Vector coordinate conversion, rotation matrix, and view Conversion

Source: Internet
Author: User

In the 3D world, we need to constantly convert coordinates in various spaces. For example, we need to convert an object from a model space to a world space, and convert points in a world space to a view space of a camera. We know that coordinate conversion can be achieved by multiplying a vector and a conversion matrix. Note that if the row vector is selected, the matrix is placed on the right side of the multiplication, and if it is a column vector, the matrix needs to be placed on the left side of the vector to multiply. If the displacement is not considered, we can use a 3x3 matrix to indicate rotation or scaling operations.

If we use a row vector to represent a point P (px py pz) in a model space, assuming that the model is rotated, the new axis is represented as R (the left and right axes) in the World Space, u (the upward axis) f (the forward axis), and the rotation matrix is

RX ry Rz

UX Uy uz

FX FY FZ

After p is multiplied by the matrix, the new X point is PX * RX + py * UX + PZ * FX, that is, the dot product of the column vectors of P and the rotation matrix. The dot product of a vector can also be understood as the projection of a vector on a vector. If we observe the rotation matrix from the column perspective, we can find that the first column is actually the new R axis after the original R axis is rotated in the opposite direction. Similarly, the third column in the second column is the same. This makes it easy to understand. A model rotates an angle so that the model does not move and the coordinate axis rotates the same angle in the opposite direction. After rotation, each column is a new vector representation of the coordinate axis. The point is multiplied by the rotation matrix, which is actually the projection of the original point on the new coordinate axis.

After converting all models to the world coordinate space, we need to go to the view space. Assuming that we know that the conversion matrix of the camera from the model space to the world space is the rotation matrix above, to convert an object to the camera space, the inverse of the above matrix is required. The inverse of the orthogonal matrix can be expressed by the transpose matrix of this matrix. So the transformation matrix becomes

RX UX FX

Ry Uy FY

Rz uz FZ

If a point P in the world space is multiplied by this matrix, the result is (p * r, p * u, p * f). here we can see that the point of the world space is converted to the view space, it is actually the projection of points on the coordinates of the camera. Here we do not consider location conversion, but only consider the 3x3 matrix to simplify thinking.

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.