This topic is now archived and is closed to further replies.

3D Rotations

This topic is 6576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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;

yr = y*cos(xa) - z*sin(xa); // Rotate about X
zr = y*sin(xa) + z*cos(xa);

xr = x*cos(ya) + z*sin(ya); // Rotate about Y
zr = x*-(sin(ya)) + z*cos(ya);

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;

Share this post

Link to post
Share on other sites
Why don't you simply use matrices. They are way more comfortable and offer a lot more functions than simple functions.

Alexander Stockinger

Share this post

Link to post
Share on other sites