segmentFraction method
Computes the fraction of distance (in 0.0, 1.0
)
that the projection of a point occurs along this line segment.
If the point is beyond either ends of the line segment,
the closest fractional value (0.0 or 1.0) is returned.
Essentially, this is the {@link #projectionFactor} clamped to the range [0.0, 1.0]. If the segment has zero length, 1.0 is returned.
@param inputPt the point @return the fraction along the line segment the projection of the point occurs
Implementation
double segmentFraction(Coordinate inputPt) {
double segFrac = projectionFactor(inputPt);
if (segFrac < 0.0)
segFrac = 0.0;
else if (segFrac > 1.0 || segFrac.isNaN) segFrac = 1.0;
return segFrac;
}