Detect when two edges make a "inner" angle or an "outer" angle So, given three points, a direction of movement and the side of the movement, find out the "external" or "internal" angle value.

In the left pic, I'm above the red line, moving from edge 1 to edge 2. The "external" angle (in orange) needs to be found.
In the right pic, I'm above the red line, moving from edge 1 to edge 2. The "internal" angle (in orange) needs to be found.
The info I have:
- the x and y values of the points
- the direction of the movement
- the direction of the lines (they are defined in a clockwise order)
This is killing me. Thanks.
Oh, and sorry about the "external" and "internal" names. I really don't know the definition of these.
I have to find the answer in all cases, here some more examples:

We could use p1, p2 and p3. p1 being the first point of the movement, p2 is the middle and p3 is the final one. In all cases this applies.

EDIT: Some more cases

 A: Let $P_1=(x_1,y_1),\;P_2=(x_2,y_2),\;P_3=(x_3,y_3)$. Then we have two vectors (arrows, if you like):
$${\bf v_1} = \overrightarrow{P_1P_2} = (x_2-x_1,\; y_2-y_1) \\
{\bf v_2} = \overrightarrow{P_2P_3} = (x_3-x_2,\; y_3-y_2).$$
The angle, $\theta$, between them is found via their dot product:
$$\theta_0 = \cos^{-1}\left(\dfrac{{\bf v_1}\cdot {\bf v_2}}{\|{\bf v_1}\|\;\|{\bf v_2}\|} \right).$$
This gives a value $\theta_0\in [0,\pi]$ and it assumes that ${\bf v_2}$ starts at $P_1$ instead of at $P_2$, which we must adjust for.
We also need to consider whether, in moving from ${\bf v_1}$ to ${\bf v_2}$, we are "turning left" or "turning right". We can determine this by using the cross product of these two vectors.
If we are turning left, the cross product vector ${\bf v_1}\times {\bf v_2}$ is in the positive $z$ direction, and if we are turning right it is in the negative $z$ direction.
The $z$-coordinate, $z_c$, of this cross product is:
$$z_c = (x_2-x_1)(y_3-y_2) - (x_3-x_2)(y_2-y_1).$$
Finally, we consider the side of the lines we move on. As we move along from $P_1$ to $P_2$ to $P_3$ this could be either the left or the right side of the lines. In the new examples provided, we are on the left in rows $1$ and $4$. we are on the right in rows $2$ and $3$.
So you could equate "being on the left of the lines" with either:


*

*moving left on the upper side, or

*moving right on the lower side.


And you could equate "being on the right of the lines" with either:


*

*moving left on the lower side, or

*moving right on the upper side.


So, putting this all together, we have the required angle, $\theta_1$, as follows:
\begin{eqnarray*}
&& \text{if $\theta_0 = 0$ then $\qquad\theta_1 = \pi$} \\
&& \text{else if $\theta_0 = \pi$ then $\qquad\theta_1 = 0$} \\
&& \text{else if we are on the LEFT of the lines and $z_c \gt 0$ then $\qquad\theta_1 = \pi - \theta_0$} \\
&& \text{else if we are on the LEFT of the lines and $z_c \lt 0$ then $\qquad\theta_1 = \pi + \theta_0$} \\
&& \text{else if we are on the RIGHT of the lines and $z_c \gt 0$ then $\qquad\theta_1 = \pi + \theta_0$} \\
&& \text{else if we are on the RIGHT of the lines and $z_c \lt 0$ then $\qquad\theta_1 = \pi - \theta_0$}.
\end{eqnarray*}
