Sign in to follow this  
Caitlin

4x4 matrix triangles or individual verts?

Recommended Posts

I am wondering if 4x4 matricies typically contain values for a single vertex, or does the matrix define a triangle (3 verts). I would assume that since its 4x4 it would contain vert info for a complete triangle.

Share this post


Link to post
Share on other sites
Matrices generally store transformation information which are then applied to an arbitrary number of vertices. A matrix by itself can store scaling, sheer, rotation and translation, but inherently does not store point information.

Share this post


Link to post
Share on other sites
I'm by no means an expert :), but I think that most people use a 4D vector or 3D to contain a vertex individually (most likely 1) and then use a 4x4 matrix vector to descibe operations done on that vector. Though, I suppose any vector , say (1, 1, 1, 1) can be broken down into

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Does that answer your question?

Share this post


Link to post
Share on other sites
So verts aren't stored in matrix form when manipulating them? Let's say I have a triangle with the following points:

PX0 = 4, PY0 = 9, PZ0 = 1
PX1 = 0, PY1 = 0, PZ1 = 0
PX2 = 7, PY2 = 5, PZ2 = 2

Are they, if this is how verts are organized when manupilating them, arranged like so:

P0 P1 P2 n

X 4 0 7 0
Y 9 0 5 0
Z 1 0 2 0
n 0 0 0 0

Share this post


Link to post
Share on other sites
A vertex is treated as a vector that is multiplied by the matrix. While you can batch vertex multiplication by storing multiple vertices in a matrix before being multiplied by the transformation matrix, the mathematics are no different than interpreting each as a single vector and multiplying them in turn.

Share this post


Link to post
Share on other sites
Quote:
Original post by Caitlin

Are they, if this is how verts are organized when manupilating them, arranged like so:

P0 P1 P2 n

X 4 0 7 0
Y 9 0 5 0
Z 1 0 2 0
n 0 0 0 0


Ok, the way this is put is a bit confusing to me, but I'll try and see if I can answer it with this general explanation.

if you had three points, say (4, 0, 7) (9, 0, 5) and (1, 0, 2) and you wanted to do something to them , you would manipulate them by applying a 4D matrix to them. This gets kinda tricky because those things have only three points. I don't want to confuse you more (because I was in this boat a little bit ago), but most people usually just add a "1" to those 3d points at the end (4, 0, 7, 1), etc. Now, say you wanted to do something to those vertices. You would just simply apply whatever transormation you like to each one.

here, in example, is something I use in my own code to modify a vertex:

[source lang="cpp"

SHYR_INLINE ShyrVec3 ShyrMat3::operator*( const ShyrVec3 &vec ) const {
return ShyrVec3(
mat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,
mat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,
mat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );
}




Granted, this example is just a 3D matrix and 3D vector, but you could apply the concept to anything. This Matrix transforms the vector by multiplying it by whatever I want.

If you would like some references, check these out:

http://www.gamedev.net/reference/articles/article695.asp

http://www.upl.cs.wisc.edu/~psilord/docs/local_axis.html

The second is a bit tricky to follow, but very informative. Let me know if I can help you anymore in any way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this