PtReflectionPolyLine extends PtsPolyline<T> { private static <T> List<Vect<T>> reflected(final Vect<T> center, final List<Vect<T>> pts) { final List<Vect<T>> result = new ArrayList<>(pts.size()); for (final Vect<T> point : pts) { result.add(PtReflectionPolyLine.reflected(center, point)); } return result; } PtReflectionPolyLine(final Vect<T> center, final Polyline<T> input);  PtReflectionPolyLine(final Polyline<T> input);   }
@Test public void buildsReflection() { final Polyline<Double> input = new PtsPolyline<>( Arrays.asList( new RandomPoint<>(), new RandomPoint<>(), new RandomPoint<>(), new RandomPoint<>() ) ); final RandomPoint<Double> across = new RandomPoint<>(); final Polyline<Double> result = new PtReflectionPolyLine<>(across, input); for (int idx = 0; idx < result.points().size(); ++idx) { PtReflectionPolyLineTest.equal( result.points().get(idx), PtReflectionPolyLineTest.reflected( across, input.points().get(idx) ) ); } }
@Test public void buildsReflectionAcrossOrigin() { final Polyline<Double> input = new PtsPolyline<>( Arrays.asList( new RandomPoint<>(), new RandomPoint<>(), new RandomPoint<>(), new RandomPoint<>() ) ); final Polyline<Double> result = new PtReflectionPolyLine<>(input); for (int idx = 0; idx < result.points().size(); ++idx) { PtReflectionPolyLineTest.equal( result.points().get(idx), PtReflectionPolyLineTest.reflected(input.points().get(idx)) ); } }