Hi all,
I have to make a graphics project about drawing a circle like:
1/Draw the circle on the screen with yellow pen color and dark blue background. (Note: yellow
color: 0xFFFF00, dark blue color: 0x191970).
2/ Rotate the circle counterclockwise around the center I with the speed 10 degree per second, the
rotating will stop when user press ‘q’.
but I just did the first requirement.
Here is my work, can you help me with the second requirement!

Recommended Answers

All 2 Replies

Here is my work, can you help me with the second requirement!

Sure we can help you, but that's such a vague question ...
Where are you having problems with ?

Hmmm seems like you need to bust out the math book. I honestly dont remember the math functions in CMath, but you should probably look it up. I also don't know how the library you are using supports key entry for stopping, so I'll just say its called GetKey() and returns a character. Also I don't know anything about your circle class, but I will assume it accepts 2 coordinates and a radius.

double fX = 0;
double fY = 0;
double fAngle = 0;  //in radians
const int ciRadius = 10;
const double cfPi = 3.14159;
const int ciAngularVelocity = 10;  //in degrees
const int ciAmplitude = 100;
while (GetKey() != 'q')
{
    fX = SIN(fAngle) * ciAmplitude;
    fY = COS(fAngle) * ciAmplitude;
    DrawCircle(iX, iY, ciRadius)
    sleep(1000); //pause for a second
    fAngle += (ciAngularVelocity * (cfPi / 180.0f));
}

Something like that should do the trick. Probably not the exact code you need for your specific application, but it should give you a damn good idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.