Definition and usage of Quaternion in Unity, unityquaternion

Source: Internet
Author: User

Definition and usage of Quaternion in Unity, unityquaternion

Official API documentation:
File: // Applications/Unity. app/Contents/Documentation/html/en/ScriptReference/Quaternion.html

Quaternion refers to the Quaternary element, which is used to represent rotation.

They are compact and do not generate universal joint deadlocks and can be easily interpolated. In Unity, Quaternion is used to indicate all rotation actions. (What can be a universal node under Baidu)

It is based on the plural and is not easily understood. Therefore, you basically never need to access or modify a single Quaternion component (x, y, z, w ); generally, you only need to get the existing rotation (for example, from Transform) and use them to construct a new rotation (for example, smoothly interpolation between two rotations ). In the application of the Quaternary functions, 99% of the time is applied to the following functions (other functions are used only) Quaternion. lookRotation, Quaternion. angle, Quaternion. euler, Quaternion. slerp, Quaternion. fromToRotation, Quaternion. identity.

You can use Quaternion. operator * to rotate a certain rotation by another rotation angle or by one rotation angle.

Static variables:
Identify
Identify is a read-only variable. This element is equivalent to an object without rotation.

Variable:
EulerAngles
Returns the Euler's angle of rotation.
This [int index]
Use [0], [1], [2], and [3] To Access Components x, y, z, and w.
W
The W component of the Quaternary element. Do not directly modify this component unless you are familiar with the element.
X
X component of the Quaternary element. Do not directly modify this component unless you are familiar with the element.
Y
Y component of the element. Do not directly modify this component unless you are familiar with the element.
Z
Z component of the Quaternary element. Do not directly modify this component unless you are familiar with the element.

Constructor:
Quaternion
Use the given x, y, z, and w components to construct a new Quaternary element.

Function:
Set
Set the x, y, z, and w components for an existing Quaternary element.
SetFromToRotation
Create a rotation from fromDirection to toDirection.
SetLookRotation
Create a specific forward and upward rotation.
ToAngleAxis
Convert the rotation to "angle-axis.
ToString
Returns a fully formatted Quaternary string.

Static Method:
Angle
Returns the angle between two rotated a and B.
AngleAxis
Rotate the angle around the axis to create a rotation.
Dot
The point multiplication between two rotations.
Euler
Returns a rotation angle, which rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis.
FromToRotation
Create a rotation from fromDirection to toDirection.
Inverse
Returns the Reverse Rotation of the rotation.
Lerp
Interpolation is performed between the from and from values, and the result is normalized after the operation.
LookRotation
Create a specific forward and upward rotation.
RotateTowards
Rotate an angle from the from.
Slerp
Spherical interpolation: interpolation between the from and (from) values.

OPERATOR:
Operator! =
Determine whether two Enis are unequal
Operator *
Merge two rotations
Operator =
Determine whether two Enis are equal

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.