Coordinate transformation understanding

Source: Internet
Author: User

1. Simplifying the idea of transformation:UseInertial coordinate system(the inertial coordinate system is the position of the world coordinate system to translate to the object coordinate system) can simplify the object-world, the world-object, or any two coordinate systems between the conversion to do an intermediate conversion, make the problem simple. UseNested Coordinate Systems(Parent coordinate system-sub-coordinate system-sub-coordinate system) can also decompose the problem, simplifying complex transformation logic.In fact, the simple way to think about the problem is to instantiate, split it, transform it, and then combine the transformation of abstraction back, it can be very elegant to solve the problem. the orientation and movement of many objects need to be carried out in the same coordinate system, and the rendering pipeline itself requires the conversion of multiple coordinate systems to achieve rendering.
2. The relationship between object transformation and coordinate system transformation:The object is transformed (for example, the coordinate system of the object is treated as a world coordinate system without changing, so the object is required by the world coordinate system to see the rotation translation transformation), which is equivalent to the reverse order of the inverse amount of the object coordinate system (for example, the object is fixed unchanged, Then the coordinate system needs to be reversed in the opposite direction to translate the rotation in the opposite direction. In fact, the transformation of the coordinate system will also be the coordinates of all the objects to recalculate position, but sometimes that more appropriate to use that kind of transformation, the general problem is the transformation of the object, but in reality is the transformation of the object coordinate system (assuming the object is unchanged), because the transformation of the coordinate system more convenient to deal with the transformation between multiple The final object only needs to recalculate the position once .
3. Nested coordinate systems, for bidirectional transformations between coordinate systems: object to World Advanced row scaling (changes in the axis size affected by the axis direction and the origin) after rotation (changing the axis to be affected by the origin) after the translation (change the origin, not affected by the size and axis of the axis), the world to the object before the opposite translation of the opposite rotation , Other coordinate systems also conform to this law. The reverse order is mainly due to the combination of matrix transformation to seek inverse requirements .
4. Example:The D3DXMATRIXLOOKATLH function embodies the transformation of the world-observing coordinate system:
D3dxvector3 Position (0.0f, 0.0f, -5.0f),//camera position vector in the world coordinate systemD3dxvector3 Target (0.0f, 0.0f, 0.0f);//target is the point at which the camera needs to be panned and rotated, either the origin or other observation pointsD3dxvector3 up (0.0f, 1.0f, 0.0f);//define the upward direction, generally [0,1,0]D3dxmatrix V;//V is the transformation matrix of the World-to-view space, which computes the transformation of the world coordinate system to the observed coordinate system (the object is assumed to be unchanged) .//In fact, the position of all objects in the new coordinate system is recalculated. D3DXMATRIXLOOKATLH (&v, &position, &target, &up);Device->settransform (D3dts_view, &v);//Set the state of the transform, and the objects inside the camera and camera will be transformed together when actually transformed.

The new coordinate system returned is:

Zaxis = Normal (At-eye)
Xaxis = Normal (cross (up, Zaxis))
YAxis = Cross (Zaxis, Xaxis)

Xaxis.x yaxis.x zaxis.x 0
Xaxis.y yaxis.y Zaxis.y 0
Xaxis.z yaxis.z zaxis.z 0
-dot (Xaxis, eye)-dot (YAxis, eye)-dot (Zaxis, eye) 1



Coordinate transformation understanding

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.