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);
if (angle1 >= 0)
angle1 = angle1 * (180 / PI);
angle1 = (angle1 + 2 * PI) * (180 / PI);
if(angle2 >= 0)
angle2 = angle2 * (180 / PI);
angle2 = (angle2 + 2 * PI) * (180 / PI);
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);
After short check - it seems that OpenCV function calculates middle angle as
ma = (angle1 + angle2) / 2 and draws arc through this point.
Both (-45,45) and (45,-45) give the same 90-degrees arc through zero, both (315,45) and (45,315) give the same 270-degrees arc.
To get desired result, you have not map negative angle to positive value (
(angle1 + 2 * PI)), and use
-21 values in the first case.