Question

so I have written a class which draws me a Circle. I obviously know the radius and the center coordinates of the circle. Let's say I want to draw a Point with a distance to the center equal to the half of the radius (r*0.5) and with an angle of 59 degrees. How can I draw the Point at the correct x and y coordinates?

I coded this in Android, but I think the programming language isn't relevant for this problem, it's just something mathematical.

I appreciate your help.

Was it helpful?

Solution

x = r * cos(A) + x0;
y = r * sin(A) + y0;

where (x0, y0) is the centre of your circle, r is the radius and A is the angle.

So:

x = (r * .5) * cos(59) + x0;
y = (r * .5) * sin(59) + y0;

OTHER TIPS

In general, if you have a line segment of length R and angle theta counterclockwise up from a horizontal axis, then its horizontal component (length of its "shadow" on a horizontal axis) is R*cos(theta), and the vertical component is R*sin(theta).

BUT!

The angle must be measured in radians. The conversion is easy: 180 degrees = 2*pi radians. EDIT: Unless the sin and cos functions take angles in degrees as arguments. Check the language specs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top