The meaning and use of quaternion in unity

Source: Internet
Author: User

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

Quaternion means a four-dollar number, which is used to represent rotation.

They are compact and do not produce gimbal deadlocks and can easily be interpolated. Quaternion is used within unity to represent all rotation actions. (Universal joint is what can Baidu under)

The four-dollar number is based on complex numbers and is not easy to understand intuitively, so you basically never need to access or modify a single quaternion component (x,y,z,w); Usually you just need to get the existing spins (for example, from transform) and use them to construct new rotations (for example, Smooth interpolation between two rotations). In the application of the four-tuple function, 99% of the time is applied to the following functions (additional functions are used only) quaternion.lookrotation, Quaternion.angle, Quaternion.euler, Quaternion.slerp, Quaternion.fromtorotation, Quaternion.identity.

You can use Quaternion.operator * to rotate a rotation by another rotation angle, or to rotate a vector by a rotation angle.

Static variables:
Identify
Identify is a read-only variable. This four-dollar number is equivalent to no rotation, which is still the object itself.

Variable:
Eulerangles
Returns the Euler angle that represents the rotation.
This [int index]
Use [0], [1], [2], [3], respectively, to access the x, Y, Z, w components.
W
A W component with a four-dollar number. Do not modify this component directly unless you are aware of the four-dollar number.
X
The X component of the four-dollar number. Do not modify this component directly unless you are aware of the four-dollar number.
Y
The Y component of the four-dollar number. Do not modify this component directly unless you are aware of the four-dollar number.
Z
The z component of the four-dollar number. Do not modify this component directly unless you are aware of the four-dollar number.

Constructor:
Quaternion
Constructs a new four-dollar number with the given x, Y, Z, and W components.

Function:
Set
Set the X,y,z,w component for an already existing four-dollar number.
Setfromtorotation
Creates a rotation from fromdirection to todirection.
Setlookrotation
Creates a rotation that has a specific forward and upward direction.
Toangleaxis
Converts the rotation to a "corner-axis" representation.
Tostring
Returns a fully formatted four-tuple string.

static method:
Angle
Returns the angle between two rotations A and b.
Angleaxis
Rotate the angle around the axis axis to create a rotation.
Dot
A point multiplication between two rotations.
Euler
Returns a rotation angle, rotates the z-degree around the z-axis, rotates the X-degree around the x-axis, and rotates the Y-degree around the y-axis.
Fromtorotation
Create a rotation from fromdirection to todirection.
Inverse
Returns the reverse rotation of the rotation.
Lerp
The value is interpolated from the T-value from, and the result is normalized after the operation.
Lookrotation
Creates a rotation that has a specific forward and upward direction.
Rotatetowards
Rotates an angle from the from direction to.
Slerp
The spherical interpolation, interpolated from the T-value from.

Operator:
Operator! =
Determine whether the two four-dollar number is unequal
operator *
Merge two rotations
operator = =
Determine if two of the four-dollar numbers are equal

The meaning and use of quaternion in unity

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.