Question: Using OpenGL develop a C code that a) draws a point that moves clockwise slowly along a circle with a center at (0,0). You may

Using OpenGL develop a C code that a) draws a point that moves clockwise slowly along a circle with a center at (0,0). You may want to draw a circle first, and a point that moves on the circle with a different color.

----Please take Note that this code does not work----

#include

#include

#include

#include

void DrawArc(float cx, float cy, float r, float start_angle, float arc_angle, int num_segments)

{

float theta = arc_angle / float(num_segments - 1);//theta is now calculated from the arc angle instead, the - 1 bit comes from the fact that the arc is open

float tangetial_factor = tanf(theta);

float radial_factor = cosf(theta);

float x = r * cosf(start_angle);//we now start at the start angle

float y = r * sinf(start_angle);

glBegin(GL_LINE_STRIP);//since the arc is not a closed curve, this is a strip now

for (int ii = 0; ii < num_segments; ii++)

{

glVertex2f(x + cx, y + cy);

float tx = -y;

float ty = x;

x += tx * tangetial_factor;

y += ty * tangetial_factor;

x *= radial_factor;

y *= radial_factor;

}

glEnd();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!