@Test public void testDistancePL() { List<ILine> lines = new ArrayList<>(); List<Double> idx = new ArrayList<>(); for (double i = 0; i < (2 * Math.PI); i += 0.1) { idx.add(i); final double spiralCoeff = i + 1e-3; IVector2 p2 = Vector2.fromXY(spiralCoeff * SumatraMath.cos(i), spiralCoeff * SumatraMath.sin(i)); lines.add(Line.fromDirection(Vector2f.ZERO_VECTOR, p2)); } for (int i = 0; i < idx.size(); ++i) { final double scalefactor = idx.get(i) * Math.pow(10, idx.get(i) - Math.PI); final IVector2 scaledX = Vector2f.X_AXIS.multiplyNew(scalefactor); final IVector2 scaledY = Vector2f.Y_AXIS.multiplyNew(scalefactor); final double distanceX = LineMath.distancePL(scaledX, lines.get(i)); final double distanceY = LineMath.distancePL(scaledY, lines.get(i)); Assert.assertEquals(Math.abs(scalefactor * SumatraMath.sin(idx.get(i))), distanceX, TEST_ACCURACY_SQR); Assert.assertEquals(Math.abs(scalefactor * SumatraMath.cos(idx.get(i))), distanceY, TEST_ACCURACY_SQR); final double distanceX2 = LineMath.distancePL(scaledX, lines.get(i)); final double distanceY2 = LineMath.distancePL(scaledY, lines.get(i)); Assert.assertEquals(Math.abs(scalefactor * SumatraMath.sin(idx.get(i))), distanceX2, TEST_ACCURACY_SQR); Assert.assertEquals(Math.abs(scalefactor * SumatraMath.cos(idx.get(i))), distanceY2, TEST_ACCURACY_SQR); assertThat(distanceX).isCloseTo(distanceX2, within(TEST_ACCURACY)); assertThat(distanceY).isCloseTo(distanceY2, within(TEST_ACCURACY)); } }
public static double distancePL(final IVector2 point, final ILine line) { return VectorMath.distancePP(point, leadPointOnLine(line, point)); }
LineMath { public static double distancePL(final IVector2 point, final ILine line) { return VectorMath.distancePP(point, leadPointOnLine(line, point)); } }
LineMath { public static double distancePL(final IVector2 point, final ILine line) { return VectorMath.distancePP(point, leadPointOnLine(line, point)); } @SuppressWarnings("unused") private  LineMath(); }
LineMath { public static double distancePL(final IVector2 point, final ILine line) { return VectorMath.distancePP(point, leadPointOnLine(line, point)); } @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); }
LineMath { public static double distancePL(final IVector2 point, final ILine line) { return VectorMath.distancePP(point, leadPointOnLine(line, point)); } @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);  }