Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

matrix[4][4] in a 3d lib

programmeurkeprogrammeurke Member Posts: 19
hi,
now i've understood the whole bunch about matrices and vectors, i found myself a good library. In that library they use 4*4 matrices, but I don't know what's in it, how many points or something like that. BTW: for rotating they only use till 0..2 of the matrix (so there are 7 numbers not used).
Secondly: vectors exist of four items: an x, a y, a z and something else.
What do you think it is, that fourth number?
Thanx in advance.
[green][b][size=5]P[/size][size=4]ro[/size][size=3]g[/size][size=2]r[/size][size=1]amm[/size][size=2]e[/size][size=3]u[/size][size=4]rk[/size][size=5]e[/size][/b][/green]

Comments

  • MutilateMutilate Member Posts: 22
    Well...I dont if your 3d lib use the same way to perform geometric trasformation as I do. There are also quaterions that can (not sure) be rapresented like a 4x4 matrix.
    And matrices can also be passive or active trasformation that change the way you do what u have to do. But if we are talking of the same thing (which is the moust common way), then your matrix should look like this:

    [rxx ryx rzx tx]
    [rxy ryy rzy ty]
    [rxz ryz rzz tz]
    [0 0 0 1]

    so when u multiply this matrix with a point (x,y,z,1) u get:
    x*rxx + y*ryx + z*rzx + tx =new_x
    x*rxy + y*ryy + z*rzy + ty =new_y
    x*rxz + y*ryz + z*rzz + tz =new_z
    x*0 + y*0 + z*0 +1 =1
    [rxx,rxy,rxz], [ryx,ryy,ryz], [rzx,rzy,rzz] are the vectors of the x, respectly y, respectly z axis of the old coordinates system (the one you were expressing the point beform performing the trasformation). This are the "things" that particaly rotate your point in your new coordinates system. All these vectors should have lenght=1, if you dont perform scaling.

    Instead [tx,ty,tz] is the traslation vector, that means that your point will be moved by this vector in order to be trasformed in the new coordinates system (x+tx, y+ty, z+tz).

    [0,0,0,1] this vector is linked to the fact your are using fake 4-dimensional vectors, that's called omogenus coordinates system, but nothing I can explain within few lines, and you dont really need to know that, just figure out that in order to add the traslation we need at last a 3x4 matrix, but you can't multiply a 3x4 matrix with a 3x1 vector, you need a 4x4 matrix and a 4x1 vector to do that. But this is just a mathematical needs, when u know what u need and how to do it, you can just take away the [0,0,0,1] row to spare memory and computation time.

    You said that you lib used the forth coordinate, well...I read around that it's more and more common to write a point with 4 cordinates like (x,y,z,w), w should be the "weight" (right spelled?) of the point. Ok what it's the weight of a point...I dont really know, it seems that is used for shading and maybe also for morphing, but I didn't need such a variable yet (that would be rather a vertex's charateristic, than a point's one, wouldn't it ?).

    Anyway if the forth raw of the matrix contain some kind of trasformation aplied to the weight, they aren't done as the a mathematical matrix multiplication 'cause It will scale the traslation vector and modify the point's coordinates, the wight would also be corrupted by the coordinates...quite a mess.

    Mutilate

Sign In or Register to comment.