Ways to Express a Rotation Gimbal Lock
Total Page:16
File Type:pdf, Size:1020Kb
Ways to Express a Rotation Gimbal lock ● Picture an aircraft that moves in spherical coordinates: ● Imagine if, to rotate the three ways shown, we can only adjust one of the three angles at a time. After step 1, the brown vector changes, affecting our setup for step 2. Likewise for step 3. Gimbal lock ● Suppose our pilot begins looking at the horizon but then steers straight up to look at the sun. Now, two of our three degrees of freedom spin our view of the sun around, redundantly, while none can move our view sideways away from the sun (toward the wings)! Rotation formalisms in 3D ● https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions ● Many ways to express a rotation with floats. ● Three degrees of freedom - so three floats minimum. ● Taken as three steps like in the previous example, you’d have three rotation matrices multiplied. Rotation formalisms in 3D A set of three steps could be: ○ Extrinsic (with all steps using the original axes) ■ Three matrices will be read in “points” order (right-left) Or, ○ Intrinsic (incremental like in the previous example) ■ Three matrices will be read in “bases” order (left-right) We’ll stick to intrinsic updates, local reference frames. Rotation formalisms in 3D ● Intrinsic “Euler angles” are shown here. ○ Intrinsic rotates around the current axes accumulated so far ● Both alpha and gamma here rotate around the current z axis (blue z axis for alpha, red z axis for gamma). ○ So all sets of Euler angles have redundant ordering: axis1, axis2, axis1 again ○ The particular ordering shown here is therefore z, x’, z’’ Rotation formalisms in 3D ● Tait-Bryan angles cycle through three different axes without repeats. ○ axis1, axis2, axis3 ○ One of these, z-y’-x″, gives our familiar "pitch / yaw / roll" from aircraft & cars More rotation formalisms in 3D ● Axis-angle formulation - single direct rotation to anywhere ● Rotation matrix representation - we can combine these, but can't interpolate ○ The results of linear blending of matrices are not rotations ○ Extreme example: Blend two valid rotation matrices that exactly zero out a row ● Quaternions - can interpolate these ○ 4 scalars; a unit vector ○ A more concise, but also linearly blendable, version of a rotation matrix ○ They are NOT for avoiding gimbal lock - though they do avoid strange routes around the sphere when you blend two rotations (See geodesics) Gimbal lock ● The problem isn’t the representation (don’t blame Euler angles) - it’s rotation order when adjusting in increments ○ Matrix order strikes again! ● No relation to quaternions ○ You can have gimbal lock even with quaternions ○ You can avoid gimbal lock even with Euler angles ● Any representation can gimbal lock if you tell it to rotate successively on cardinal axes one at a time. Gimbal lock ● Most people solve the problem by representing each incremental rotation in one step instead of three successive ones, removing order as a consideration. ○ For their one step, they use angle-axis pairs to go directly to their desired angle. ○ Often graphics tutorials show how to do that, but then they also mistakenly call them “quaternions” and worse say “quaternions can’t have gimbal lock.” ● Appendix C of this link also talks about that misconception: http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA484864 Quaternions ● Although both involve four numbers, the following two things are not the same: ● Angle & axis ○ One scalar and one 3d unit vector ● Quaternions: ○ One 4d unit vector ○ The first number does not represent an angle, and ○ The other three do not representent an axis. ● Extreme example: (1,0,0,0) is a valid quaternion. What kind of an axis is (0,0,0)?? ● In reality, they’re just a set of four arbitrary scalars… whose unit-length range maps to every possible rotation and every possible reflection ● Linearly mix their four scalars and you can interpolate between rotations ○ This is the only time you would want quaternions Powers of Matrices ● Another method of expressing rotations is called “exponential maps” - but what do exponents have to do with angles? ● Euler’s identity connects them: ○ Famous for succinctly combining several special constants i2 = −1 Powers of Matrices ● Another method of expressing rotations is called “exponential maps” - but what do exponents have to do with angles? ● Euler’s identity connects them Powers of Matrices ● Example: Our 45° matrix, squared, is a 90° rotation (try multiplying it out by hand). ○ We just used repetition (i.e. exponents) in place of calculating any new trig. ○ This works for any angle; we could have exponentiated 9° matrix 5 times to get the 45° matrix..