vector rotation

I tried this post in the math/algo forum but I think its down.

how do I calculate these three vectors:

x,y,z

1,0,0
0,1,0
0,0,1

to align with a rotated modelmatrix to allow for relative movement?

This might help with understanding of question

I can look around with the mouse:

void LookAround(float x,float y)//x,y from mouse
{
GLfloat MMatrix[16];

glGetFloatv(GL_MODELVIEW_MATRIX,MMatrix);
glLoadIdentity();
glRotatef(sqrt(xx+yy)*magicnumber,-y,x,0.0);
glMultMatrixf(MMatrix);
}

multiple LookAround() Functions leads to rotations in all directions not just x and y

Now I want a funtion that makes me move relative to the new rotation:

void MoveAround(float x,float y,float z)//get a velocity vector eg: (0,0,1)=1 forward
{
GLfloat MMatrix[16];
float rotatedX,rotatedY,RotatedZ;

glGetFloatv(GL_MODELVIEW_MATRIX,MMatrix);
//switch(explanation){
//case abstract_math:
//vector matrix math that i don’t know, likely full of sin()'s and cos()'s
//break;
//case simpler_fuctions:
//translation manipulation with opengl fuctions such as glRotate() and glMultMatrixf()

glTranslate(rotatedX,rotatedY,RotatedZ);
}

I will probably need those vectors for collision response and rotational bounce or something anyway.

Math & algorithms is up, I’ll move your thread there.

– Tom

cheers

I use:
void MoveAround(float x,float y,float z)
{
GLfloat MMatrix[16];

glGetFloatv(GL_MODELVIEW_MATRIX,MMatrix);
glLoadIdentity();
glTranslatef(x,y,z);
glMultMatrixf(ModelViewMatrix);
}

should I do collision detection from the modelmatrix where collidable things have their own rotation and translation or should I have a geometry thing or a combo?
should I have object attributes such as location and rotation and then gltranslate()/glrotate() or should I get those attributes from the matrix

if you “just want to move arround”:
why don’t you write your own camera-class or something to keep track of the position you are, the look-at and the up-vector?
you can calculate everything…

I have my own cam class.

it has 3 vectors (Position, Look-At and Up)
and a SetCam-function which calls gluLookAt(pos.x.y.z,look.x.y.z,up.x.y.z)

to move in the direction you’re “looking” calculate:

I assume:
p - position, l - lookat, both vectors
void pseudocode_mode(float distance)
{
vector d;
float distance; // the distance, how far you’ll move

d = l - p;
d.Normalize()

d = d*distance;

p = p+d;
l = l+d;

}

normalisation of vector d:

float n = d.Length();

d.x = d.x / n;
d.y = d.y / n;
d.z = d.z / n;

length m of a vector:

float m = sqrt ( d.xd.x + d.yd.y + d.z*d.z );

hope this helps.

Greetings
Bastian

The rotation matrices contain a rotated coordinate system in the columns if i remember correctly. First column represents current x-Axis in respect to the identity coordinaten system and so on…