#### Archived

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

# gluCylinder/matrix rotation problem

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

## Recommended Posts

Hi. I have a cylinder, which have basepoint, toppoint and radius. I get vector from basepoint to toppoint which tell me how cylinder is oriented in the world. Now I have a problem because gluCylinder draws cylinder from (0,0,0) to (0, 0, height) (on z-axis). Matrix should be translated/rotated before drawing cylinder. Translation is simple because I use basepoint as reference point. But rotation -> argh. Question: How do I create matrix which makes needed rotation? I guess all needed information is in direction vector. I have tried to rotate axis one by one by asking from vector ''how much is angle to axis-x/y/z?'', but result is not correct. Thanks. PS. Should this belong to ''OpenGL''-section. Guess not.

##### Share on other sites
Well the rotation matrix is just three vectors that describe the direction of each axis. So You probably want the z-axis to point the same direction as your orientation vector... and then to get the x axis take the cross product of the z-axis vector with a vector that points straight up.

Taking the cross product of this vector with the z-axis vector will give you the y-axis vector...

Hope this helps

[edited by - nexius on August 13, 2003 7:05:03 PM]

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
631775
• Total Posts
3002279
×