Finding the coordinates on the edge of a circle

35,677

Solution 1

Here's the mathematical solution which can be applied in any language:

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

x0 and y0 are the coordinates of the centre, r is the radius, and theta is in radians. The angle is measured anticlockwise from the x-axis.

This is the code for C# specifically if your angle is in degrees:

double x = x0 + r * Math.Cos(theta * Math.PI / 180);
double y = y0 + r * Math.Sin(theta * Math.PI / 180);

Solution 2

using Pythagoras Theorem (where x1,y1 is the edge point):

x1 = x + rcos(theta)
y1 = y + r
sin(theta)

in C#, this would look like:

x1 = x + radius * Math.Cos(angle * (Math.PI / 180));
y1 = y + radius * Math.Sin(angle * (Math.PI / 180));

where all variables are doubles and angle is in degrees

Solution 3

For a circle with origin (j, k), radius r, and angle t in radians:

   x(t) = r * cos(t) + j       
   y(t) = r * sin(t) + k
Share:
35,677
Ian Vink
Author by

Ian Vink

https://mvp.microsoft.com/en-us/PublicProfile/5002789?fullName=Ian%20Vink

Updated on May 21, 2021

Comments

  • Ian Vink
    Ian Vink almost 3 years

    Using C#:

    How do I get the (x, y) coordinates on the edge of a circle for any given degree, if I have the center coordinates and the radius?

    There is probably SIN, TAN, COSIN and other grade ten math involved... :)

  • Alastair Pitts
    Alastair Pitts over 14 years
    It funny on these types of questions how almost identical the answers are. Even down to the structure of the answer :P