Started by May 03 2000 11:19 AM

,
6 replies to this topic

Posted 03 May 2000 - 11:19 AM

Is there a way to draw a cylinder by telling it the coordinates of where to start drawing and where to stop, instead of having to draw it, then rotate? Thanks!

Posted 03 May 2000 - 11:32 AM

i''m sorry, but.. WHAT??

--

Float like a butterfly, bite like a crocodile.

--

Float like a butterfly, bite like a crocodile.

Posted 03 May 2000 - 11:47 AM

check out the primitives in glut

Posted 03 May 2000 - 02:32 PM

I''ll eloborate:

Right now, when I use Nehe''s quadratic tutorial to draw cylinders, I have to glTranslatef to somewhere, then draw it. It''s always straight (horizontal) though, so to get it diagonal, I have to rotate it after. I want a way to just say: start drawing at xyz, then finish drawing at xyz. So I can tell it where to draw both ends....

And what''s this about primitives in glut? Thanks!

Right now, when I use Nehe''s quadratic tutorial to draw cylinders, I have to glTranslatef to somewhere, then draw it. It''s always straight (horizontal) though, so to get it diagonal, I have to rotate it after. I want a way to just say: start drawing at xyz, then finish drawing at xyz. So I can tell it where to draw both ends....

And what''s this about primitives in glut? Thanks!

Posted 04 May 2000 - 03:42 AM

You mean you''ve given the center line of the cylinder with the end vertices of this line, A and B, and you''ve given the radius r?

I haven''t read Nehe''s tutorial, I don''t know how Nehe draws a cylinder, but I can tell you how I do:

For the parametric cylinder description with the parameters s and t, firstly you need the direction vector of the cylinder, which is v = B-A. Then you''ll need two vectors perpendicular to each other and perpendicular to v. You could get one of the perpendicular vectors, n1, with n1.x=-v.y, n1.y = v.x and n1.z = 0. For the second one, n2, you need the cross product: n2 = v x n1

Now we''ve got the equation: x(s,t) = A + v*s + r*sin(t)*n1 + r*cos(t)*n2

where x(s,t) is a vertex of the cylinder surface. Let s run from 0 to 1 and t from 0 to 2*PI to get the vertices.

Visit our homepage: www.rarebyte.de.st

GA

I haven''t read Nehe''s tutorial, I don''t know how Nehe draws a cylinder, but I can tell you how I do:

For the parametric cylinder description with the parameters s and t, firstly you need the direction vector of the cylinder, which is v = B-A. Then you''ll need two vectors perpendicular to each other and perpendicular to v. You could get one of the perpendicular vectors, n1, with n1.x=-v.y, n1.y = v.x and n1.z = 0. For the second one, n2, you need the cross product: n2 = v x n1

Now we''ve got the equation: x(s,t) = A + v*s + r*sin(t)*n1 + r*cos(t)*n2

where x(s,t) is a vertex of the cylinder surface. Let s run from 0 to 1 and t from 0 to 2*PI to get the vertices.

Visit our homepage: www.rarebyte.de.st

GA

Posted 04 May 2000 - 03:44 AM

I forgot to say that you must normalize n1 and n2:

n1 = n1/sqrt(n1.x^2+n1.y^2+n1.z^2)

n2 = n2/sqrt(n2.x^2+n2.y^2+n2.z^2)

Visit our homepage: www.rarebyte.de.st

GA

n1 = n1/sqrt(n1.x^2+n1.y^2+n1.z^2)

n2 = n2/sqrt(n2.x^2+n2.y^2+n2.z^2)

Visit our homepage: www.rarebyte.de.st

GA

Posted 04 May 2000 - 07:44 AM

Hmmm, well in Nehe''s tutorial, you just say the length, radius at start, radius at end, and number of faces.... You have to translate to tell it where to draw. So I was wondering if I could tell it coordinates to start and end at instead.... I''ll try to figure out what you said though