Quaternion interpolation and Matrix

Source: Internet
Author: User

In the previously involved procedures, processing the rotation of an object is usually in the form of a matrix. Due to the enhancement of hardware in texture ing and grating, programmers can use more CPU cycles for Physical Simulation and other work, which will make the program more realistic.

1, source: http://www.gamasutra.com/features/19980703/quaternions_01.htm

Ii. Excerpt:

There are three methods to indicate rotation: Matrix Representation, Euclidean representation, and triplet representation. It may be difficult to process interpolation in the matrix or orah notation.
There are always ways to represent the orientation of an object. most programmers use 3x3 rotation matrices or three Euler angles to store this information. each of these solutions works fine until you try to smoothly interpolate between two orientations of an object.

Matrix Representation is not suitable for interpolation (instantaneous orientation is obtained between the first and second orientations of the rotation ). The matrix has 9 degrees of freedom (3x3 matrix), which actually means that a rotation requires only 3 degrees of freedom (rotation axis 3 ).
Rotations involve only three degrees of freedom (DOF), around the X, Y, and Z coordinate axes. however, nine DOF (assuming 3x3 matrices) are required to constrain the rotation-clearly more than we need.

Another login coming of rotation matrices is that they are extremely hard to use for interpolating rotations between two orientations. The resulting interpolations are also Ally very jerky, which simply is not acceptable in games any more.

Orazo notation
You can also use angles to represent rotations around und three coordinate axes. you can write this as (Q, C, F); simply stated, "transform a point by rotating it counterclockwise about the Z axis by Q degrees, followed by a rotation about the Y axis by C degrees, followed by a rotation about the X axis by F degrees."

A defect in the oaram Notation: It turns a rotation into a series of rotations. In addition, interpolation is not convenient.
However, there is no easy way to represent a single rotation with Euler angles that corresponds to a series of Concatenated rotations. Furthermore, the smooth interpolation between two orientations involves Numerical Integration

Directory

[Hide]

  • 1-4-tuple notation
  • Basic operation rules of 2 tuples
  • 3. Formulas for rotating with four tuples
  • 4. Rotating superposition

[Edit]

Triplet Representation

[W, V] where V is a vector, indicating the rotation axis. W scalar, indicating the rotation angle. Therefore, a triplet represents a complete rotation.
There are several notations that we can use to represent quaternions. The two most popular notations are complex number notation (Eq. 1) and 4d vector notation (Eq. 2 ).

W + Xi + YJ + ZK (where I2 = J2 = k2 =-1 and ij = k =-ji with real w, x, y, z) (Eq. 1)

[W, V] (where V = (x, y, z) is called a "vector" and W is called a "scalar") (Eq. 2)

4D space and unit tuples:
Each Quaternion can be plotted in 4D space (since each quaternion is comprised of four parts), and this space is called quaternion space. unit Quaternions have the property that their magnitude is one and they form a subspace, S3, of the quaternion space. this subspace can be represented as a 4D sphere. (those that have a one-unit normal), since this has CES the number of necessary operations that you have to perform.

[Edit]

Basic operation rules of tuples

Table 1. Basic operations using quaternions.

Addition: q + Q' = [W + W', V + V']

Multiplication: qq' = [WW '-V · V', v x v' + WV '+ W' v] (· is vector dot product and X is vector Cross Product ); note: QQ '? Q'q
// Why? -- Defined as this, which makes sense.
Conjugate: Q * = [W,-v]

NORM: n (q) = W2 + X2 + y2 + Z2 Mode

Inverse: Q-1 = Q */N (q)

Unit quaternion: Q is a unit quaternion if n (q) = 1 and then Q-1 = Q *

Identity: [1, (0, 0, 0)] (when involving multiplication) and [0, (0, 0, 0)] (when involving addition)

[Edit]

Formulas for rotating with four tuples

Important !!!! : Only the Unit Four tuples indicate rotation.Why ???? -- Solved (shoemake has a detailed proof)
It is extremely important to note that only Unit Quaternions represent rotations, and you can assume that when I talk about quaternions, I'm talking about Unit Quaternions unless otherwise specified.

Since you 've just seen how other methods represent rotations, let's see how we can specify rotations using quaternions. it can be proven (and the proof isn't that hard) that the rotation of a vector V by a unit quaternion Q can be represented

V '= Q v q-1 (where V = [0, V]) (Eq. 3)

//////////////////////////////////////// ////////////////////

The conversion of the four tuples and the rotation parameter is expressed by four variables (X, Y, Z, W). If a axis and angle of the rotating axis are given, the calculation formula of the four tuples is as follows:

void Quaternion::fromAxisAngle(const Vector3 &axis, Real angle){Vector3 u = axis;u.normalize();Real s = Math::rSin(angle/2.f);x = s*u.x;y = s*u.y;z = s*u.z;w = Math::rCos(angle/2.f);}

The formulas for calculating the axis and angle of the rotating axis are as follows:

/void Quaternion::toAxisAngle(Vector3 &axis, Real &angle) const{angle = acos(w)*2axis.x = xaxis.y = yaxis.z = z}

//////////////////////////////////////// /////////////////////

Quatinians by shoemake: a pure mathematical explanation.

  • Content

    • More computational properties (too many mathematical symbols, too lazy to compare ).
    • It is proved that the rotation can be represented by the unit tuples.
    • Pushes down the conversion between tuples and matrices.

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.