@Test public void testIsPointInShapeWithMargin() { double margin = 250d; Vector2 a = Vector2.fromXY(0.0, 0.0); Vector2 b = Vector2.fromXY(1000.0, 0.0); Vector2 c = Vector2.fromXY(0.0, 1000.0); Triangle triangle = Triangle.fromCorners(a, b, c); ILineSegment abSegment = Lines.segmentFromPoints(a,b); IVector2 ab = abSegment.stepAlongLine(abSegment.getLength()/2.); ILineSegment bcSegment = Lines.segmentFromPoints(a,b); IVector2 bc = bcSegment.stepAlongLine(bcSegment.getLength()/2.); ILineSegment acSegment = Lines.segmentFromPoints(a,b); IVector2 ac = acSegment.stepAlongLine(acSegment.getLength()/2.); testCornersWithMargin(triangle, margin); assertThat(triangle.isPointInShape(a)).isTrue(); assertThat(triangle.isPointInShape(b)).isTrue(); assertThat(triangle.isPointInShape(c)).isTrue(); assertThat(triangle.isPointInShape(ab)).isTrue(); assertThat(triangle.isPointInShape(bc)).isTrue(); assertThat(triangle.isPointInShape(ac)).isTrue(); assertThat(triangle.isPointInShape(a, margin)).isTrue(); assertThat(triangle.isPointInShape(b, margin)).isTrue(); assertThat(triangle.isPointInShape(c, margin)).isTrue(); assertThat(triangle.isPointInShape(a, -margin)).isFalse(); assertThat(triangle.isPointInShape(b, -margin)).isFalse(); assertThat(triangle.isPointInShape(c, -margin)).isFalse(); }
public static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c) { return new Triangle(a, b, c); }
Triangle extends ATriangle { public static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c) { return new Triangle(a, b, c); } }
Triangle extends ATriangle { public static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c) { return new Triangle(a, b, c); } @SuppressWarnings("unused") private  Triangle(); protected  Triangle(final IVector2 a, final IVector2 b, final IVector2 c); protected  Triangle(final Triangle triangle); }
Triangle extends ATriangle { public static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c) { return new Triangle(a, b, c); } @SuppressWarnings("unused") private  Triangle(); protected  Triangle(final IVector2 a, final IVector2 b, final IVector2 c); protected  Triangle(final Triangle triangle); static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c); @Override ITriangle withMargin(final double margin); @Override ITriangle shortenToPoint(final IVector2 x); @Override IVector2 getA(); @Override IVector2 getB(); @Override IVector2 getC(); @Override List<IVector2> getCorners(); @Override final boolean equals(final Object o); @Override double area(); @Override boolean isNeighbour(ITriangle triangle); @Override List<IVector2> lineIntersections(final ILine line); @Override int hashCode(); @Override String toString(); }
Triangle extends ATriangle { public static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c) { return new Triangle(a, b, c); } @SuppressWarnings("unused") private  Triangle(); protected  Triangle(final IVector2 a, final IVector2 b, final IVector2 c); protected  Triangle(final Triangle triangle); static Triangle fromCorners(final IVector2 a, final IVector2 b, final IVector2 c); @Override ITriangle withMargin(final double margin); @Override ITriangle shortenToPoint(final IVector2 x); @Override IVector2 getA(); @Override IVector2 getB(); @Override IVector2 getC(); @Override List<IVector2> getCorners(); @Override final boolean equals(final Object o); @Override double area(); @Override boolean isNeighbour(ITriangle triangle); @Override List<IVector2> lineIntersections(final ILine line); @Override int hashCode(); @Override String toString();  }