Archived

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

Kimeli

gluCylinder/matrix rotation problem

Recommended Posts

Kimeli    139
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 this post


Link to post
Share on other sites
NeXius    124
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]

Share this post


Link to post
Share on other sites