Please forgive me, but I'm not mathematically inclined and i'm trying to solve a problem for a video game i'm developing. My levels are composed of vector shapes and i want to find out what the average angle given three points. Please see this image for an example: example here
I can get the angles for the points easily, so i know the two angles from a->b->c
my efforts so far have given me crazy results, there are certain angles and use cases where things are upside down and all over the place.
Can anybody help?
Take the angle from $A$ to $B$ and add $180$; this is the angle from $B$ to $A$. Call this
angle1and do not worry if it is out of range, that is, is greater than 360 or less than 0.Average the angle from $B$ to $C$ and
angle1; this is the angle of the bisector of $\angle ABC$. (Note that it may be the angle of the "inner" $\angle ABC$ or the "outer" $\angle ABC$, but either way, it is perpendicular to the line segment $N$ in your linked image.) Call thisangle2and do not worry if it is out of range.Set
angle3 = mod(angle2 + 90, 360). This one of the angles of line segment $N$ and is in the range $[0,360)$. The other angle of $N$ ismod(angle3 + 180, 360)and is also in the range.In C-like pseudo-code (no promises, I haven't compiled C-ish code in years):
Note that this could be compacted significantly, but I have no reason to believe a vaguely modern compiler can't at least match any "mad hax" I can express via pseudocode.