I'm developing a model for the collision for two ships.
First, I have the angle that the first ship would be pointing if it was to directly point at the second ship. I'll call the angle between the two ships $\phi$.
Next, I have the measured angle of the first ship's trajectory, which I'll call $\theta$.
The problem is, I check if $\theta$ is greater or less than $45^{\circ}$ from $\phi$. This is fine if the $\phi$ is, say, $180^{\circ}$, and $\theta$ is, say, $170^{\circ}$. This is fine until I hit the problem of $0^{\circ}$. If $\phi$ is $10^{\circ}$, and $\theta$ is $357^{\circ}$, it would still be within that $45^{\circ}$ radius. However, it would not be detected.
What is an easy/simple way to solve it so that if $\phi = 10^{\circ}$ and $ \theta = 357^{\circ}$ would still be detected as within the $45^{\circ}$ radius?
If your angles are within $[0,360]$, the cyclic distance is given by $$d_\text{cyc}(\alpha_1,\alpha_2) = \min (|\alpha_1 - \alpha_2|, 360^\circ - |\alpha_1 - \alpha_2|)$$ You want to check if $d_\text{cyc}(\alpha_1, \alpha) \le 45^\circ$.
Here's a step-by-step evaluation of $d_\text{cyc}(10,357)$:
$$\min(|10-357|,||10-357|-360|) = \min(|-347|,360 - |-347|) = \min(347, 360-347) = \min(347,13) = 13$$