[OpenGL] rotating matrix calculation around any unit axis

Source: Internet
Author: User

In 3D transformations, Rotation Transformations are often used, and many transformations are centered around any axis. The following describes two methods to rotate around any unit axis.

Assume that the angle to be rotated is A, and the axis around it is R.


Method 1:

(1) build a new foundation

Find the coordinate axes S and T in the other two units of length. They are vertical to each other and vertical to R. In this way, R, S, and t form a group of new bases.

The specific method of S:

Find the minimum component in R, set it to 0. Then swap the other two components, and then reverse the first non-zero component (in fact, you can also reverse the other non-zero component ).

T is required. Only cross product of R and S is required.

Detailed formula:



This ensures that R, S, and t constitute a group of orthogonal unit bases.


(2) transform the standard base to the new base.

The R and x axes must be overlapped by transformation, so that the subsequent rotation is the normal rotation around the X axis. The other two axes also overlap.

The transformation matrix consists of the preceding R, S, and t vectors:



(3) Rotating

Because R overlaps with X, in the new base, we only need to rotate around the X axis (normally rotating.

Assume that the rotation matrix is rx ().


(4) return to the original standard base.

The transformation matrix should be M's inverse matrix. Because m is orthogonal, its inverse matrix is its transpose matrix.


Therefore, the final transformation matrix around any unit axis is:



Method 2

According to the formula given by Goldman, this formula is a bit complicated:



For detailed derivation process, refer:

Http://www.cppblog.com/lovedday/archive/2008/01/12/41031.html

http://www.cnblogs.com/cg_ghost/archive/2012/04/27/2473347.html

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.