Difference in angles for 4 cases
Attached figure shows small part of bigger problem.
The circle of radius 5 is divided into 4 segments. Midpoints of these segments are marked (e.g. O). From the midpoint of segments, the end points of segment of interest is connected (e.g OA, OB). $\theta_{A}$ and $\theta_{B}$ are the angles made by the vectors/lines OA and OB respectively from positive x-axis (horizontal line) drawn from O.
E.g.: In figure 1, angle made by OA with horizontal at O is 67.5 degree and angle made by OA with horizontal at O is 112.5 degree.
Convention: Measurement of angle is positive in counter clockwise (CCW) with respect to horizontal line
I have used three methods to find $\left(\theta_{B} - \theta_{A}\right)$
The functions atan, atan2 from EXCEL or MATLAB and acos from angle between two vectors $\left[\textbf{OA} \cdot \textbf{OB}=\|\textbf{OA}\|\|\textbf{OB}\| cos(\theta)\right]$ have been used to find the $\left(\theta_{B} - \theta_{A}\right)$
Using these, for the 4 cases shown the data are given below
\begin{array}{|c|c|c|c|c|c|c|c|} \hline atan & atan & atan & atan2 & atan2 & atan2 & acos & Visual \\ \hline \theta_{B} & \theta_{A} & (\theta_{B} - \theta_{A}) & \theta_{B} & \theta_{A} & (\theta_{B} - \theta_{A}) & (\theta_{B} - \theta_{A}) & (\theta_{B} - \theta_{A}) \\ \hline -67.5 & 67.5 & -135 & 112.5 & 67.5 & 45 & 45 & 45 \\ \hline 67.5 & 22.5 & 45 & 67.5 & -157.5 & 225 & 135 & -135 \\ \hline 22.5 & -22.5 & 45 & -157.5 & 157.5 & -315 & 45 & 45 \\ \hline -22.5 & -67.5 & 45 & 157.5 & 112.5 & 45 & 45 & 45 \\ \hline \end{array}
Results from atan and atan2 doesn't agree with Visual in two cases while acos agrees in magnitude except for the sign. I'm looking for any formula which when used should yield results matching with Visual.
I appreciate your help. Thank you.
For MS EXCEL: ATAN2(x_num, y_num)
Case 1: Coordinates of O, A and B are O$(\frac{5}{\sqrt2}, \frac{-5}{\sqrt2})$, A(5, 0), B(0, 5)
OA(1.4645, 3.5355), OB(-3.5355, 8.5355)
For OA: atan2(1.4645, 3.5355)
For OB: atan2(-3.5355, 8.5355)
p.s.: Can someone make the image visible in line with text instead of hyperlink to image