I'm looking for a better solution than the 2 algorithms I've currently written (in C) to check if a point on the circumference of a circle is located in the short arc created between two other points on the same circle.
For example: p1 = 358 deg, p2 = 1 deg on the circumference, and I need to know if p3 = .5 degrees is located between p1 and p2 (the solution should regard it as such).
Clarification: For this use case I only check "betweenness" if p1 != p3 or p2 != p3. In those exceedingly rare cases (floating point numbers) I already have the answer I need.
This problem is complicated by the fact that sometimes retrograde motion means p2 < p1, and also because p1 and p2 can straddle the 0/360 degree boundary.
My real world use case (in case you are interested) is to determine when to continue on and apply an interpolation algorithm for finding exact time of conjunction (occultation) between two bodies in space, one body represented by p1 & p2 at known times, and a different object at p3.
I've marked @tp1 answer correct because of the effort he expended in answering it, but I've not gotten around to testing it. It is computationally intensive and the following ended up being a simpler (and probably faster) solution which didn't require transforming the angle values into cartesian coordinates.
This definitely works in all cases I can think to test.