Jump to content
  • Advertisement

Archived

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

Kimeli

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.

If you intended to correct an error in the post then please contact us.

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


Link to post
Share on other sites
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!