#### Archived

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

# Problem with rotation function on the glbook

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

## Recommended Posts

Ok, I am writting a MD2 loading and displaying class bassed on the OpenGL programming book, everything works fine, but MD2 models are huge and use an "UP" vector of 0,0,1, which is not the one OpenGL uses (0,1,0), so I am scaling and rotating at load time so I dont have to do it per frame, scaling works great, but then rotation does not. I am doing it on a per Point basis. I am trying to use the rotation function on Page 77:
void CVector3::Rotate(float rx,float ry, float rz)
{
x=x*(cos(rz)*cos(ry)) +
y*((cos(rz)*sin(ry)*sin(rx)) - (sin(rz)*cos(rx))) +
z*((cos(rz)*sin(ry)*sin(rx)) - (sin(rz)*cos(rx)));

y=x*(sin(rz)*cos(ry)) +
y*((sin(rz)*sin(ry)*sin(rx)) - (cos(rz)*cos(rx))) +
z*((sin(rz)*sin(ry)*cos(rx)) - (cos(rz)*sin(rx)));

z= -x*sin(rz)+z*(cos(ry)*sin(rx));
};

Where rx,ry,rz are rotation angles for each coordinate, I think that if I have 0,1,0 and I use rotate(90,0,0), I should end with 0,0,1, but this is not the case, I get instead 0,0.45,0. So, any idea what is wrong? am I getting the right result, but not undertsnading what the function really does? or am I missing some parentesis? Thanks

##### Share on other sites
It just hit me, I might have to convert the cos/sin results from radians to degrees newbie mistake, I guess I am a bit rusty.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 37
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631413
• Total Posts
2999946
×