News for hackers. Stuff that matters.
Re:Introduction to the Math of Computer Graphics by Ologn on Wednesday December 30, 2015 @08:11AM (#10811903)
Yes. Imagine you have a cube plotted in XYZ coordinates. The eight vertex points are (0,0,0), (0,0,10), (0,10,0), (0,10,10), (10,0,0), (10,0,10), (10,10,0) and (10,10,10).

Now let us say you want to rotate that cube 30 degrees on the X axis. You take the last vertex and make it a matrix, adding 1 at the end like you will do with the others, i.e. (10 10 10 1). Then you multiply it by the X rotation matrix ( https://open.gl/transformations ) using the appropriate angle. You now have the new correct position of that point. Now do the same for the other vertexes on the cube. The cube is still the same size and shape but its position has shifted.

You can do other easy transformations with matrix math. You can scale the cube with a scaling matrix - doubling it, halving it, or whatnot. Just multiply each vertex to the same scaling matrix. The new coordinates have the same size.

You can have a translation matrix to, where each vertex is multiplied by the same translation matrix, so that the cube is translated x, y, z coordinates from its origin.

You can also chain these matrix multiplications, so that the cube size is doubled, then rotated 60 degrees on the Y axis, then moved 20 X, -30 Y, 15 Z via translation. So that is multiplying three matrices in a row, then multiplying them against each vertex.

There are no comments on this comment yet.