In-depth exploration of orthogonal projection transformation

Source: Internet
Author: User

-Pan Hong

-2009.4.20

-My skills are limited, and mistakes are inevitable. Please give me some advice from mathematical experts and programming experts.

-Email: popyy@netease.com

 

Previously, we studied the principle and generation method of Perspective Projection Transformation of OpenGL, d3d, and M3G in "Deep Exploration of Perspective Projection Transformation" and "Deep Exploration of Perspective Projection Transformation (continued. These methods are widely used in mainstream image APIs. However, for projection applications, there is also a frequently used projection method that requires in-depth understanding-orthogonal projection. We will study it in this article (Here we assume that the reader has read the first two articles, and understand the vast majority of theories, because orthogonal projection is much easier to deduce than perspective projection, so our derivation will be very fast. If readers have any questions, please refer to the first two articles or contact me by email ).

Prior to the specific study, I think it is necessary to briefly introduce the classification of planar projection in order to give everyone a general understanding of this knowledge system. See:

Plane projection is divided into two types: Parallel projection and Perspective Projection. The latter is described in the first two articles. Parallel projection is a projection method with a rectangular observer (perspective projection is the eye cone observer). It does not scale objects according to the distance from the object to the viewpoint (perspective projection will ). Parallel projection can be divided into two types: side projection and orthogonal projection. How can these two types be distinguished? Let's continue to see the figure:

In, V is the projection plane, and N is its normal. P and q are two points outside the plane, and p and q are their projection points on the plane. Q's Projection Direction vector is Q = unitization (Q'-q), while P's Projection Direction vector is P = unitization (P'-P ), Q does not run on N while P is parallel to N. Q is called a side projection, while P is called an orthogonal projection. Orthogonal projection is our research object today.

In reality, the classification of the above-mentioned plane projection can continue to be subdivided. For example, the Perspective Projection can be divided into one drop point, two drop points, and three drop point perspective projection. Side projection can be further divided into scatter projection and oblique two-axis projection. Orthogonal projection can be divided into axial-side projection and multi-viewpoint orthogonal projection. If you are interested in this, you can refer to the relevant graphics tutorial.

Next we will study orthogonal projection. This section describes OpenGL, d3d, and M3G respectively. Our environment conventions (left and right hand coordinate system, row and column vector multiplication, CVV range) still respect the corresponding API settings.

OpenGL orthogonal projection transformation
It is the observation space in the right hand Coordinate System of OpenGL. What we see is the rectangular observation body of orthogonal projection. The origin is the camera position, and N is the distance from the near-cropping plane to the camera plane, f is the distance from the plane to the plane of the camera. P is a point in the object, and p 'is the point after its projection.

We have something to do after projection:

Because it is orthogonal projection, there is no unified projection Ray target point, so the X and Y after the projection will not change, while Z will always become-N, we ran to the projection plane (we made the projection plane overlap with the near-cropping plane) and it was useless, then we use this useless information to save Z (used for subsequent meta operations) and write it:

In this way, CVV is built in the z direction, so that when Z is near the cropping plane, AZ + B =-1, while Z is cropping the plane far, AZ + B = 1 (the Z range of OpenGL CVV is [-]. I have already said it three times. If readers are confused, we strongly recommend that you understand the first two articles ). Let's calculate a and B.

Then, we use the current result to reverse push orthogonal projection matrix version 1.

 

 

Then we establish X and Y into CVV (simple linear interpolation)

 

 

Reverse push orthogonal projection matrix Version 2 (Final Version)

 

 

 

Then the matrix on the right is the orthogonal projection matrix of OpenGL, which can be created through glortho. If you have read and understood the previous two articles, you will feel that my derivation is becoming more concise and neat :) OpenGL solves the problem. below is d3d.

D3d orthogonal projection transformation
It is the condition of observing space in the left-hand Coordinate System of d3d. Because it is the left-hand coordinate system, the near crop plane is on the z = n plane, while the far crop plane is on the z = f plane.

 

After projection

 

 

 

Save Z with the third useless information and write it

 

Make (the Z range of d3d CVV is [0, 1])

Reverse push orthogonal projection matrix version 1

CVV linear interpolation for X and Y

 

 

 

 

 

 

It can be discussed in two cases (if you are not clear about this, refer to the second article "exploring Perspective Projection Transformation (continued)"):

(1) center the projection plane, pin 1/2 of the two sides, and then reverse push the orthogonal projection matrix.

 

 

 

The matrix below is the orthogonal projection matrix, which is also used by the d3dxmatrixortholh method.

 

(2) In general, the projection plane is not necessarily centered, and the orthogonal projection matrix is reversed directly through the projection result.

 

 

 

The matrix below is the orthogonal projection matrix, which is also used by the d3dxmatrixorthooffcenterlh method. Well, the introduction of d3d is complete, followed by M3G.

 

M3G orthogonal projection transformation
M3G is an encapsulation of OpenGL, so the environment is the same as OpenGL. Let's look at the interpolation of X and Y.

 

 

 

M3G uses only the center projection plane. Therefore, you can pin 1/2 of both sides to obtain

 

 

 

Next, the orthogonal projection matrix is introduced.

 

 

 

The final matrix is the orthogonal projection matrix of M3G, that is, the form used by camera. setparallel.

Conclusion
The above describes the generation method of orthogonal projection matrix used by the three APIs. The orthogonal projection matrix of the three can still be obtained through the field of view (FOV) and the aspect ratio (Aspect Ratio) of the projection plane) for more information, see the second article "exploring Perspective Projection Transformation (continued)".

The orthogonal projection matrix and the perspective projection matrix can have an infinite number, but the principle is the same. The difference is only the environment. Orthogonal projection is currently in the same position as perspective projection in the 3D engine. It is at least the basis of the 3D user interface system. Therefore, it is necessary to clearly understand the principles of orthogonal projection matrix and Perspective Projection Matrix so as to truly create, modify, and use the graphics engine.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/popy007/archive/2009/04/26/4126809.aspx

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.