PDA

View Full Version : Coordinate system matrix



Pete
08-12-2002, 08:52 PM
Hi all,

How could I to obtain a matrix of my own coordinate system? I know all three directions and origin point.

Thanks

Pete

rixed
08-13-2002, 01:02 AM
I dont really understand what you want.
Lets assume that you have vertices defined in what you called your own coordinate system. If vectors (X, Y, Z) are your 3 directions, and T your origine point, then the matrix that transform your vertices to the upper coordinate system is :

GLfloat matrix[16] = {
Xx, Xy, Xz, 0
Yx, Yy, Yz, 0
Zx, Zy, Zz, 0
Tx, Ty, Tz, 1
}

If you want to inverse this (if what you call your own coordinate system is your camera for example, and that you have the dirs and position of your camera in the absolute coordinate system and look for the dirs and pos of the absolute coord system in your camera coordinate system), apply this :

transpose(GLfloat (*matrix)[]) {
GLfloat x,y,z;
x=coord[12]*coord[0]+coord[13]*coord[1]+coord[14]*coord[2];
y=coord[12]*coord[4]+coord[13]*coord[5]+coord[14]*coord[6];
z=coord[12]*coord[8]+coord[13]*coord[9]+coord[14]*coord[10];
coord[12]=-x;
coord[13]=-y;
coord[14]=-z;
x=coord[1];coord[1]=coord[4];coord[4]=x;
x=coord[2];coord[2]=coord[8];coord[8]=x;
x=coord[6];coord[6]=coord[9];coord[9]=x;
}

which transpose the rotation part of the matrix (assuming the matrix is orthogonal), and calculate the translation from center of your coordinate system to absolute coord system in the matrix coordinate system.

May the force be with you.


[This message has been edited by rixed (edited 08-13-2002).]

Pete
08-13-2002, 04:10 AM
Thank you for your answer Rixed,

I want to use "own coordinate system" to define sketch plane.

Pete

rixed
08-13-2002, 07:01 AM
I still do not understand what you want to do nor what you call a sketch plane, but anyway, if that helps... :-)