Rotating a 2D line
-
Hi, How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL). Thanx in Advance , Regards, FarPointer
-
Hi, How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL). Thanx in Advance , Regards, FarPointer
OpenGL is very special, I think u should post ur Q on a OpenGL forum. good luck.
A nice tool for optimizing your Microsoft html-help contents. Includeh10
-
OpenGL is very special, I think u should post ur Q on a OpenGL forum. good luck.
A nice tool for optimizing your Microsoft html-help contents. Includeh10
Hi, I couldnt Find OpenGL Forum in CodeProject you got a better idea were i can . Regards, FarPointer
-
Hi, How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL). Thanx in Advance , Regards, FarPointer
This really isn't OpenGL specific but is just trigonometry. Decide on how many points you want to use in your rotation. For each point on the line you want to rotate it 360 degress around the z-axis. Decide what your delta theta is. For each point you will loop from 0 to the number of points and create a vertex as follows: glBegin( GL_QUADS ); for each point on line for each delta theta x1 = x * cos(theta); y1 = y * sin(theta); z1 = z1; glVertex3f( x1, y1, z1 ); glEnd(); I hope this helps you get started. Deus caritas est
-
Hi, How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL). Thanx in Advance , Regards, FarPointer
FarPointer wrote:
How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL).
actually, you are making it too difficult. OpenGL relative to order of operations. So assuming you want to rotate a line 30 degrees you go from this:
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(50.0f, 50.0f, 50.0f);
glEnd();to this:
glPushMatrix();
glRotatef(30.0,0.0f,1.0f,0.0f);
// rotate 30 degrees on Y-Axis
// then draw line
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(50.0f, 50.0f, 50.0f);
glEnd();
glPopMatrix();although the glPushMatrix() and glPopMatrix() are not required operations if you draw another primitive it is relative to the last rotate, push and pop operations restores the rotation matrix to prior to the rotate so that another primitive is relative to the original scene-view not the last rotation. see this tutorial over at Nehe: Nehe OpenGL tutorial on Rotations[^] _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
Hi, How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL). Thanx in Advance , Regards, FarPointer
Might be a little late for this reply, but... If you want to display a cone in wire or solid form, include glaux.h, and call either auxWireCone(radius, height) or auxSolidCone(radius, height). If you want to construct a cone on your own, you'll need the mathematical formula for a cone and some code to draw the triangles that form the cone (GL_TRIANGLE_STRIP), and the base of the cone (if desired, also GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN). In either case, you can call glRotate before drawing the cone, to get the desired orientation of the cone. delete this; * poof! *