View Full Version : Elipses

10-24-2000, 06:22 PM
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

10-24-2000, 10:03 PM
Well, if you know how to scale your spheres do this:

1) Define the elipse radius on each axis
(x, y, z)

2) glPushMatrix();
glScaled(radiusX, radiusY, radiusZ)
>>Render sphere with size 1.0<<

10-29-2000, 02:33 AM
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) (x*x)
#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));