nrbrasiliense

10-22-2001, 11:08 AM

Hi! I have tried to draw cylinders using the function gluCylinder of "GL Utility library". It's pretty easy but I have gotten some problems because it draws a cylinder directly on the Z-axis, so, I must make some rotation before draw a cylinder in any axis.

I tryed to make 2 consecutive rotations, first in Y-Axis and then in the X-Axis, if I had the right angles, it should be enough to draw in any direction with the "gluCylinder" function.

The problem is that it doesn´t work when a have a cylinder, for instance, from the point P1( 0, 0, 0 ) to the point P2( 100, 100, 100 ), I have not been able to calculate the right angle to make the right rotation before call gluCylinder.

I did that : angleY = arctan[(p2.X - p1.X) / (p2.Z - p1.Z)];

angleX = arctan[(p2.Y - p1.Y) / (p2.Z - p1.Z)];

Seems that the angleY is right, but the angleX is not.

If somebody could help me, showing how to calculate these angles, would be very nice.

Thanks a lot.

[ ]'s

Rogerio Brasiliense

Florianópolis - Brazil

I tryed to make 2 consecutive rotations, first in Y-Axis and then in the X-Axis, if I had the right angles, it should be enough to draw in any direction with the "gluCylinder" function.

The problem is that it doesn´t work when a have a cylinder, for instance, from the point P1( 0, 0, 0 ) to the point P2( 100, 100, 100 ), I have not been able to calculate the right angle to make the right rotation before call gluCylinder.

I did that : angleY = arctan[(p2.X - p1.X) / (p2.Z - p1.Z)];

angleX = arctan[(p2.Y - p1.Y) / (p2.Z - p1.Z)];

Seems that the angleY is right, but the angleX is not.

If somebody could help me, showing how to calculate these angles, would be very nice.

Thanks a lot.

[ ]'s

Rogerio Brasiliense

Florianópolis - Brazil