-
A quaternion represents a rotation. We don't need to master computing, we can use it if we understand its purpose.
A quaternion Q serves two purposes:
1. Indicates status . Indicates the rotation state, for example, the rotation attribute of transform is a quaternion.
2. Table rotation action . A quaternion is multiplied by another quaternion, which represents the superposition of rotation operations; a quaternion "multiplies" a three-dimensional vector, which represents the rotation represented by Q on the modified vector.
Tips: The first case can also be regarded as the rotation represented by Q from the initial state.
-
There are common ways to create a quaternion as follows:
1.new creates a new quaternion
2. Specify the rotation axis and angle to create a quaternion
3. Create a quaternion from Euler angles (rotation order is zxy)
4. The quaternion from the start direction to the end direction
5. Create an inverse based on an existing quaternion
6. Directly create a rotation state quaternion that can be assigned to transform.rotation
-
Usage 1: The rotation attribute of the transform component is a quaternion (table state ). can be specified directly
-
Usage 2: Multiplying a vector on the right side of the quaternion is to rotate according to the quaternion (table action )
-
Usage 3: Quaternion multiplied by quaternion, superposition of table rotation . As shown in the figure, first perform q1 and then q2
-
Usage 4: Through the Matrix4x4.SetTRS function, pass in the position (3D vector), rotation (quaternion), scaling (3D vector), and construct the matrix.
-
Usage 5: Progressive interpolation through SLerp, or uniform interpolation through additional code.
How does Unity use quaternions?
Guess you like
Origin blog.csdn.net/haneya/article/details/106750762
Recommended
Ranking