Distance to Leg
Distance to Leg
The heavy lifting in terms of deciding the relationship between points and line is done the distToLeg function.
This start life as simple distToLine function and returned the distance from a point to to line as described in the previous section. Over time, it evolve into something more powerful and now returns multiple values as an object. Some of the values were used in previous incarnations of the program logic and others are there to provide information to aid debugging.
The key items are
- it calculates the distance from
to the line defined by and . If doesn’t actually lie on the leg then this value is inflated to 1000m so it is effectively ignored. - It calculates the distance from
to - It calculates the distance from
to - It gets the minimum value of the three previous calculations and returns that as dist.
- It sets a boolean isOnLine to indicate whether to point is indeed close to the line. Currently this is true if
. - It sets a second boolean isNearLine which is true if
. isOnLine true implies that this will also be true. The use of this will be seen later when we look at the continuing co-incidence of the two segments. - A boolean matchP1 is returned as true if {\displaystyle P_{0}}$ is less than 30m from {\displaystyle P_{1}}$.
- A boolean matchP2 is returned as true if {\displaystyle P_{0}}$ is less than 30m from {\displaystyle P_{2}}$. Note that matchP1 can also be true at the same time.
A lot of this historical and now the most important value returned is isOnLine and most subsequent decisions are based on this.