[Math] Check point is between two points

geometry

I want to check whether $(x_3,y_3)$ is between $(x_1,y_1)$ and $(x_2,y_2)$.

"between" means this:

enter image description here

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...