Drawing a cylinder along an arbitrary axis with gluCylinder

  • Follow


Hey all,

I want to draw a cylinder (using glyCylinder) so that it spans two points p1 
and p2, and am having trouble with it somewhere. The gluCylinder method draws 
the geometry so that it starts at (0,0,0) and goes to (0,0,h) where h is the 
height of the cylinder in this case. So, I have to transform those coordinates 
into the ones I want by using the model-view matrix.

So, first off, I can translate the coordinate system so that I am going from 0 
to pd = p2 - p1. That's easy enough.

However, rotating the system is more complicated. I know that I can get the 
angles that describe the vector pd by doing atan2( pd.y, pd.x) and things like 
that. However, how do I compose those angles into the quaterian-style 
rotations that I need so that (0, 0, h) transforms to the vector pd?

Thanks.

Dave
0
Reply Dave 1/14/2007 6:21:56 AM


0 Replies
355 Views

(page loaded in 0.024 seconds)

Similiar Articles:






7/23/2012 8:46:41 AM


Reply: