Drawing orbit trial for a planet in OpenGL [closed]

If the planet is following a circular orbit, you need to know the center of the circle, the radius, and the axis of rotation. In your case, the axis of rotation is the y-axis. Therefore the points on along orbit can be computed by the trigonometric functions sin and cos Define a center point (float CPT[3]) and a radius (float radius). Use the Line primitive type GL_LINE_LOOP to draw the circular orbit:

for (float angle = 0; i < 2 * PI; angle += 0.01)
    float x = CPT[0] + cos(angle) * radius;
    float y = CPT[1];
    float z = CPT[2] + sin(angle) * radius;
    glVertex3f(x, y, z);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top