On coordinate system

Coordinate systems play a very important role in the graphics rendering pipeline, they are not very complicated. When we study geometry in school, the first thing we are exposed to are coordinates. But let’s look at these things first, which will make it easier to understand the concept of matrices.


In the previous article we discussed the concept of points and vectors. There, points and vectors are represented by three real numbers, but what do those numbers mean? Each of the real numbers represents their distance to the origin. For example, if we draw a line and mark a point right in the middle of the line, we say that this point is the origin. This point is the reference point that we use to measure distance. If a point is to the right of the origin, we express its distance as something greater than 0, and if a point is to the left of the origin, we express its distance as something less than 0.


Let’s say we have a line that goes infinitely to both sides of the origin, so that the distance between the two ends is infinite. In mathematics, this is fine, but in the computer world, it is. In general, we can calculate only a limited range of things. However, this limited size is enough to create complex 3D worlds, so it doesn’t really matter.

Now let’s scale this line so that it can be used to measure the length. So we can use it to measure what the coordinates of a point are. In computers, this scale is called the coordinate axes.

If a point is not on the coordinate axis, we can still project its position onto the coordinate axis. The distance between the projection point and the origin is going to be our point relative to the origin.

We’ve already inadvertently said that defining the coordinate position of a point on a coordinate axis.


Dimensions and Cartesian coordinates

Let’s think of the horizontal line as the X-axis. We can then draw a second coordinate axis, which passes through the origin perpendicular to the X-axis. Let’s call this axis the Y-axis. From now on, for any point, we can project it onto the x axis and onto the y axis, and then calculate the distance from the origin, and use that to represent the position of that point. Such a position contains two numbers representing the x and y coordinates. So, we can say, we can define a two-dimensional space with two axes.

For example, draw a bunch of dots on a piece of paper. This piece of paper occupies a two-dimensional space. You can view it as a plane. We can draw an axis for each dimension. If we measure the position of each point again using the x and y axes, the two coordinate axes form a coordinate system. If these two axes are perpendicular to each other, we call it a Cartesian coordinate system.

We usually represent the coordinates of a point by a set of statements in a definite sequence. The two marks are separated by a comma. For Cartesian coordinates, we usually write the x coordinate first, and the y coordinate after. For example, we would call a point of x 2.5 and y 2.25 (2.5,2.25). But don’t let these two things scare you, they’re just marking the relationship between this point and the origin.

So far, we’ve figured out how to make a 2D frame, and define 2D points in that frame. You also need to make it clear that the 2D coordinates of these points are unique. That is to say, it is impossible for points in the same coordinate system to appear in different positions. The other thing you need to know is that there are more than just standard coordinate systems, the axes of coordinate systems don’t have to be horizontal or vertical, you can place your coordinate system however you want.

In fact, we can define an infinite number of coordinate systems on a plane. Let’s say, for simplicity, that we draw two Cartesian coordinates on a piece of paper. And, we put a point on the paper. The coordinates of the points will be different depending on the reference frame, although their physical positions will not change. Such as:


The coordinates of point P in A coordinates are negative 1,3, and the coordinates of point P in B coordinates are 2,4. But they’re all saying the same thing. Remember those coordinates in OpenGL? Is it just a little bit more understanding of what OpenGL matrices do?

So, if we know the coordinates of point P in B coordinates, what do we need to find the coordinates of that point in A coordinates? This principle is particularly important in our computer graphics. We’re going to learn very quickly how to map the coordinates of a point from one coordinate system to another.


Now, let’s consider the previous example. We can map the coordinates of P from A to B by adding the coordinates (-1,3) to (3,1). And we can map P from B to A by adding negative 3, negative 1 to 2,4. So what we’re going to notice here is that negative 3, negative 1 and 3,1 happen to be inverse. The key word: Inverse.


Another common operation is to move a point from one position in the coordinate system to another without changing the reference system. This operation is called a translation operation. This is also the most basic operation. In fact, all the other linear transformations can also be applied to points. Multiplying the coordinates of a point by a constant affects the scaling of the coordinates of a point. If YOU scale a point, you’re going to see in space that the point is going to move along the line that connects it to the origin.


In addition, students of the engine course must read the full set of all the text resources provided by us, although a little boring, but will always be reflected in the engine course code. When the class starts, you won’t have to agonize over the details.