Zack
Zack

Reputation: 177

opengl transformation from model coordinate to world coordinate

I am having trouble to understand the transformation from Model Coordinate to World Coordinate. Here is the slides, my main problem is what is m1, x1, x2, x3, y1, y2, y3, and z1, z2, z3. What kind of value are they representing? and How should I determine it.

enter image description here

Upvotes: 0

Views: 2516

Answers (1)

Cyber
Cyber

Reputation: 867

They represent a transformation. Specifically, they represent the basis vectors of the transformed coordinate system. To understand what this means, I recommend watching 3Blue1Brown's "Essence of linear algebra", it explains all you need to know about these transformations in an intuitive way.

More practically, what you'll want to do is mainly 3 things: you want to scale your object, you want to rotate your object, and you want to move your object. All of these are transformations. Whenever you see the word "transformation", read it as "matrix". These operations are all matrices.

So for example the scaling matrix is:

sx  0  0 0
 0 sy  0 0
 0  0 sz 0
 0  0  0 1

Where sx is the amount you want to scale in the direction x, and so on.

The rotation matrix will depend on the axis of rotation, for example this is the rotation matrix to rotate the object around the x axis by an angle of t radians, following the right hand rule:

1       0      0 0
0  cos(t) sin(t) 0
0 -sin(t) cos(t) 0
0       0      0 1

You can find the other ones here.

This is the translation matrix used to move the object around:

0 0 0 tx
0 0 0 ty
0 0 0 tz
0 0 0  1

You combine these transformation by multiplying them together. So if your point is (x, y, z), S is your scaling matrix, R is your rotation matrix and T is your translation matrix, you transform the point like this: p = T*R*S*(x,y,z,1). The 1 as the "4th dimension" is used for projection. Tthe GPU divides x, y and z by that value, called w, after it's done processing the vertex. Research projection matrices to know more.

Upvotes: 2

Related Questions