Ray3 extends Line3Base implements ReadOnlyRay3, Poolable { @Override public boolean intersectsTriangle(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB, final ReadOnlyVector3 pointC, final Vector3 locationStore) { return intersects(pointA, pointB, pointC, locationStore, false); } Ray3();  Ray3(final ReadOnlyRay3 source);  Ray3(final ReadOnlyVector3 origin, final ReadOnlyVector3 direction); Ray3 set(final ReadOnlyRay3 source); @Override double getDistanceToPrimitive(final Vector3[] worldVertices); @Override boolean intersects(final Vector3[] polygonVertices, final Vector3 locationStore); @Override boolean intersectsTriangle(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB,
      final ReadOnlyVector3 pointC, final Vector3 locationStore); @Override boolean intersectsTrianglePlanar(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB,
      final ReadOnlyVector3 pointC, final Vector3 locationStore); @Override boolean intersectsQuad(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB,
      final ReadOnlyVector3 pointC, final ReadOnlyVector3 pointD, final Vector3 locationStore); @Override boolean intersectsQuadPlanar(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB,
      final ReadOnlyVector3 pointC, final ReadOnlyVector3 pointD, final Vector3 locationStore); @Override boolean intersectsPlane(final ReadOnlyPlane plane, final Vector3 locationStore); @Override double distanceSquared(final ReadOnlyVector3 point, final Vector3 store); static boolean isValid(final ReadOnlyRay3 ray); @Override String toString(); @Override boolean equals(final Object o); @Override Ray3 clone(); final static Ray3 fetchTempInstance(); final static void releaseTempInstance(final Ray3 ray);  }
@Test public void testIntersectsTriangle() { final Vector3 v0 = new Vector3(-1, -1, -1); final Vector3 v1 = new Vector3(+1, -1, -1); final Vector3 v2 = new Vector3(+1, +1, -1); final Vector3 intersectionPoint = new Vector3(); Ray3 pickRay = new Ray3(new Vector3(0.5, -0.5, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(0, -1, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(0, 0, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(+1, 0, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(-1, -1, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(+1, -1, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(1, 1, 3), new Vector3(0, 0, -1)); assertTrue(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(0, -1.1, 3), new Vector3(0, 0, -1)); assertFalse(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(-0.1, 0.1, 3), new Vector3(0, 0, -1)); assertFalse(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(+1.1, 0, 3), new Vector3(0, 0, -1)); assertFalse(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(-0.5, -0.5, 3), new Vector3(0, 0, +1)); assertFalse(pickRay.intersectsTriangle(v0, v1, v2, intersectionPoint)); pickRay = new Ray3(new Vector3(0.5, -0.5, 3), new Vector3(0, 0, -1)); assertTrue(4.0 == pickRay.getDistanceToPrimitive(new Vector3[] {v0, v1, v2})); assertTrue(pickRay.intersectsTrianglePlanar(v0, v1, v2, intersectionPoint)); }