How to find midpoint of an arc in MATLAB

577 Views Asked by At

It is necessary for me to find midpoint of some arc in MATLAB. For simplicity let this arc is a part of circle. Also, we know the radius, center and starting point and ending point of the arc. I used $atan2(y,x)$ to get the angle for each line constructed by start and end points. Then find $t_{mid}=\frac{t_1+t_2}{2}$ and use $x_{mid}=r*cos(t_{mid})+xc,~y_{mid}=r*sin(t_{mid})+yc.$ But the problem is that $atan2$ gives the angle between $-\pi$ and $\pi$. Then for example for third quarter if $t_1=\pi$ and $t_2=-\pi/2$, $t_{mid}=\pi/4$ and it is not true. If I add $2\pi$ to the angles lower than zero, then I have the same problem for fourth quarter, for example $t_1=\frac{3\pi}{2},t_2=0$, the mid angle is $\frac{3\pi}{4}$!!. How can I solve this problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Compute the coordinates of the midpoint $I$ of the endpoints (which is outside of the arc, of course): its polar angle is the same as the polar angle of the point you are looking for. The rest is easy.