Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

math - Finding Points On Perimeter Of a Circle

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.

Image after 120 degree

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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) 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...