Triangle implements Shape { public boolean isInnerPoint(Vector3 point) { boolean res=Vector3.pointInLineLeft(a, b, point); if(res!=Vector3.pointInLineLeft(b, c, point)) { return false; } if(res!=Vector3.pointInLineLeft(c, a, point)) { return false; } if(Vector3.cross2D(a, b, c)==0) { return false; } return true; } Triangle(Vector3 a, Vector3 b, Vector3 c, int index,int ...vectorIndex); @Override String toString(); int getIndex(); List<Connection<Triangle>> getConnections(); float getAngle(Vector3 reference); Vector3 getRandomPoint(Vector3 out); float area(); float area2D(); boolean isInnerPoint(Vector3 point); @Override int hashCode(); @Override boolean equals(Object obj); @Override Rectangle getBounds(); @Override Rectangle2D getBounds2D(); @Override boolean contains(double x, double y); @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); public int index; public Vector3 a; public Vector3 b; public Vector3 c; public float y; public Vector3 center; transient List<Connection<Triangle>> connections; public int[] vectorIndex; }
@Test public void testPointIntTriangle() { Vector3 point1=new Vector3(4, 1); Vector3 point2=new Vector3(4, 5); Triangle triangle=new Triangle(new Vector3(1, 1), new Vector3(6, 3), new Vector3(4, 7), 1); Assert.assertFalse(triangle.isInnerPoint(point1)); Assert.assertTrue(triangle.isInnerPoint(point2)); }