3D Rotations

Started by
3 comments, last by acw83 24 years, 4 months ago
you are calculating yr and zr for rotation around the x axis, then totally replacing zr in your calculation of the y axis rotation...etc. You need to make temp variables so you don't lose what you just calculated in the next step.

I none to good at explaining stuff like this, so it probably doesn't make any sense. (or I may totally be off)

I'm just guessing from a quick glance at your code.

Hope I at least helped a bit.

William Reiach - Human Extrodinaire

Marlene and Me


Advertisement
Z axis is the last calculation that you are making, that is why it is correct. That is how I came to the conclusion in the post above.
William Reiach - Human Extrodinaire

Marlene and Me


Okay, what'll happen is that the Vertex will move, but in a funky-unrotate-like matter...
Could someone please explain why this doesn't work out okay when rotating about the x or y axis. The z axis works fine...

void PrepVertex(CVertex* v, float xra, float yra, float zra)
{

float x = v->x;
float y = v->y;
float z = v->z;

float xr = v->x;
float yr = v->y;
float zr = v->z;

float xa = xra*3.14159/180;
float ya = yra*3.14159/180;
float za = zra*3.14159/180;


if(xra!=0){
yr = y*cos(xa) - z*sin(xa); // Rotate about X
zr = y*sin(xa) + z*cos(xa);
}

if(yra!=0){
xr = x*cos(ya) + z*sin(ya); // Rotate about Y
zr = x*-(sin(ya)) + z*cos(ya);
}

if(zra!=0){
xr = x*cos(za) - y*sin(za); // Rotate about Z
yr = x*sin(za) + y*cos(za);
}

v->xr = xr;
v->yr = yr;
v->zr = zr;
}

Why don't you simply use matrices. They are way more comfortable and offer a lot more functions than simple functions.

------------------
Alexander Stockinger
Programmer

Alexander Stockinger
Programmer

This topic is closed to new replies.

Advertisement