I think I get the idea of a vertex, as that can be used to represent a point on a shape, like a 3d model.
I think I get the idea of a vertex, as that can be used to represent a point on a shape, like a 3d model.
Suppose figuring out where a world point (in a game map, for example) should show up on screen (in pixels) looked like a bit like this function call sequence (this is simplified):
screenPoint = perspective(move(rotate(move(worldPoint))))
Think of a camera moving around the world; in virtual reality, this is exactly equivalent to the camera staying put and the world moving around instead. That's more or less how 3D graphics works. You have a virtual box that logically lives behind your screen, with the same x and y coordinates as your screen resolution, and z coordinates handled by a Z buffer that's used to determine what overlaps what. A big chunk of the matrix work is about moving, rotating and squishing the whole virtual world until the bit you want to look at fits into the virtual box that lives behind the screen.Each function (perspective, move (aka translate), rotate, scale, etc.) can be expressed in the form of multiplication by a matrix. See [1], for example. That turns it into something like this:
screenPoint = perspectiveMatrix * moveMatrix * rotateMatrix * moveMatrix * worldPoint
But because matrix multiplication is associative, we can calculate a single matrix to do all the work: transformMatrix = perspectiveMatrix * moveMatrix * rotateMatrix * moveMatrix
screenPoint = transformMatrix * worldPoint
And this is much more efficient because there's fewer calculations that need to be performed per point.A matrix corresponds to a linear mapping of some vector space to another. In case of graphics you usually start with local coordinates of your object. These have to be mapped to world coordinates, camera coordinates, and finally a perspective projection to get the screen coordinates. All these mappings can be expressed as matrices and applying mapping A after B is the same as applying the matrix product A*B to your initial coordinate vector. Precomputing the entire transformation matrix in this way causes quite a speedup for long transformation pipelines.
It helped me understand them quickly, with easy to understand, practical examples.
Don't mind the "Flash 8" context, there really isn't anything flash-specific in there.
and now multiplying a vector (~ a 3d point) by that transform matrix is the same as doing each individual transformation (in the reverse order they appear in matrix multiplication) on a point to get the point after transform
Here's an example 3-d matrix:
[ a d g ]
[ b e h ]
[ c f i ]
(a,b,c) is the vector representing the direction of the X axis; (d,e,f), Y; (g,h,i), Z.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.
I have already started on the next article, which will provide the context for what these mathematical constructs provide.
To briefly answer your question, for 3d graphics the Matrix provides an efficient mechanism to translate, scale, rotate, shear and convert between different coordinate systems.
http://webglfundamentals.org/webgl/lessons/webgl-2d-matrices...
That's 2d but if you follow them forward it will go to 3d
The neat thing is that when you multiply matrices together you update the original matrix. e.g. If you want to rotate something 90degrees to the right, you make a transform matrix with a zero transpose and multiply it with the original matrix. The resulting matrix will be an object in the same place rotated by 90 degrees.
Most modeling applications since about 2000 though use quaternions and a point to represent rotation and location. That's because it uses less memory and is easier/faster to compute.