### Question:
LineMath { public static boolean isPointOnLineSegment(ILine line, final IVector2 point, final double margin) { IVector2 lp = leadPointOnLine(line, point); double dist = VectorMath.distancePP(point, lp); if (dist > margin) { return false; } double lineLength = line.directionVector().getLength(); return VectorMath.distancePP(lp, line.supportVector()) <= (lineLength + margin) && VectorMath.distancePP(lp, line.supportVector().addNew(line.directionVector())) <= (lineLength + margin); } @SuppressWarnings("unused") private  LineMath(); static Optional<Double> getSlope(ILine line); static Optional<Double> getYIntercept(ILine line); static Optional<Double> getYValue(ILine line, final double x); static Optional<Double> getXValue(ILine line, final double y); static Optional<Double> getAngle(ILine line); static Vector2 leadPointOnLine(final ILine line, final IVector2 point); static Optional<IVector2> intersectionPoint(final ILine line1, final ILine line2); static Optional<IVector2> intersectionPointOfSegments(
			final ILine line1,
			final ILine line2); static Optional<IVector2> intersectionPointWithSegment(final ILine line, final ILine segment); static Optional<IVector2> intersectionPointOfLineAndHalfLine(final ILine line, final ILine halfLine); static Optional<IVector2> intersectionPointOfHalfLineAndHalfLine(final ILine halfLineA, final ILine halfLineB); static boolean isPointOnLineSegment(ILine line, final IVector2 point, final double margin); static boolean isPointInFront(final ILine line, final IVector2 point); static Vector2 nearestPointOnLineSegment(final ILine line, final IVector2 point); static Vector2 nearestPointOnHalfLine(final ILine halfLine, final IVector2 point); static double distancePL(final IVector2 point, final ILine line); static double distancePointHalfLine(final IVector2 point, final ILine halfLine); static double distancePointLineSegment(final IVector2 point, final ILine lineSegment); static IVector2 stepAlongLine(final IVector2 start, final IVector2 end, final double stepSize);  }### Answer:
@Test public void testIsPointOnLineSegment() { ILine segment = Line.fromPoints(Vector2f.ZERO_VECTOR, Vector2f.X_AXIS); final double margin = 1e-5; IVector2 point = Vector2.fromXY(1 + margin / 2.0, 0); Assert.assertTrue(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(1 + margin * 2, 0); Assert.assertFalse(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(0.5, 0); Assert.assertTrue(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(0.5, 0 + margin * 2); Assert.assertFalse(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(0.5, 0 + margin); Assert.assertTrue(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(0.0 - margin * 2, 0.0); Assert.assertFalse(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(0.0 - margin / 2, 0.0); Assert.assertTrue(LineMath.isPointOnLineSegment(segment, point, margin)); point = Vector2.fromXY(-SumatraMath.cos(AngleMath.deg2rad(45)) * margin, -SumatraMath.cos(AngleMath.deg2rad(45)) * margin); Assert.assertTrue(LineMath.isPointOnLineSegment(segment, point, margin)); }