PDA

View Full Version : Transformations and Rotations (quaternions)

robERTk
06-04-2002, 12:14 PM
I am having a major brain-block understanding rotations using quaternions.

What I am trying to do is the following:
- I have a cylinder, starting at (0,0,0) and ending at (1,1,0) (basically rotated 45 degrees around z)
- at point (1,1,0) I want to attach a 90 degree elbow (elbow has a radius R), which I want to rotate 'theta' angle around axis that the cylider defines
- when rotated, I want to find out the ending coordinates of an elbow (x1, y1, z1)

So basically I am looking for a psedu-code that will give me ideas how to rotate a point using quaternions.

Thanks

yakuza
06-04-2002, 02:16 PM
Gametutorials has a tutorial on using quaternions, giving real code instead of psuedocode. http://www.opengl.org/discussion_boards/ubb/smile.gif Perhaps that will suit your needs?
http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg3.htm

Jambolo
06-04-2002, 09:25 PM
I don't think quaternions are the right thing to use here. They are great for keeping track of orientation (among other things), but not simple rotation.

So, are you looking for code that spits out numbers? If so, then OpenGL has nothing that will help you.

Do you want to render this scene? Then take a look at glRotate.

Gavin
06-05-2002, 05:59 AM
Have a look at ......
www.cs.cf.ac.uk/user/G.R.Powell (http://www.cs.cf.ac.uk/user/G.R.Powell)
->
C Code
->
quaternian

robERTk
06-05-2002, 06:24 AM
Originally posted by Jambolo:
I don't think quaternions are the right thing to use here. They are great for keeping track of orientation (among other things), but not simple rotation.

So, are you looking for code that spits out numbers? If so, then OpenGL has nothing that will help you.

Do you want to render this scene? Then take a look at glRotate.

Basically what I am trying to do is draw bended pipe in a 3D space (for straight sections I am using gluCylinder, and for bends I am drawing a part of torus also using OpenGl).
So what I am trying to do is write my positioning algorithm that calculates my starting position x,y,z, and then I rotate and transform section of a pipe into that position. That's why I thought quaternions would be the most straight forward for my positioning algorithm.