在圆的周长上寻找点 [英] Finding Points On Perimeter Of a Circle

查看:119
本文介绍了在圆的周长上寻找点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从圆心画一条线.为此,我首先选择图像的中心作为圆心,然后绘制一个半径已知的圆.之后,使用圆的参数方程式,我只是通过将角度增加6度来计算周长上的x和y.

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) 

我正在使用OpenCV进行所有这些操作,其中像素坐标从左上角开始.所以我的问题是,对于360度循环,算法需要绘制60条线,但是当角度达到120度时,它会完成一个循环,因此我注意到每条线可分开15度,而不是6度. 下面是我的照片是120度之后的.

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.

推荐答案

sincos期望角度为弧度.如果以度为单位提供角度,则实际差异将为6 == 6 - 2 * Pi,大约为-16.22°.

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) 

这篇关于在圆的周长上寻找点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆