Unity API Parsing (8)--quaternion class

Source: Internet
Author: User

Four--consists of 4 components of x, Y, Z and W, which belong to the struct type

The selection angle used to store and represent objects

Eulerangles Properties--Euler's Corner

The transform of the Gameobject object is the order of the Euler angle, which rotates the corresponding angle around the z-axis, rotates the corresponding angle around the x-axis, and the last y-axis-the final state of the different rotation order.

Using unityengine;using System.collections;public class eulerangle_ts:monobehaviour{public    Transform A, B;    Quaternion rotations=quaternion.identity;    Vector3 eulerangle = Vector3.zero;    float speed = 10.0f;    void Update ()    {        ///The first method assigns quaternion to transform rotation        rotations.eulerangles = new Vector3 (0.0f, Speed * time.time, 0.0f);        A.rotation = rotations;        The second way, the three-dimensional vector represents the Euler angle directly assigned to the transform eulerangles        eulerangle = new Vector3 (0.0f, Speed * time.time, 0.0f);        B.eulerangles = Eulerangle;    }}

setfromtorotation--Creating an Rotation instance

Used to create a rotation from fromdirection to Todirection

cannot be set directly using the Transform.rotation.setFromToRotation (V1,v2) method, only the instantiated quaternion are assigned to Transform.rotation

Using unityengine;using System.collections;public class Setfromtorotation_ts:monobehaviour {public    Transform A, B , C;    quaternion q1 = quaternion.identity;void Update () {        //cannot be used directly c.rotation.setfromtorotation (a.position,b.position) ;        Q1. Setfromtorotation (a.position,b.position);        c.rotation = Q1;        Debug.drawline (vector3.zero,a.position,color.red);        Debug.drawline (Vector3.zero, b.position, color.green);        Debug.drawline (C.position, C.position+new Vector3 (0.0f,1.0f,0.0f), color.black);        Debug.drawline (C.position, C.transformpoint (vector3.up*1.5f), Color.yellow);}}

setlookrotation--Setting the orientation of the quaternion instance

quaternion q1 = quaternion.identity;

Q1. Setlookrotation (V1,V2);

Transform.rotation = Q1;

The Transform.forward direction is the same as the V1 direction

Transform.right perpendicular to Vector3.zero, V1 and V2, the 3-point plane

Can not be used directly using Transform.rotation.SetLookRotation (V1,V2), you should instantiate a quaternion and then use Setlookrotation The last assignment to Transform.rotation

The angular axis representation of a toangleaxis--quaternion instance

This method is usually used in conjunction with the static method Angleaxis (Angle:float, Axis:vector3), so that the rotation of an object remains consistent with the rotation of another object

Angle between angle--quaternion instances

Used to return the angle from parameter A to parameter B transformation--The angle returned is not the angle of a local axis to the transformation, but rather the Gameobject object from state A to State B to make the minimum angle required to be rotated

dot--Point Multiply

euler--four-dollar number of Euler angles

Returns a four-tuple instance of the Euler angle Vector3

Fromtorotation--quaternion Transform

inverse--Value of Reverse quaternion

lerp--linear interpolation

lookrotation--Setting the orientation of the quaternion

slerp--spherical interpolation

Unity API Parsing (8)--quaternion class

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.