I have three points, lets say C as a center point while P1 and P2 are two other points. I have computed angle between C and P1 know as angle1 and c p2 called angle 2. here is the code I use to compute it
angle1 = atan2(p1.y - c.y, p1.x - c.x);
angle2 = atan2(p2.y - c.y, p2.x - c.x);
after that I changed them into degrees by using this.
if (angle1 >= 0)
angle1 = angle1 * (180 / PI);
else
angle1 = (angle1 + 2 * PI) * (180 / PI);
if(angle2 >= 0)
angle2 = angle2 * (180 / PI);
else
angle2 = (angle2 + 2 * PI) * (180 / PI);
Then I use this openCv method to compute draw the arc, some time arc is perfect between two point while some times it fills all the circle other than the two points which I post image here.
radius = sqrt(pow(c.x - p1.x, 2.0) + pow(c.y - p1.y, 2.0));
ellipse(outPutMat, c, cv::Size(radius, radius), 0, angle1, angle2, Scalar(0, 0, 0), -1, 8, 0);
red points are the points, while black is ellipse filled color. For 1st image agngle1 = 42.1376 while angle2 = 338.962 For 2nd image agngle1 = 152.447 while angle2 = 223.363
2nd image produced right results but first is wrong. I just want to fill area between points.