3D Math Basics: Conversion between four-and Euler-angles

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.