Recommended Posts

Trying to figure this out has really shown me that I dont remember much of my highschool math involving PI, sine, cosine and tangent. Im currently trying to draw a circle in SFMl, and im having trouble figuring out how to do it. Initially I was thinking of having a circle with 32 "sides" or edges, and therefore creating a for loop that loops 32 times. The problem is I dont know how to calculate where the point moves to next. I know the angle of each edge would be 360/32. I know there's probably a simpler way to perhaps use PI * 2 or one of the other functions from math.h. Just been a while since ive done this stuff. Any help to get me along would be greatly appreciated.

Share this post

Link to post

Share on other sites

The unit circle is a great tool to keep in mind, with the idea that any point on a circle of radius 1 centered at the origin is at (cosine theta, sine theta) where theta is the angle of rotation from the positive x axis. It also has the bonus of helping to remember the cos/sin values of major angles like 0, 90, etc.

I draw this every time I'm working out trig-related problems:

0

Share this post

Link to post

Share on other sites

You could loop through each pixel on the screen and calculate the distance between that pixel and the centre of the circle and if that distance is equal to the radius of the circle then draw it! xD Though that'd be stupid, don't actually do that!