http://blog.csdn.net/huazai434/article/details/6458257
I read "3D Math Fundamentals: Graphics and Game development" around May 2009, when the concept of universal locking in the European Cape was always baffled and never encountered. There is a saying in the book: "If you have never encountered a universal lock situation, you may be confused about it, and unfortunately, it is difficult to clarify this issue in this book, you need to experience to understand." "Today I have 3 hours to think again about this problem, finally to understand, now to share the results of thinking to everyone."
I would like to explain four questions below:
1, what is Euler's angle?
2, what is a universal lock phenomenon?
3. What happens when a universal lock is encountered in a game animation?
4, how to solve the problem of universal lock?
One, what is Euler's angle?
In a nutshell, the Euler angle is the angle of rotation of the object around the coordinate system three axes (x, y, Z axis).
In this case, the coordinate system can be the world coordinate system, can also be the object coordinate system, the rotation order is also arbitrary, can be any kind of xyz,xzy,yxz,zxy,yzx,zyx, can even be xyx,xyy,xzz,zxz and so on ... So the Euler angle is varied. Euler angles can be divided into two situations:
1, Static: That is, around the world coordinate system three axis rotation, because the object rotation process of the axis remains stationary, so called static.
2, Dynamic: That is, around the object coordinate system three axes of rotation, because the object rotation process of the axis as the object does the same rotation, so called dynamic.
For rotation around three axes respectively, the following theorem is established:
Any kind of rotation of an object can be broken down into rotations that revolve around three axes respectively, but not in a single way. Such as:
Assuming that the rotation around the y-axis is heading, the x-axis is rotated to pitch, and the z-axis is rotated to the bank, the first heading45° pitch90° equivalent to pitch90° and bank45° first.
Two, universal lock is a kind of what phenomenon?
For the dynamic Euler angle, the rotation is around the object coordinate system. (Static no universal lock problem) No matter how many degrees heading and bank, as long as the pitch is ±90° (that is, the rotation around the second axis), there will be a universal lock phenomenon.
In order to have a perceptual understanding of this phenomenon, please pick up your own mobile phone (no?). NO) and a pen (used as a rotary axis), do the following several rotations.
First determine the mobile phone object coordinate system orientation, in order to facilitate memory, we assume that the z-axis and mobile phone screen vertical (mobile phone flat on the desktop) pointing above, a short edge of the mobile phone is the x axis, the longer one side is the Y axis (direction by the phone tail pointing to the head), the origin of the object coordinate system is the (Note that the rotation order is ZYX)
Rotate any angle around the z-axis (note that the X and Y axes are also rotated), rotate 90 ° around the y-axis, and rotate any angle around the x-axis. With many attempts, you will find one thing in common: the z axis is always horizontal, and in layman's words, the phone will never stand up! Originally we thought the cell phone would point in any direction, but in fact the phone seems to be locked on the desktop, can only point to a horizontal direction, this phenomenon is called universal lock.
And if the rotation around the y axis is not equal to 90° (1° or 89°), just choose the appropriate angle around x and Z, you can make the phone point to the three-dimensional space in any direction, the phone is free, you will not encounter universal lock phenomenon.
Third, what happens when a universal lock is encountered in a game animation?
There is a universal lock phenomenon, the essential reason is that when the second rotation angle is 90°, the third axis is transferred to the same direction as the first axis, so the phone is missing a degree of freedom (vertical degrees of freedom missing), leaving only the first axis and the second axis of freedom. And only two degrees of freedom means that mobile phone movement is confined to the two-dimensional space, so the phone will never stand up.
In the game, when the character spins the animation trigger, the character will make a series of continuous rotation transformations, each of which will be represented by a set of Euler angles, but it is not possible to each location of the Euler angle is stored, so the animator defines a series of keyframes, specifying the position of the role at the Keyframe (described by a set of Euler angles), The computer then interpolates these groups of Euler angles according to the time t, resulting in a series of Euler angles.
If the pitch is not ±90°, there will be no universal lock phenomenon, and a series of Euler angles after interpolation can fully depict the desired role rotation path.
If a keyframe's pitch is rotated around the second axis to 90°, it encounters a universal lock, when the phone can only rotate within the horizontal plane, and if the animator specifies the next keyframe the position of the phone is not set up, there is no problem, but what happens if the orientation of the next keyframe specified is set up?
In order to have a perceptual understanding, or mobile phone, for example, below I specified four key frames, four key frames at the mobile phone's azimuth respectively with R0,R1,R2,R3 four group Euler angle representation (counterclockwise is the positive direction, right hand rule):
(Note that the object coordinate system at the R0 is the same as that of the world coordinate system, I assume the z axis is up, the x axis is right, the Y axis points to your chest)
Rotation angle around the z-axis around the y-axis rotational angle about the x-axis
r0:0 0 0
R1:90 0 0
r2:90-90 0
r3:0 0 90
Please make these four changes to your phone first, then remember the four directions of your phone, and imagine what your "expected" continuous animation should look like.
Simple description: The initial moment, the phone is located on the desktop, the screen facing up, the phone head pointing to your chest, and then, the phone in the desktop counterclockwise rotation 90 °, know that the phone head pointing to the right, and then the phone's right to start high up, until with the desktop vertical, when the phone head still pointing to the right, Since the second rotation of the R2 is 90°, the phone enters the Universal lock mode. Then the phone should turn back to you, stand up perpendicular to the desktop until the phone is straight back to you.
But is the reality the case?
You can try to interpolate the four azimuth and then rotate to see if the path is the same as we expected above.
Here are my attempts:
The interpolation of R0 to R1 and R1 to R2 is calculated and then rotated to fully conform to the above path. However, after the R2 to the R3 of several interpolation, the rotation of the resulting path and expectations do not match. For example, these two interpolation values:
Z:60 y:60 x:30
Z:45 y:45 x:45.
To do these two rotations, you will find that the phone is not perpendicular to the desktop, that is, the path of the R2 to R3 and the expected offset. This is the "path offset" and "camera jitter" mentioned in "3D Mathematical Fundamentals: Graphics and Game development".
Summary: If the animator specifies an orientation at a keyframe that will cause a universal lock, the path between the two keyframes is offset when the direction of the next keyframe exceeds the bounds of the universal lock, reflecting the rotation offset on the character animation, which is reflected in the lens control as the lens jitter.
To get a sense of the path offset, you can refer to this video: This video is somewhat different from my description, which is explained by a strange device called the Universal node, and I am directly using the object coordinate system but the path offset is the same.
Http://v.youku.com/v_show/id_XNzkyOTIyMTI=.html
Four, how to solve the problem of universal lock?
The root cause of this problem is that the interpolation of the Euler angle is not linear in the case of a universal lock, so the rotation path shifts.
The workaround is to:
The Euler angle is converted to four, and the number of four is slerp the spherical linear interpolation, then the series of four is converted to the corresponding Euler angle, and then the role is applied. The disadvantage is to consume a certain amount of memory, but the role can be arbitrarily rotated, high flexibility.
Game animation Central European pull angle and universal lock understanding (Turn)