Point Methods to test if a point lies between two other points

These arose while I was working on a web app for the Canal and River Trust.
On computers with location services (GPS etc.), I wanted to place a marker on a
navigation diagram between two features (typically locks) so that the user could
see his/her current location.
The diagram is schematic, not a scaled map, so I needed a function to test if the
current location was between two known locations.
Navigations do not normally travel in a straight line, so a rough test was
required to allow for deviations from the straight line.

Three methods are provided to test if a point (p0) lies between two other points
p1 and p2.

The method tests whether this point (p0) lies within the circle centred midway between
p1 and p2 with radius half the distance between p1 and p2.

The circle passes through p1 and p2. Points p1 and p2 are considered to be within
the circle. Change the <= test to a < test to exclude points on the circle.

Point.isBetween2(p1, p2, e)

This method tests whether this point (p0) lies within the ellipse (of eccentricity e)
centred midway between p1 and p2.

Points p1 and p2 are the end points of the major axis of the ellipse and are considered
to be within the ellipse. Change the <= test to a < test to exclude points on the
ellipse.

Point.isBetween3(p1, p2, e)

Point.isBetween3 is essentially the same as Point.isBetween2. The code has been
modified to eliminate the Math.sqrt calls.

Choose point 1 (x,y)

Choose point 2 (x,y)

Choose point 0 (x,y)

Set eccentricity

by major-axis to minor-axis ratio:

or by direct entry of e in [0,1):

Diagram

The diagram displays the points and the circle and ellipse used in the calculation.
Note that the y-coordinate increases downwards on the diagram.

Log Output

Table of eccentricities for various major-axis to minor-axis ratios (a)