Unity Four-dollar number

Source: Internet
Author: User

If you want an object (i,j,k) to rotate the θ around the A (x, Y, z) axis. This rotation with a four-dollar number means q =((X,Y,z ) sin θ/2 , cosθ/ 2) The object is expressed as P = ((j,j,k), 0) with a four-dollar number. Then the point of the rotated object is P′ , then:

< Span id= "mathjax-span-509" class= "Mrow" > < Span id= "mathjax-span-514" class= "Mi" > a formula can be calculated to P′ value.

< Span class= "Texatom" > < Span class= "mn" >< Span class= "Mrow" >quaternion.angleaxis (30.0f, Transform.right This method means to create a four-dollar number indicating that the transform.right axis rotates 30 degrees. Four USD multiple rotation operations can be performed with the * operator for example:

< Span class= "Texatom" > < Span class= "mn" >< Span class= "Mrow" >transform.rotation = Quaternion.angleaxis ( 30.0f, Transform.right)  *  quaternion.angleaxis (30.0f, transform.up);

< Span class= "Mi" > < span class= "Mo" > You can also use  Quaternion.Euler  Euler rotation to represent four-dollar rotations such as:

< Span class= "Texatom" > < Span class= "mn" >< Span class= "Mrow" >transform.rotation = Quaternion.euler (new Vector3 (0.0f, 30.0f, 20.0f)) * Quaternion.angleaxis (30.0f, Transform.forward);

If you want to rotate a vector as follows:

Vector3 somevector = new Vector3 (1.0f,1.0f,1.0f);
Vector3 newvector = Quaternion.angleaxis (vector3.up) * somevector;

Quaternion.lookrotation (a vector v) makes the object's orientation and V consistent

The difference (quaternion.slerp) rotation is made using four-dollar numbers:

Transform.rotation = Quaternion.slerp (Transform.rotation,quaternion.euler (New Vector3 (0.0f, 30.0f, 0.0f)) * Quaternion.angleaxis (30.0f, Transform.forward), Time.deltatime * 0.33f);

Unity Four-dollar number

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.