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

后端 未结 4 1361
悲&欢浪女
悲&欢浪女 2020-11-22 15:02

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:

4条回答
  •  一生所求
    2020-11-22 15:21

    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.

提交回复
热议问题