Finding Points On Perimeter Of a Circle

六月ゝ 毕业季﹏ 提交于 2019-11-28 11:25:59

问题


I need to draw line from the centre of a circle. For this I first chose centre of the image as a circle centre and draw a circle with known radius. After that using parametric equation of the circle I just calculated the x and y on perimeter by incrementing angle by 6 degree.

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

I am using OpenCV to do all these, where pixel co-ordinate start from upper left corner. So my problem is for 360 degree cycle the algorithm need to be draw 60 lines but when the angle reaches 120 degree it completes one cycle and I noticed that each line is separable about 15 degree instead of 6 degree. Below is my image is after 120 degree.


回答1:


sin and cos expect the angle to be in radians. If you provide the angle in degrees, the actual difference will be 6 == 6 - 2 * Pi which is about -16.22°.

So just calculate the radians from degrees:

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


来源:https://stackoverflow.com/questions/14598954/finding-points-on-perimeter-of-a-circle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!