@Test public void testIntersectsPlane() { final CCVector3 intersectionPoint = new CCVector3(); CCPlane plane = new CCPlane(new CCVector3(0, 1, 0), 2); CCRay3 pickRay = new CCRay3(new CCVector3(0, 3, 0), new CCVector3(0, 0, 1)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, 3, 0), new CCVector3(0, 1, 0)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, 2, 0), new CCVector3(0, 1, 0)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, 1, 0), new CCVector3(0, 1, 0)); assertNotNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, 0, 0), new CCVector3(1, 0, 0)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -3, 0), new CCVector3(0, 0, 1)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, 3, 0), new CCVector3(0, -1, 0)); assertNotNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -3, 0), new CCVector3(1, 1, 1)); assertNotNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -3, 0), new CCVector3(-1, -1, -1)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); plane = new CCPlane(new CCVector3(1, 1, 1), -2); pickRay = new CCRay3(new CCVector3(0, 0, 0), new CCVector3(1, -1, 1)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -1, 0), new CCVector3(0, 1, 0)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -2, 0), new CCVector3(0, 1, 0)); assertNull(pickRay.intersectsPlane(plane, intersectionPoint)); pickRay = new CCRay3(new CCVector3(0, -3, 0), new CCVector3(0, 1, 0)); assertNotNull(pickRay.intersectsPlane(plane, null)); }
public CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore) { final CCVector3 normal = thePlane.normal(); final double denominator = normal.dot(_myDirection); if (denominator > -CCMath.FLT_EPSILON && denominator < CCMath.FLT_EPSILON) { return null; } final double numerator = -normal.dot(_myOrigin) + thePlane.constant(); final double ratio = numerator / denominator; if (ratio < CCMath.FLT_EPSILON) { return null; } if (theLocationStore == null) { theLocationStore = new CCVector3(); } theLocationStore.set(_myDirection).multiplyLocal(ratio).addLocal(_myOrigin); return theLocationStore; }
CCRay3 extends CCLine3Base { public CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore) { final CCVector3 normal = thePlane.normal(); final double denominator = normal.dot(_myDirection); if (denominator > -CCMath.FLT_EPSILON && denominator < CCMath.FLT_EPSILON) { return null; } final double numerator = -normal.dot(_myOrigin) + thePlane.constant(); final double ratio = numerator / denominator; if (ratio < CCMath.FLT_EPSILON) { return null; } if (theLocationStore == null) { theLocationStore = new CCVector3(); } theLocationStore.set(_myDirection).multiplyLocal(ratio).addLocal(_myOrigin); return theLocationStore; } }
CCRay3 extends CCLine3Base { public CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore) { final CCVector3 normal = thePlane.normal(); final double denominator = normal.dot(_myDirection); if (denominator > -CCMath.FLT_EPSILON && denominator < CCMath.FLT_EPSILON) { return null; } final double numerator = -normal.dot(_myOrigin) + thePlane.constant(); final double ratio = numerator / denominator; if (ratio < CCMath.FLT_EPSILON) { return null; } if (theLocationStore == null) { theLocationStore = new CCVector3(); } theLocationStore.set(_myDirection).multiplyLocal(ratio).addLocal(_myOrigin); return theLocationStore; } CCRay3();  CCRay3(final CCRay3 theSource);  CCRay3(final CCVector3 theOrigin, final CCVector3 theDirection); }
CCRay3 extends CCLine3Base { public CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore) { final CCVector3 normal = thePlane.normal(); final double denominator = normal.dot(_myDirection); if (denominator > -CCMath.FLT_EPSILON && denominator < CCMath.FLT_EPSILON) { return null; } final double numerator = -normal.dot(_myOrigin) + thePlane.constant(); final double ratio = numerator / denominator; if (ratio < CCMath.FLT_EPSILON) { return null; } if (theLocationStore == null) { theLocationStore = new CCVector3(); } theLocationStore.set(_myDirection).multiplyLocal(ratio).addLocal(_myOrigin); return theLocationStore; } CCRay3();  CCRay3(final CCRay3 theSource);  CCRay3(final CCVector3 theOrigin, final CCVector3 theDirection); static CCRay3 createFromLine(CCVector3 theStart, CCVector3 theEnd); CCRay3 set(final CCRay3 theSource); double getDistanceToPrimitive(final CCVector3[] theWorldVertices); boolean intersects(final CCVector3[] thePolygonVertices, final CCVector3 theLocationStore); boolean intersectsTriangle(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theLocationStore
	); boolean intersectsTrianglePlanar(
		final CCVector3 pointA, 
		final CCVector3 pointB, 
		final CCVector3 pointC,
		final CCVector3 locationStore
	); boolean intersectsQuad(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theD,
		final CCVector3 theLocationStore
	); boolean intersectsQuadPlanar(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theD,
		final CCVector3 theLocationStore
	); CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore); CCVector3 intersectsPlane(final CCPlane thePlane); double distanceSquared(final CCVector3 thePoint, final CCVector3 theStore); static boolean isValid(final CCRay3 theRay); @Override String toString(); @Override boolean equals(final Object theObject); @Override CCRay3 clone(); }
CCRay3 extends CCLine3Base { public CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore) { final CCVector3 normal = thePlane.normal(); final double denominator = normal.dot(_myDirection); if (denominator > -CCMath.FLT_EPSILON && denominator < CCMath.FLT_EPSILON) { return null; } final double numerator = -normal.dot(_myOrigin) + thePlane.constant(); final double ratio = numerator / denominator; if (ratio < CCMath.FLT_EPSILON) { return null; } if (theLocationStore == null) { theLocationStore = new CCVector3(); } theLocationStore.set(_myDirection).multiplyLocal(ratio).addLocal(_myOrigin); return theLocationStore; } CCRay3();  CCRay3(final CCRay3 theSource);  CCRay3(final CCVector3 theOrigin, final CCVector3 theDirection); static CCRay3 createFromLine(CCVector3 theStart, CCVector3 theEnd); CCRay3 set(final CCRay3 theSource); double getDistanceToPrimitive(final CCVector3[] theWorldVertices); boolean intersects(final CCVector3[] thePolygonVertices, final CCVector3 theLocationStore); boolean intersectsTriangle(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theLocationStore
	); boolean intersectsTrianglePlanar(
		final CCVector3 pointA, 
		final CCVector3 pointB, 
		final CCVector3 pointC,
		final CCVector3 locationStore
	); boolean intersectsQuad(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theD,
		final CCVector3 theLocationStore
	); boolean intersectsQuadPlanar(
		final CCVector3 theA, 
		final CCVector3 theB, 
		final CCVector3 theC, 
		final CCVector3 theD,
		final CCVector3 theLocationStore
	); CCVector3 intersectsPlane(final CCPlane thePlane, CCVector3 theLocationStore); CCVector3 intersectsPlane(final CCPlane thePlane); double distanceSquared(final CCVector3 thePoint, final CCVector3 theStore); static boolean isValid(final CCRay3 theRay); @Override String toString(); @Override boolean equals(final Object theObject); @Override CCRay3 clone();  }