Game Basics Production Mechanism of Game Contents 1 (Affine Space)
GCC Academy
Hello, this is Lee Deukwoo of Game Math
During this time, we'll learn about affine space
We're going to talk about two things today
First, we'll talk about what an affine space is
and why it is formed
Then we'll talk about the elements
that form up the affine space
The Concept of Affine Space
I'm first going to explain about the affine space
Before that, I'll explain about why
we need the affine space
When we implement computer graphics
we can't leave out the function of movement
Implementing computer graphics without the movement function
is actually a state with
a very important function left out
But in the concept of linear transformation that we talked about
we weren't able to implement this movement
It's because for the concept of movement
the origin itself has to move
But for the concept of vector that we learned
it always started from the origin and continued somewhere else
It was the concept of an arrow
Therefore, for this concept of linear transformation
we can't be separated from the origin
so we can't implement these kinds of transformations
If we were to make a matrix
that actually implements these movement functions
we need to design a linear transformation like the following
But a matrix that can satisfy this doesn't exist
When we multiply a linear transformation
the multiplied value must only be added to x
and then only to y
but there's no linear transformation that satisfies this
Therefore, we weren't able to implement the movement function
with the original linear transformations that we had
But here, if we apply a little bit of
the translation that we mentioned last time,
then it would be a different method
It's not a normal method, but it would be a different method
where we can implement the movement function
I'll briefly explain about that method
Let's first look at translation
As we mentioned earlier,
one axis stays there
and the y-axis is translated this way
That's what translation is
How can this be related to movement?
In the two dimensional translation,
let's look at just the x value first
It's two dimensional here, but we'll first look at
only the one dimensional value, the straight line
The y-value underneath here
Take a look at this red standard basis vector
on y=0
Next, look at this vector of 1,
blue and located on y=1
and parallel to the standard basis vector
When we translate one unit,
the bottom standard basis vector stays the same
but this vector, on y=1,
changes from 1 to 2
If we translate two units
then it changes from 2 to 3
Then how can we interpret this?
It's a translation of two dimensional space
but when we only use one dimension,
not the entire two dimension,
When we apply a translation of 1 unit,
in terms of this straight line, y=1,
in terms of all the coordinates where y=1,
all the points on this line
moved to the right by one unit
Next, a translation of 2 units
The result of applying a translation of scale 2 is
in terms of just this y=1 part,
all the points moved to the right
by 2 units, all at once
In other words, there's a partial spot
that moves by the amount we translated
and that's where y=1
where the value of the last dimension is 1
If we use this, we can ultimately
utilize the translate function, expand upon it, and
implement the movement function as well
Right now, we can call it a one-dimensional movement
Since the x value increased from 1 to 2, to 2 to 3
means that we used a two dimensional transformation
to implement a one dimensional movement
If we want to implement a two-dimensional movement
then we just need to use a three-dimensional translation
Just like in the figure below,
in the three-dimensional space formed by x, y, and z,
when we push the x and y axis by (a, b)
then along this flat surface where z=1
it moved from the origin
by the amount (a, b)
Therefore, this translation of a flat surface
Or, two-dimensional translation
ultimately means one-dimensional movement
and translation of a space
is the movement of a flat surface
We can talk about the movement of a flat surface like this
Then how can we show this three-dimensional translation
with a numerical expression?
Using a three-dimensional square matrix
fixing only the z
and only moving x and y in the matrix
can be expressed this way
When we actually use a matrix multiplication
and multiply it to a three dimensional vector x, y, 1
the result is the exact result
that we wanted earlier
It adds a to x, and b to y
The last value stays at 1
and this is the flat surface where z=1
This means z=1, and actually, we
don't need to use this
If we just cut this part off
we can obtain the result of
moving by the amount a, b that we wanted
However, we're cutting it off at the final value
When we actually use the matrix
we need to use a 3x3 square matrix
Like this, when we conduct the transformation
at a space one dimension higher
then we can conduct movement, rotation, and scaling
in the form of linear transformation
These transformations are called affine transformation
Therefore, in affine transformation
the movement function is included
The movement transformation that we looked at just now
gets utilized as an affine transformation
We can call this a two-dimensional movement
Well then, the rotation and scaling that we used before
used a 2x2 square matrix
For those, we just need to artificially increase it by one dimension
Just like the following, set the last dimension to 1
and fix the scale transformation
For rotation as well, fix the last z axis
so that nothing occurs
Then you'll get a rotation of a flat surface
Just like that, if you set all linear transformations
to transformations with a scale of 3,
then using the linear transformation that we mentioned earlier,
we can decrease the number of operations
using matrix multiplication
which is an advantage of matrices
These three transformations are the main transformations
that are used in game production
Translation, scale, and rotation
We take the first letter of each and call them TSR
Let's analyze it structurally
The entire vector space
would be one dimension higher
than the space that we're actually moving
But we're not using the entire space
There's a separate space where we can actually move
In the perspective of two-dimension
the yellow area here
is the corresponding space
In this space where the last dimension z-value equals 1,
all the elements in this space are called points
The yellow space
is called the affine space A
Therefore, a point is ultimately
the elements within this yellow space
They're the elements that are part of this yellow space
Their characteristic is that
the last dimension value is always 1
Therefore, a point in the two-dimensional space is
(x, y, 1)
A point in the three-dimensional space
refers to (x, y, z, 1)
With that, we defined what a point is
In order to create a new point
we need another creation system
In the correlation of points
they need to make something with each other
What we use here in the affine space is a sliding vector
It's also called a displacement vector
It's used for representing the correlation between points
You can think of it as an element of the vector space
that's surrounding the affine space
Therefore, if we add this displacement vector on the point
we can create a correlation with another vector
If you see here, we added a displacement vector v on the point P1
and created a correlation with P2
in this picture
You must never change the value of the vector
And that's because the value of the last dimension of P1 is 1
and the value of the last dimension of P2 is also 1
When this displacement vector is added
and if the value of the last dimension isn't 1
we would break the rule of affine space,
where we can move at the scale of a, b
that we have set
Therefore, for the displacement vectors
the last dimension shouldn't affect the location of the point
so it must always have a value of 0
Therefore, the displacement vector of two-dimensional space
becomes (x, y, 0)
The displacement vector of three-dimensional space
becomes (x, y, z, 0)
Composing Elements of Affine Space
With that, we learned about the affine space
Now we'll look into the composing elements of affine space
The composing elements of affine space can be separated into
two parts, a point and a displacement vector
For displacement vector, I'll explain later but
we just call it vector for short
But this vector is a bit different
from the mathematical vector we talked about earlier
The word is just the same
This vector is actually similar to the vector
talked about in physics
A point is the subject that we can move
That's how you can view it
A vector is the medium used
for moving that subject within the same space
You can say that it's the power
So this entire affine
This area that the affine space takes up in this 3D vector space
is the area where z=1, where the last dimension equals 1
The area used by the displacement vectors
is the area where z=0
Let's think about the rules
of this affine space, points, and vectors
First of all, we've said that when we add a vector to a point
we get a point
When we add a vector to a point, we get a point
Other way around, when we subtract a point from a point
we can obtain vector
which is the correlation between the two points
Point - point gives you a vector
but point + vector gives you a point
Then what would happen if we do vector + vector?
We would make a vector with a new direction
with the vectors combined
Finally, among the ones we didn't mention
there's point + point
For this, actually
we get a result we can't use
When you think about how the last dimension is 1 and 0
you can easily predict this relationship
For a point, the last is 1, and for a vector, it's 0
so it becomes 1-1=0, and it's true
Then 1+0=1, that's true
0+0=0, that's satisfied
But when we do 1+1, we get 2
Then the element
of vector space where z=2
cannot be moved the way we want
so it's technically impossible to use
To understand this rule better
I'll express the point as time, and the vector as hours
Then it will be easier to understand
For point - point
if we compare a point to a time
we can say that it's time - time
When we subtract 2 PM from 3 PM
we would get one hour left
That corresponds to this vector of one hour
Then it will be easier to remember that
point - point equals vector
Point + vector, in terms of time and hour,
it will be time + hour
When we add 1 hour to 3 PM
then we get the time of 4 PM
Therefore, point + vector gives us a point
Finally, point + point means time + time
Adding 3 PM to a 2 PM, that's a very vague concept
Therefore, we determine that
this can't be used
Finally, I'll explain about
the significance of affine space
The vector space that's one dimension higher, which is the stage
The stage of the game that we're using
is actually composed of vector space
that's one dimension higher
Within that, there's a particular space
where we can move about
Because of this affine space
we are able to move with linear transformation
What that means is that
the character can move, like in a game,
and we can place various objects on the world
A foundation has been made for that
as what you should know
And within this world space
all the objects composing this map we're moving about
are composed using the points
of the affine space
The objects may stay right where they are
but we may apply power in real-time
and make them fly or move
The power used for moving them
the power of scale and direction
is carried out using the displacement vector
to move the objects
So when we use numbers and vectors
we sometimes expressed them as points
and we sometimes expressed them as arrows
that continued from the origin
There was this ambiguity of expressing a single subject
with two ways
but in the affine space,
the expression is done by a point, the movement is done by an arrow
Since we can distinguish them clearly,
we are able to form a stronger system
and that's a significance
The vectors used in this affine space
have very similar concepts as
the mathematical vectors I've talked about earlier, but
the application range is actually a bit different
We can say that it's the concept of vectors used in physics
With that, we set the basics of the game world
through affine space
We'll use this to implement various transformations
and get into producing a game world
That's all for this lecture
Great job for listening to the lesson, thank you
Concept of affine space Problem of movement transformation Since vector starts from origin, the basis vector cannot be separated from the origin
Utilization of translation Use a three-dimensional square matrix to move a two-dimensional flat surface by the wanted amount
[1 0 a] [x] = [x + a] [0 1 b] * [y] = [y + b] [0 0 1] [1] = [ 1 ]
Affine transformation Increase the space by one dimension and convert translation, rotation, and scaling transformation into linear transformation
Essential affine transformation: Translation, scale, rotation Elements of affine space: point, displacement vector
Composing elements of affine space Point Element of affine space Value of last dimension is 1 Location information for visual expression of object
Displacement vector Another form of vector used to express correlation of points Value of last dimension is 0 Medium for moving the points
Rule of affine space Point+vector=point Point-point=vector Vector+vector=vector Point+point=cannot use
Significance of affine space Can implement movement by using affine space, which is a particular area of vector space that's one dimension higher...