I have been trying to draw an elipse with opengl…any suggestions? I can figure out spheres and make them translate,scale and rotate but I can’t seem to get elipses…any help would be nice. txs
Well, if you know how to scale your spheres do this:
-
Define the elipse radius on each axis
(x, y, z) -
glPushMatrix();
glScaled(radiusX, radiusY, radiusZ)
>>Render sphere with size 1.0<<
glPopMatrix();
This will plot points around the perimeter of an ellipse, given an angle, semi-minor & semi-major axis. I was coding a Solar System simulator & needed it.
#define PI 3.14159265358979323846
#define SQ(x) (xx)
#define D2R(a) (a(PI / 180))
GLfloat a, r, x, y, min = 5, maj = 10;
for (a=0; a<360; a++)
{
r = sqrt ((SQ(maj)*SQ(min)) / ((SQ(maj) * SQ(sin(D2R(a)))) + (SQ(min) * SQ(cos(D2R(a))))));
x = r * cos(D2R(a));
y = r * sin(D2R(a));
}
Sean