Hello, I need to rotate an object 90 degrees around the X-axis.
Since I am very new to OpenGL I am still practicing, and therefor i don’t want to use the glRotate function in this program I am doing at the moment.
So I want to specify the Rotation matrix myself and then add it using glMultMatrix.
I did the following:
//The rotation matrix OGL style:
//In the display func:
drawhouse();//this is the object i am rotating
There is some rotation going on, but it is wrongly rotated. I cannot understand what I am doing wrong.
I hope somebody can help me out here, thank you very much.
Many regards the Black Adder
Math functions sin and cos need radians, you used degrees.
Now I am doing the following:
#define PI 22/7
but alas, it still gives me wrong image…
Also if i rotate about the z-axis:
it gives me a wrong rotation…
Integer division 22/7 gives 3.
#define PI (22.0/7.0)
#define M_PI 3.14159265358979323846264338327950288419716939937510
double theta = 90.0 * M_PI / 180.0;
Remember that OpenGL matrices are column-major.
Your matrix built from R
1 cos(theta) -sin(theta) 0
0 sin(theta) cos(theta) 0
0 0 0 1
0 0 0 missing?
But you probably wanted
1 0 0 0
0 cos(theta) sin(theta) 0
0 -sin(theta) cos(theta) 0
0 0 0 1
Be more careful.
yes of course hehe
Shame on me…It was the integer divide that made the inacurracy.
Thank you very much