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

后端 未结 4 1318
悲&欢浪女
悲&欢浪女 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:33

    Who needs trig when you have complex numbers:

    #include 
    #include 
    
    #define PI      3.14159265358979323846
    
    typedef complex double Point;
    
    Point point_on_circle ( double radius, double angle_in_degrees, Point centre )
    {
        return centre + radius * cexp ( PI * I * ( angle_in_degrees  / 180.0 ) );
    }
    

提交回复
热议问题