Avoiding Gimbal Lock - 3D
Transcription
Avoiding Gimbal Lock - 3D
Avoiding Gimbal Lock o place an object in 3D space,its transformation proper- is a pivoted device,most often a ring, which rotatesaround a single ties need to be specified:position, scale,and orientation. The axis. By mounring a gimbal inside another one, the inner ring ro- first two attributes are easily definable by three numbers for tatesaround an additional axis, increasingrhe degreesoffreedom each. The meaning of the x, y, and z positions and scaleparamerers by one. Defining the orientation of an objecr with Euler anglesis are easyto understand,visualize,manipulare, and animate for art- like putting it inside a virtual three-gimbaldevice,and then rotar- ists. However, that is not the casefor orientation. ing each ring by the correspondingangle. (Once again, the order Using an xyz rriplet (three angular values) to manipulare an of rotations and the coordinate frame axesmust be agreed upon.) object'sorientation may become impossible-for ir.rstance, during some configurations of the rhree angles,such as gimbal lock-and lead to major problems when animating rhesevalues.Gimbal lock is a phenomenon known for a long rime, and it has causedsevere problems long before compurer graphicsemerged.According to NASA documents on the Apollo spaceprogram, pilots had to keep a closeeye on the Gimbal Lock warning light while maneuvering the spacecraft in order to avoid unwanted and dangerous malfi-rnctioningin the guidanceand control sysrems. The orientation, or angular position, of a rigid object has three degreesof freedom. By holding a camera in our hands, for example, we can pan left and right, tik it up and down, or roll it without changing the point of interest.The mosr common and intuitive way to define theseartributesis rhe useof Euler angles:The orientation is represented by three consecutive rotations around the main axesof a reference frame. However, the order of the rotational axes is something the industry has never agreed on, so The outer ring can represenrthe rilt, the middle rir.rgthe pan, and it is essentialto supply this information if we transfer animation data using Euler angles.Each major 3D application has a way to the innermost ring the roll. However, most of the publications on Euler anglesrefer to the three attributes as yaw pirch, and roll, as changethe order ofrotations. used in aerospaceapplications. Using three gimbals, it is possiblero consrrucra physicaldevice, a gimbal sysrem,basedon the principle of Euler angles.A gimbal Having full control over the three degreesof freedom, one could conclude that Euler angles (or gimbal sysrems,in general) are the perfect way to describe orientation. Unfortunately, rhere are configurations wherein we lose one degree of freedom: the gimbal lock. In this state, one of the girnbal rings is rotated such that it aligns perfectly with another. In this siruation, the enrire range of rotations is unreachable, and we may need to first re-orient the locked gimbal in order to rorare the ring arbitrarily. If the angles are near the gimbalJock stare, the gimbal system becomes unsrable, as even small rotations (or round-off errors of the numerical representation) may yield unexpected results. rol J u n e2 0 0 9 'T?awprertr-rutmtrffiffi It is fairly easyto get closeto gimbal lock 'We simplyneedto rotatethe'middle" angle, or gimbal, by 90 degrees.Becausenryoofthe rotational axeshavebecomealigned,chang- ing gimbals, Euler anglesare the industry qmnot rotatefreely,therebyriskingthe loss ing the first or the last anglein the chain re- standardfor describingrotations. Real-world gimbal systems have been sultsin a rotation around the sameaxis(see ofreference. imagesabove).The only way to leavethis known and usedfor a very long time now. ing the magazineand begin watching the locked sate is to adjust the middle rotation The gyroscope--invented nearly 200 years againand move it out of the dangerzone. ago-is a fine example:At the heart of this 1995 movieApolb I 3 farvring Tom Hanl6 (and some great visual effects). You will deviceis a pladorm,with oneor morespin- be surprisedhow much they talk, or yell, GimbalLod<in CG This may be a good dme to finish read- ning wheelsor disla mounted in gimbals. about avoiding gimbal lock and losing the Computer animators controlling charac- The largeattgular momentum of the spin- referenceof the Inenial MeasurementUnit. ters' body pans or any kind ofobject us- ning elementsforces the central platform The IMU of the Apollo space program ing only three angularvaluesshould try to to remain almost perfecdyfixed, regardless was a three-gimbalrystem,and pilots were avoid gimbal lock. Investipte your setup of the motion of the devicet'thell," asthe required to navigatethe spacecraftso they beforeyou stan to animate,and changethe gimbalslet it rotatefreely.By installing sen- did not approachthe lO-degreedangerzone order of the axesso the middle axis is the sors to detect the rotation of eachgimbal, around gimbal lock. The curent atdrudeof leastone used.Ifdl three degreesoffree- we can measure the relative orientation (or anitude) of any object as it relatesto the vehide was displayedon the Flight Direcor Anitude Indicator,or the "eight bdl," aspilots refered to it. Ifthe indicatorentered help. If readabiliry and human interac- a fixed reference$zstem;That is how the Inenid MeasurementUnit (IMU) of air- tion are not important, such as under the craft, spacecraft,and watercraft, including I80-degree poles, and t}le stable member hood of game engines, then quaternions guided missiles,works. The three gimbals and rontional matricesare usedinsteadof lost its attitude reference,the gimbalshad to be re-alignedin-fight againststarreferences. Euler angles.Quaternions arefour-dimen- hold the central stableplatform-widr the spinning glsms115-v/ithout introducing sional representadons,ideal for compudng any notable external torque, whic} would smooth transitionsbetweenposes.\7hile force the pladorm to loseits origind orien- gimbal lock never happens when using tation. That is where gimbal lock becomes 1-i crew members,who were losing oxygen quaternions,they arehard to readand con- a real problem: By losing one degreeof and electricalpower in a crippled spacecraft ceptualize.In spite of all the issuesof lock- freedom near this state,the fixed platform at the sametime. dom are needed,hierarchical transformations (parenting an additional node) may fie red dangerzone centeredat yaw 0 and So,the nexttime you arefighting gimbal lock in a 3D animation packageor game engine,dont panic.Just rhink of theApolb June2009 't:'i;t'+! | 11