Learned in the OpenGL Programming Guide,Strong push: detailed explanation of caster99 blogger、The homogeneous coordinate understanding of jeffasd god、Homogeneous coordinates Baidu Encyclopedia
OpenGL uses a camera model that compares the view transformation operation to the process of taking a photo with a camera. The specific steps are as follows:
1. Move the object to be shot to the specified position in the scene. (Model Transformation, Model Transform)
2. Move the camera to the position where you want to shoot and align it in a certain direction. (View Transform, View Transform
)
3. Set the camera's focal length, or adjust the zoom ratio. (Projection Transform, Projection Transform)
4. Transform to adjust the size of the photo to the desired image size. (viewport transformation)
The first three can be implemented with a transformation matrix
Homogeneous coordinates are ubiquitous in computer graphics because they allow translation, rotation, scaling, and perspective projection, etc., to represent a general vector operation in which a matrix is multiplied by a vector. According to the chain rule, the sequence of any such operation can be multiplied into a single matrix for simple and efficient processing. In contrast, if Cartesian coordinates are used, translational and perspective projections cannot be represented as matrix multiplications, although other operations are possible. Both OpenGL and Direct3D graphics cards now take advantage of homogeneous coordinates to implement a vertex shader engine with a vector processor with four registers.
Homogeneous coordinates foreign language reference:http://www.songho.ca/math/homogeneous/homogeneous.html
Problem import: two parallel lines can intersect at one point
In Euclidean geometry, two parallel lines of the same plane cannot intersect, which is a scene we are all familiar with.
However, in the perspective space, two parallel lines can intersect, for example: the train track becomes narrower and narrower as our line of sight, and the last two parallel lines intersect at infinity .
Euclidean space (or Cartesian space) is well suited for describing 2D/3D geometry, but this method is not suitable for dealing with perspective space (in fact, Euclidean geometry is a subset of perspective geometry), 2D Cartesian coordinates. Can be expressed as (x, y).
If a point is at infinity, the coordinates of this point will be (∞, ∞), in Euclidean space, this becomes meaningless. Parallel lines intersect at the infinity of the perspective space, but not in the Euclidean space. The mathematicians have found that using homogeneous coordinates can solve this problem.
In short, homogeneous coordinates use N+1 dimensions to represent N-dimensional coordinates.
We can add an additional variable w to the end of a 2D Cartesian coordinate to form 2D homogeneous coordinates. Therefore, a point (X, Y) becomes (x, y, w) in homogeneous coordinates, and there is
X = x/w
Y = y/w
For example, the homogeneous coordinate of (1, 2) in the Cartesian coordinate system can be expressed as (1, 2, 1), and if the point (1, 2) moves to infinity, it becomes (in Cartesian coordinates). , ∞), then its homogeneous coordinate is expressed as (1, 2, 0), because (1/0, 2/0) = (∞, ∞), we can use "∞" to represent an infinity Clicked.
The way we convert the homogeneous coordinates into Cartesian coordinates is that the first n-1 coordinate components are divided by the last component.

In the process of converting homogeneous coordinates to Cartesian coordinates, we have a discovery, for example:

You will find that (1, 2, 3), (2, 4, 6) and (4, 8, 12) correspond to the same Euclidean point (1/3, 2/3) , the product of any scalar, for example (1a, 2a, 3a) corresponds to (1/3, 2/3) inside the Cartesian space. Therefore, these points are "homogeneous" because they represent the same point in the Cartesian coordinate system. in other words,Homogeneous coordinates have scale invariance.
Proof: Two lines can spatially intersect visually.
Consider the following equations:

We know that in the Cartesian coordinate system, the system of equations has no solution, because C ≠ D, if C = D, the two lines are the same.
Let us replace the x, y with the homogeneous coordinates x/w, y/w in the perspective space.

Now we have a solution (x, y, 0) where the two lines intersect at (x, y, 0), which is at infinity.
Comprehensive:
Many graphics applications involve geometric transformations, including translation, rotation, and scaling. When calculating these transformations as matrix expressions, translation is matrix addition, rotation and scaling are matrix multiplication, which can be expressed as p' = m1p+ m2 (Note: For customary reasons, the change matrix is generally used to multiply the vector in practice) (m1 rotates the scaling matrix, m2 is the translation matrix, p is the original vector, and p' is the transformed vector). The purpose of introducing homogeneous coordinates is mainly to multiply and add in the merging matrix operation, expressed as p' = pThe form of M. That is, it provides an efficient way to transform a set of points in a two-dimensional, three-dimensional or even high-dimensional space from one coordinate system to another using matrix operations.
Second, it can represent points that are infinite.
Assuming a 3-dimensional vector x, we linearly transform Tx for this vector, but T is any 33 matrix, can not complete the vector translation operation (such as x = (0, 0, 0), Tx can not be transformed to (1, 0, 0) in any case).
Here we need to use homogeneous coordinates. The purpose of using homogeneous coordinates is to add vector values to complete the vector translation. Familiar with OpenGL already knows, it is enough to put 3D data into the thinking coordinate space. That is, x = (0, 0, 0) is converted into x = (0, 0, 0, 1). T also changed to 44 matrix.
The homogeneous coordinates express the direction rather than the position. For example, x1=(1,2,3,1) and x2=(2,4,6,2) actually represent the same position in the 3-dimensional coordinate system. In addition, the larger the last component w, the more homogeneous coordinates will be at a farther position. When OpenGL is ready to display the assembly, it will use the left and right components to divide the previous three components, thus re-converting the secondary coordinates into the 3-dimensional coordinate system, so the larger the w, the smaller the object will be displayed. When w is 0.0, the coordinates may be infinitely close, so that the display may appear infinite. This concept is very important because the projection matrix below uses this concept!
1. Distinguish between vector and point Question: For a coordinate (1,3,5), can you tell whether it is a vector or a point? Homogeneous coordinate representation is one of the important means of compu...
1. Graphic transformation is one of the basic contents of computer graphics Geometric transformation, projection transformation, window transformation Linear transformation, the attributes remain unch...
homogeneous coordinates https://blog.csdn.net/silangquan/article/details/50984641 See this article here to prove that two parallel lines in perspective space intersect at infinity emmmmm feeling. . Af...
Matrix representation and homogeneous coordinates There are many matrix transformation formulas in this section. For convenience, set it as a picture format, but the example code can be copied, so tha...
effect: Convert homogeneous coordinates in clipping space to homogeneous coordinates in screen space principle: For homogeneous coordinates in the clipping space, the range of values for x and y is ...
forward from "Perspective division" written for everyone - homogeneous coordinates and projection OF: StanGame link: Source: Short book the term In most 3D work, our reference is based on th...
table of Contents(?)[+] Transform vector A vector has a direction (Direction) and a magnitude (Magnitude, also called intensity or length). The vector can be in any dimension (Dimension). Since a vect...
Transform in OpenGL Matrix transformation 1.1 zoom 1.2 translation 1.3 rotation 1.4 matrix combination 2. Case implementation 2. Zoom: 2.1.1 isometric than zoom 2.1.2 Not equal to zoom 2.1.3 Mirror X ...
Transform Matrix vector It is a piece of data composed of direction and size. Seeing that in the formula, there is a horizontal bar above the letter, which generally represents a vector ...
Earlier we mentioned the scaling and rotation transformation of the image, and the transformed pixel position mapping relationship can be expressed in the form of matrix multiplication. So, what about...