Drawing a cylinder

Started by
1 comment, last by tfhain 15 years, 5 months ago
I would like to draw an openfaced (i.e., no ends) cylinder with radius R, with the center of one face at the origin, and the center of the other face at an arbitrary point (x,y,z) (i.e., having length sqrt(x^2+y^2+z^2)). I know how to draw the cyclinder using a GLUquadricObj. What I need help with is with the transformation to get it there. Thanks for any suggestions! tfhain
Advertisement
What you need to do is find the angles (x axis rotation and y axis rotation) from point A to point B and use those rotations (if you can dig up some old trigonometry text books or something, they'll help a lot). The center of it will be (point A + point B) / 2.

If you basically take any 'look at' function, they should be able to provide you with the necessary rotation values. I wrote my own ages ago, and while I would provide you with that code, it's not pretty...
Hmm... doesn't help much, but thanks anyway, mate.

tfhain

This topic is closed to new replies.

Advertisement