### Author Topic: X_MULTMATRIX  (Read 3711 times)

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1634
• Particle Hawk
##### X_MULTMATRIX
« on: 2006-Nov-06 »
Code: GLBasic [Select]
DIM mat[16]
mat[0..3] = forward (local x-axis) (x,y,z,0)
mat[4..7] = local up (x,y,z,0)
mat[8..11]=local right (x,y,z,0)
mat[12..16]=translation (offset) from origin (x,y,z,1)

X_MULTMATRIX mat[]
If you want to use X_ROTATION and stuff, too - use the X_PUSHMATRIX before X_MULTMATRIX.

*quoted from gernot*

Quote
Note from Hemlos:
Im currently working with this new command and will update this in more detail as i get more information.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10697
• here on my island the sea says 'hello'
##### X_MULTMATRIX
« Reply #1 on: 2006-Nov-06 »
Create rotation/translation matrix:
Code: GLBasic [Select]
// Roll, Pitch, Yaw, Translate
FUNCTION BuildMatrix: ry, rz, rx, x, y, z, M[]
LOCAL sa,sb,sc, ca,cb,cc
LOCAL sacb, cacb
DIM M[16]

//LOCAL a[], B[], C[]
//      NewtonRollMatrix (rx, a[])
//      NewtonPitchMatrix(ry, B[])
//      NewtonMultMatrix(a[], B[], C[])
//      NewtonYawMatrix  (rz, a[])
//      NewtonMultMatrix(a[], C[], M[])
//      M[12]= x
//      M[13]= y
//      M[14]= z

ca       = COS(-ry);
sa       = SIN(-ry);
sb       = COS(rz);
cb       = SIN(rz);
cc       = COS(-rx);
sc       = SIN(-rx);

sacb=sa*cb
cacb=ca*cb

M[0]  =   sb * cc;
M[1]  =  -sb * sc;
M[2]  =  -cb;

M[4]  = -sacb * cc + ca * sc;
M[5]  =  sacb * sc + ca * cc;
M[6]  =  -sa * sb;

M[8]  =  cacb * cc + sa * sc;
M[9]  = -cacb * sc + sa * cc;
M[10] =   ca * sb;

M[12]= x
M[13]= y
M[14]= z
M[15]= 1;
ENDFUNCTION

#### Hemlos

• To boldy go where no pixel has gone before!
• Global Moderator
• Prof. Inline
• Posts: 1634
• Particle Hawk
##### X_MULTMATRIX
« Reply #2 on: 2006-Nov-07 »
interesting, and doesnt gimbal lock..but it rotates like x_rotation still, minus the gimbal..

This method works with 2 axes that are fixed to the world and one to the object.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)