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