@Test public void testIsOnEdge() { Polygon rectangle=new Polygon(0, new Vector3(0, 0), new Vector3(1, 0), new Vector3(1, 1),new Vector3(0,1 )); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0, 0))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0.5f, 0))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(1, 0))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(1, 0.4f))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(1, 1))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0.5f, 1f))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0, 1))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0, 0.5f))); Assert.assertTrue(rectangle.isOnEdge(new Vector3(0, 0.5f))); Assert.assertFalse(rectangle.isOnEdge(new Vector3(0.5f, 0.5f))); Assert.assertFalse(rectangle.isOnEdge(new Vector3(2, 0.5f))); for(int i=0;i<100000000;i++) { rectangle.isOnEdge(new Vector3(1, 0.4f)); } }
public boolean isOnEdge(Vector3 point) { for (int i = 0; i < points.size(); i++) { if (Vector3.isPointOnSegment(points.get(i), points.get((i + 1) % points.size()), point)) { return true; } } return false; }
Polygon implements Shape { public boolean isOnEdge(Vector3 point) { for (int i = 0; i < points.size(); i++) { if (Vector3.isPointOnSegment(points.get(i), points.get((i + 1) % points.size()), point)) { return true; } } return false; } }
Polygon implements Shape { public boolean isOnEdge(Vector3 point) { for (int i = 0; i < points.size(); i++) { if (Vector3.isPointOnSegment(points.get(i), points.get((i + 1) % points.size()), point)) { return true; } } return false; } Polygon(int index, List<Vector3> points, int[] vectorIndexs);  Polygon(int index, List<Vector3> points, int[] vectorIndexs,boolean initCalculate);  Polygon(int index, Vector3... point);  Polygon(List<Vector3> points); }
Polygon implements Shape { public boolean isOnEdge(Vector3 point) { for (int i = 0; i < points.size(); i++) { if (Vector3.isPointOnSegment(points.get(i), points.get((i + 1) % points.size()), point)) { return true; } } return false; } Polygon(int index, List<Vector3> points, int[] vectorIndexs);  Polygon(int index, List<Vector3> points, int[] vectorIndexs,boolean initCalculate);  Polygon(int index, Vector3... point);  Polygon(List<Vector3> points); void calculateCenter(); void calculateRadius(); void calculateArea(); float getAndCalcSignedArea(); boolean calculateIsConvex(); float getArea(); int getIndex(); Vector3 getPoint(int i); boolean isInnerPoint(Vector3 point); boolean isOnEdge(Vector3 point); boolean contains(Polygon polygon); boolean contains(Vector3 p); boolean intersectsEdge(Polygon polygon); @Override String toString(); @Override Rectangle getBounds(); @Override Rectangle2D getBounds2D(); @Override boolean contains(double x, double z); @Override boolean contains(Point2D p); @Override boolean intersects(double x, double y, double w, double h); @Override boolean intersects(Rectangle2D r); @Override boolean contains(double x, double y, double w, double h); @Override boolean contains(Rectangle2D r); @Override PathIterator getPathIterator(AffineTransform at); @Override PathIterator getPathIterator(AffineTransform at, double flatness); String print(); }
Polygon implements Shape { public boolean isOnEdge(Vector3 point) { for (int i = 0; i < points.size(); i++) { if (Vector3.isPointOnSegment(points.get(i), points.get((i + 1) % points.size()), point)) { return true; } } return false; } Polygon(int index, List<Vector3> points, int[] vectorIndexs);  Polygon(int index, List<Vector3> points, int[] vectorIndexs,boolean initCalculate);  Polygon(int index, Vector3... point);  Polygon(List<Vector3> points); void calculateCenter(); void calculateRadius(); void calculateArea(); float getAndCalcSignedArea(); boolean calculateIsConvex(); float getArea(); int getIndex(); Vector3 getPoint(int i); boolean isInnerPoint(Vector3 point); boolean isOnEdge(Vector3 point); boolean contains(Polygon polygon); boolean contains(Vector3 p); boolean intersectsEdge(Polygon polygon); @Override String toString(); @Override Rectangle getBounds(); @Override Rectangle2D getBounds2D(); @Override boolean contains(double x, double z); @Override boolean contains(Point2D p); @Override boolean intersects(double x, double y, double w, double h); @Override boolean intersects(Rectangle2D r); @Override boolean contains(double x, double y, double w, double h); @Override boolean contains(Rectangle2D r); @Override PathIterator getPathIterator(AffineTransform at); @Override PathIterator getPathIterator(AffineTransform at, double flatness); String print(); public int index; public List<Vector3> points; public float y; public Vector3 center; public float area; public boolean counterClockWise; public boolean convex; public float radius; public float radiusSq; public int[] vectorIndexs; transient List<Connection<Polygon>> connections; public List<Vector3> randomPoints; }