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

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

    Here is my implementation in C#:

        public static PointF PointOnCircle(float radius, float angleInDegrees, PointF origin)
        {
            // Convert from degrees to radians via multiplication by PI/180        
            float x = (float)(radius * Math.Cos(angleInDegrees * Math.PI / 180F)) + origin.X;
            float y = (float)(radius * Math.Sin(angleInDegrees * Math.PI / 180F)) + origin.Y;
    
            return new PointF(x, y);
        }
    

提交回复
热议问题