Finding points around the perimeter of a circle

I need to draw a line from the center of the circle. To do this, I first selected the center of the image as the center of the circle and draw a circle with a known radius. After that, using the parametric equation of the circle, I simply calculated the x and y around the perimeter, increasing the angle by 6 degrees.

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

      

I am using OpenCV to do all this where the pixel coordinate starts at the top left corner. So my problem is 360 degree loop, the algorithm should be drawn with 60 lines, but when the angle reaches 120 degrees it completes one loop and I noticed that each line is split 15 degrees instead of 6 degrees. Below is my image after 120 degrees.

Image after 120 degree

+1


source to share


1 answer


sin

and cos

expect the angle to be in radians. If you enter the angle in degrees, the actual difference 6 == 6 - 2 * Pi

is -16.22 °.

So, just calculate radians from degrees:



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

      

+5


source







All Articles