Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to know how to get a specific point on the circumference of a circle, given an angle. The diameter of the circle is 1, and the center point of the circle is { X: 0.5, Y: 0.5 }.

share|improve this question

1 Answer 1

up vote 17 down vote accepted

You can work this out using basic trigonometry. http://www.freehomeworkmathhelp.com/Trigonometry/Trigonometry_Introduction/trigonometry.html

Tan(angle) = Opposite / Adjacent
Sin(angle) = Opposite / Hypotenuse
Cos(angle) = Adjacent / Hypotenuse

I always remember the above as

The Old Arab
Sat On His
Camel And Howled

The above means if we have the angle and one length of a right-angled triangle we can work out the lengths of the other sides. Luckly your problem can be thought of as calculating the length of triangle sides:

Circle Triangle Image

Above, r is the hypotenuse, x is the adjacent and y is the opposite.

So for x:

Cos(a) = x / r
Cos(a) * r = x
x = Cos(a) * r

And for y:

Sin(a) = y / r
Sin(a) * r = y
y = Sin(a) * r

This is assuming a circle at (0, 0), so we just add on the circle's center.

radius = 1;
CenterX = 0.5;
CenterY = 0.5;

x = Cos(angle) * radius + CenterX;
Y = Sin(angle) * radius + CenterY;

Note: The C# Math functions use angles in radians, so if you have degrees convert them first:

radians = degrees * Math.PI / 180
share|improve this answer
1  
Keep in mind that the angle should be in radians. –  bummzack Oct 10 '11 at 11:21
    
Depends on the math library, but good point, XNA/.Net uses radians. –  George Duckett Oct 10 '11 at 11:27
    
Why the old Arab was to howl? Here we are not all English speakers so a conceptual memonic rule is far better than a mnemonic sentence –  FxIII Oct 10 '11 at 12:38
1  
@FxIII: True, it's not the most popular memonic, however i've always found it easy to remember than SOHCAHTOA as it's unusual. –  George Duckett Oct 10 '11 at 13:01
    
Or you could just look it up, once you are familiar with the concept, the once or twice a year that you need it. –  Tetrad Oct 10 '11 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.