OpenGL homogeneous coordinates

1 Overview

In computer graphics, translation, rotation, scaling and projection transformation of geometry are often encountered. Generally, homogeneous coordinates and transformation matrices are involved.

Question: Can two parallel lines intersect?

In Euclidean space (geometry), two parallel lines on the same plane cannot intersect, or never intersect. This is common sense that everyone is familiar with.

However, this is not the case in projected space. For example, the train track in the image below becomes narrower as it moves away from the eye. Finally, the two parallel rails meet at the horizon, a point at infinity.

The railroads narrow and meet at the horizon.

 

Euclidean spaces (or Cartesian spaces) are good enough to describe our 2D/3D geometry, but they are not good enough to handle projective spaces (actually, Euclidean geometry is a subset of projective geometry). The Cartesian coordinates of a 2D point can be expressed as (x, y).

What if the point goes to infinity? Points at infinity cannot be represented concretely in Euclidean space. In projective space, parallel lines meet at infinity, but not in Euclidean space.

Solution: homogeneous coordinates

Homogeneous coordinates, proposed by August Ferdinand Möbius (yes, that Möbius circle guy), make graphics and geometric calculations possible in projective spaces. Homogeneous coordinates are a way to represent N-dimensional coordinates with N+1 numbers.

To make 2D homogeneous coordinates, we simply add an extra variable w to the existing coordinates. Thus, a point in Cartesian coordinates, (X, Y) becomes (x, y, w) in homogeneous coordinates. Whereas X and Y in Cartesian coordinates are re-expressed as x, y and w in homogeneous coordinates as

X = x/w
Y = y/w

Why is it called "Qici"?

As mentioned before, in order to convert homogeneous coordinates (x, y, w) to Cartesian coordinates, we simply divide x and y by w.

Converting Homogeneous to Cartesian, we can discover an important fact. Let's see an example below.

 

As you can see the three points (1, 2, 3), (2, 4, 6) and (4, 8, 12) correspond to the same Euclidean point (1/3, 2/3). And any The number (1a, 2a, 3a) multiplied by a is the same point as (1/3, 2/3) in Euclidean space. Therefore, these points are "homogeneous" because they represent the same point in Euclidean space (or Cartesian space). In other words, homogeneous coordinates are independent of the multiplier a.

 

Mathematical Proof: Two Parallel Lines Can Intersect

Consider the following linear system in Euclidean space.

And we know that since C≠D, the above equation has no solution. If C=D, then the two lines are identical (overlapping).

Let's rewrite the equation for projective space, replacing x and y with x/w, y/w respectively.

Now, we have a solution, (x,y,0), because (CD)w=0, ∴w=0. Therefore, two parallel lines intersect at (x,y,0).

(x,y,0) geometrically represents a ray with no starting point and end point, and no length, it only has a direction.

Applications of homogeneous coordinates

Homogeneous coordinates are a very useful basic concept in computer graphics. By adding an extra dimension W, it can be used to scale, rotate, translate, and perspective projection matrix transformations on geometry.

Any N-dimensional homogeneous coordinates, as long as W is not 0, can be converted to a vector of W=1 by dividing each component by W, and then obtain the point value of its N-1-dimensional Euclidean space.

When W=0, this coordinate represents an infinitely long vector, usually representing an N-1-dimensional vector.

Guess you like

Origin blog.csdn.net/wzz953200463/article/details/131349633