View Full Version : rotation in 3dimensional space
03-14-2009, 12:56 AM
i was readin about rotation from book by Rogers...
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
thanks in advance.
03-14-2009, 09:56 AM
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
CHANGE the values with float numbers 1.0 0.0 3.0 ...etc
03-14-2009, 10:03 AM
that vectorials directions to draw a big square; in the floor.
glvertex3f(256.00, -1.00, -1.00);
glvertex3f(1.00, -1.00, -1.00);
glvertex3f(1.00, -1.00, 258.00);
glvertex3f(256.00, -1.00, 258.00);
03-15-2009, 11:32 PM
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...
03-16-2009, 07:15 AM
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:
setupCameraProjection(); // call glFrustum o gluPerspective or some custom camera function
setupCameraPosition(); // call glTranslate or glRotate or glLookAt to position the camera
//we are still in model view mode.
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.
04-29-2009, 04:00 AM
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 !
04-29-2009, 05:58 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.