In 3D graphics, the most common method of rotation is four-and Euler-angles, which has the advantage of saving storage space and convenient interpolation compared to matrix. In this paper, we mainly summarize the conversion of two expressions, the 3D Cartesian coordinate system is used in the calculation formula:
Figure 1 3D Cartesian coordinate System (from Wikipedia)
Defined as rotation around the z-axis, y-axis, x-axis, if used Tait-bryan angle, respectively, is yaw, Pitch, roll.
Figure 2 Tait-bryan angles (from Wikipedia)
One or four definition of the number of dollars
A four-dollar number can be constructed by rotating the axis and the angle of rotation around the axis:
This is the angle that rotates around the axis of rotation, the component of the axis of rotation in X, Y, and Z (thus determining the axis of rotation).
Second, Euler angle to four yuan conversion
Three or four yuan to Euler angle conversion
As a result of arctan and arcsin , this does not cover all orientations (the range of values for the corners has been met), so atan2 is needed instead of arctan.
Iv. use in other coordinate systems
In other coordinate systems, the above formula should be adjusted according to the definition of the axis. As in Direct3D, the x-axis of the Cartesian coordinate system changes to the z-axis, the y-axis to the x-axis, and the z-axis to the y-axis (regardless of direction).
V. Sample code
Http://www.cppblog.com/Files/heath/Euler2Quaternion.rar
The demo renders two models, the left uses Euler's angle, the right uses four-dollar numbers, the arrow keys up, the ieft, and right rotate the model.
References: [1] http://en.wikipedia.org/wiki/conversion_between_quaternions_and_euler_angles[2] Ken Shoemake, Animating Rotation with quaternion Curves, 1985[3] conversion between four and Euler angles [4] four yuan and rotation [5] four yuan and rotation [6] "unity tricks" four yuan (quaternion) and rotation
3D Math Basics: Conversion between four-and Euler-angles