Advertisement

More math than anything...

Started by September 09, 2000 07:24 PM
5 comments, last by Pathos 24 years, 2 months ago
I was wondering what formula I can use to find arbitraty points on a circle. I am hoping to have a keyboard controlled light move around a circle, but the only circle formulae I know are for perimeter and area. Any help would be appreciated.
Any point on a circle can be represented in (x,y) as (RcosA, RsinA) where A is the angle and R is the radius of the circle.
Hope that helps...
S.
Advertisement
use the maths functions sin() and cos()
they take an argument in radians (there are 2*PI radians in a circle) and sin will return the x, cos will return the y position of an angle on the x plane made with a circle with a radious of one unit
e.g.

for(int angle=0;angle<(2*PI);angle+=0.1f)
{
x=sin(angle);
y=cos(angle);
draw(x,y);
}

.. i hope u get the idea
equation of a circle:

r^2 = (x - x1)^2 + (y - y1)^2

where (x1, y1) is the centre of ur circle

Quantum, i think u've got ur x and y around the wrong way - y=sin(angle);
x=cos(angle);

Edited by - kwall on September 9, 2000 10:22:43 PM
oops sorry
im still fairly new to this stuff
no wait.. according to the OpenGL Superbible x=sin(a), y=cos(a)
Advertisement
actually you''re both right, swapping x=cos(A), y=sin(A) for
x=sin(A), y=cos(A) just rotates the circle 90 degrees in the z-axis

you can see this if you substitute A=0:
1st case: x=1, y=0
2nd case: x=0, y=1

so you can use whichever you want

alistair

This topic is closed to new replies.

Advertisement