I want to check whether $(x_3,y_3)$ is between $(x_1,y_1)$ and $(x_2,y_2)$.
"between" means this:
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityI want to check whether $(x_3,y_3)$ is between $(x_1,y_1)$ and $(x_2,y_2)$.
"between" means this:
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...
Drop the perpendicular from point 3 on the line between point 1 and point 2, and see where the foot point of this perpendicular is.
That is, compute the difference between the endpoints of the line $$ d_0 = \pmatrix{x_2-x_1\\y_2-y_1} $$ and its direction $$ v = d_0 / ||d_0|| $$ Then compute the vector from the start point of the line to the point in question $$ d_1 = \pmatrix{x_3-x_1\\y_3-y_1} $$ And finally, the dot product $$ r = v * d_1 $$ When this dot product is in the range $[0, ||d_0||]$, then the point is between the other points.