algorithmmathtrigonometry

How do I calculate a point on a circle’s circumference?


How can the following function be implemented in various languages?

Calculate the (x,y) point on the circumference of a circle, given input values of:


Solution

  • The parametric equation for a circle is

    x = cx + r * cos(a)
    y = cy + r * sin(a)
    

    Where r is the radius, cx,cy the origin, and a the angle.

    That's pretty easy to adapt into any language with basic trig functions. Note that most languages will use radians for the angle in trig functions, so rather than cycling through 0..360 degrees, you're cycling through 0..2PI radians.