I want to check whether $(x_3,y_3)$ is between $(x_1,y_1)$ and $(x_2,y_2)$.
"between" means this:
Best Answer
If $\exists t$, such that
$$
\pmatrix{x_2-x_1\\y_2-y_1}t + \pmatrix{x_1\\y_1}=\pmatrix{x_3\\y_3},
$$
then $\pmatrix{x_3\\y_3}$ lies between the two others..
EDIT
Complete the triangle. If the angles at $\pmatrix{x_2\\y_2}$ or $\pmatrix{x_1\\y_1}$ are both less than $90^\circ$ then $\pmatrix{x_3\\y_3}$ is between. See here how to calculate the angles...
The point $ap_1+(1-a)p_2$ can also be written as $p_2+a(p_1-p_2)$. Perhaps you recognize this as a parametric representation of a line through $p_2$ with direction vector $p_1-p_2$ (with $a$ as the parameter).
When $a=0$, $ap_1+(1-a)p_2=p_2$. And when $a=1$, $ap_1+(1-a)p_2=p_1$. So the points $ap_1+(1-a)p_2$ with $0\le a\le1$ make up the line segment between the two given points.
Best Answer
If $\exists t$, such that $$ \pmatrix{x_2-x_1\\y_2-y_1}t + \pmatrix{x_1\\y_1}=\pmatrix{x_3\\y_3}, $$ then $\pmatrix{x_3\\y_3}$ lies between the two others..
EDIT
Complete the triangle. If the angles at $\pmatrix{x_2\\y_2}$ or $\pmatrix{x_1\\y_1}$ are both less than $90^\circ$ then $\pmatrix{x_3\\y_3}$ is between. See here how to calculate the angles...