 # rotation in 3dimensional space

was wondering how can i go about in opengl to implement various variation of roataion in 3d space…

eg - rotation about arbitrary axis
rotation about axis parallel to co-ordinate axis…

wud really appreciate the help

Hi;
for rotate a scene is not so hard. look this exmaple code:

{
glrotate(A,X,Y,Z); //// A=ANGLE; X=AXIS X;Y=AXIS Y; Z=AXIS Z

gltextcoord2f(cood1,coord2);
glvertex3f(X1,Y1,Z1);
gltextcoord2f(coord3,coord4);
glvertex3f(X2,Y2,Z2);
gltextcoord2f(coord5,coord6);
glvertex3f(X3,Y3,Z3);
gltextcoord2f(coord7,coord8);
glvertex3f(X4,Y4,Z4);

glEnd();

}

CHANGE the values with float numbers 1.0 0.0 3.0 …etc

that vectorials directions to draw a big square; in the floor.

{
glrotate(3,0,1,0);

gltextcoord2f(1,1);
glvertex3f(256.00, -1.00, -1.00);
gltextcoord2f(0,1);
glvertex3f(1.00, -1.00, -1.00);
gltextcoord2f(0,0);
glvertex3f(1.00, -1.00, 258.00);
gltextcoord2f(1,0);
glvertex3f(256.00, -1.00, 258.00);

glEnd();

}

luck.

@rodney
thanks man for that…
i jus one more thing to ask…

does glRotate takes care of all those steps which are required to perform rotation about arbitrary axis or do i have do them using translation n multiple rotations…

openGL (fixed pipeline shader) apply various matrix to transform your local polygons in screen point (google for openGL transform pipeline).
Rotation are typically applied to the model view matrix, that is the first matrix applied to your vertices. This matrix is supposed to control the relative position between the object and the camera.
A typical oGL application exec a pseudocode like that:

``````
draw(){
glMatrixMode(GL_PROJECTION);
setupCameraProjection();  // call glFrustum o gluPerspective or some custom camera function
glMatrixMode(GL_MODELVIEW);
setupCameraPosition();  // call glTranslate or glRotate or glLookAt to position the camera

//we are still in model view mode.
glPushMatrix();
setupObjectMatrix();
drawObject();
glPopMatrix();
}
``````

the setupObjectMatrix function can do a lot of stuff… the main porpoise is to compute the transformation matrix and multiply the current (camera) matrix.
Typically this is done with glTranslate glRotate function… but is a rather old method and it’s deprecated in openGL 3.0.
If you are studying a book about rotation matrix I suggest to create your own matrix (or use a 3d math library) and then call glMultMatrix.
The glTranslate/glRotate can perform any arbitrary rotation and translation but you have to call them in the right order.

glMultMatrix is deprecated too… So, how are we supposed to do now without fixed pipeline ? Do the math manually and transform coordinates with custom matrix management ? What’s the point of that ?

Everyone seems to be happy with that (especially on the topic “feedback about OGL 3.1” where people want the old way removed) but I don’t get it. Please let me share you excitment !

You can find ton’s of library that do the maths for you, and sometime math library are even faster then the openGL driver.
Matrix operation (multiplication/translation/rotation) are not hardware accelerated, so there is no reason for them to be in the oGL.
For example if I want to use quaternion to represent orientation? With fixed pipeline I have to convert quaterion into matrix and then use glMultMatrix. Now I can do the maths by my self in the way I like.