The rotation and orientation of objects in ogre.

Source: Internet
Author: User

Here are some knowledge points to review:
There are multiple methods to indicate the rotation of an object:
() A rotating matrix (directly adding the dot vector * the result of this matrix is the result of rotation)
() Ouarla, that is, pithc (around the X axis), yaw (Y), Roll (Z). In essence, this is to break down any rotation around X, Y, z-axis rotation synthesis.
However, the computation around a coordinate axis is relatively simple (many books have told us that it is easy to understand)
(3 Quaternary
() Axis angle method, that is, through the description: round a axis to a degree.

Since an object may have to be rotated multiple times before it is finally rendered, we cannot find the new world coordinates of each point on the object. usually, save the state of his transition and accumulate the rotation effect in the future so that only one rotation is performed during rendering.
So, it is convenient to indicate that the cumulative rotation effect is only (1) (3. this is because matrix operations and Quaternary operations are very simple, while the Euler's solution and the axis-angle method do not show the effect of accumulation.
On the other hand, when we use (4) to convert an object, this conversion can easily be converted to the representation of the Quaternary element.
For example, convert degrees a from Axis A to degree A. Q:
Q. W = cos ():
Q. V = sin (a) × A. // Q. V and A are three-dimensional vectors.
It is also easy to accumulate the four-element. For example, if the original rotation state is Q1 and the applied rotation is Q2, the accumulative result is
Q1 = Q2 * Q1 //: all the three elements are Quaternary.
Finally,
When rendering to the screen at last,
After doing this operation, we can get the world coordinates of each point on the object:
Q = Q1 * Q * Q1-1 (Q1 inverse) Q is a 3-dimensional point.

OrientationIt is equivalent to a rotation relative to the original orientation, and can also be expressed using a quaternary number.

//-----------------------------------------------------------------------
// Perform a rotation on the object, which is equivalent to providing it with a ry corresponding to the conversion.
// Therefore, When you rotate an object, the object does not actually rotate. Instead, I saved the value of the Quaternary element you gave me,
// When you let me rotate again, I multiply the new rotator with the old one, and the obtained value is the cumulative rotation effect.
// This way, when I start rendering on the screen, I use the I-saved Quaternary element] morietation * (a 3-dimensional vertex vector) * mOritation-1] to get the final effect

//-----------------------------------------------------------------------
//: Axis-angle representation, indicating rotation.
//: The conversion is essentially a rotation of the Quaternary element.
Void camera: Rotate (const vector3 & axis, const radian & angle)
{
Quaternion Q;
Q. fromangleaxis (angle, axis );
Rotate (Q );
}

Void camera: Rotate (const quaternion & Q)
{
// Note the order of the mult, I. e. Q comes after
Morientation = Q * morientation;
Invalidateview ();
}

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.