WorldWind Source Analysis series: Four meta-number class

Source: Internet
Author: User

The Quaternion4d class in pluginsdk may be feeling microsoft.directx. The quaternion class is not very practical or inadequate, and has been re-written.

Four dollars is the British mathematician Hamilton (W.r.hamilton) discovered in 1843, because of the continuous enrichment of matrix theory and continuous improvement, people are more willing to use the matrix to solve the problems in the actual project, which resulted in four yuan in a long time has not been paid attention to, but also did not get the actual application. With the development of computer graphics, it is found that the use of four yuan can be a good solution to solve the problem of rotational operations, this theory has begun to be valued, and in many areas gradually applied.

Four USD extends the concept of three-dimensional rotation to the rotation in four-dimensional, provides a quaternion class for defining a four-tuple object and a four-tuple calculation in DirectX, which describes a four-dimensional vector (x,y,z,w) that can be used to wrap an object around a vector (x, y, z) by four elements Rotates an angle theta, where W=cos (THETA/2). The four-dollar operation is more efficient in this calculation than in matrix computing. For a rotating axis axis (axis.x, Axis.y, axis.z) (unit of the shaft component), Theta is the angle to rotate around the axis (counterclockwise), it can be represented by a four-element Q (X,Y,Z,W) with the values of each element:

q.x = sin (theta/2) * axis.x

Q.y = sin (theta/2) * AXIS.Y

Q.z = sin (theta/2) * axis.z

Q.W = cos (THETA/2)

The class diagram for the Quaternion4d class is shown below.

Static quaternion4deulertoquaternion (double yaw, double pitch, double roll) are used to convert the sail angle yaw, Angle pitch and roll angle rolls are converted to four-dollar objects.

Static Point3D Quaterniontoeuler (quaternion4d q) is used to convert a four-tuple object representing rotation to an angle of angle yaw, tilt-angle pitch, and roll-angle rolls.

Overloaded with add, subtract, multiply, divide, equal, not equal operators for point object operations.

Conjugate, Norm2, Abs, Dot, Normalize, Length, Slerp, Ln, EXP, squad, squad, Squadsetup, etc., define basic operations on four-dollar numbers. Please refer to the relevant literature for specific meanings.

WorldWind Source Analysis series: Four meta-number class

Related Article

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.