private static TetrahedralSign getHandedness(Vector3d planeNormal, Point3d pointInPlane, Point3d testPoint) { double distance = signedDistanceToPlane(planeNormal, pointInPlane, testPoint); // The point-plane distance is the absolute value, // the sign of the distance gives the side of the plane the point is on // relative to the plane normal. if (distance > 0) { return TetrahedralSign.PLUS; } else { return TetrahedralSign.MINUS; } }
/** * Check that all the points in the list are coplanar (in the same plane) * as the plane defined by the planeNormal and the pointInPlane. * * @param planeNormal the normal to the plane * @param pointInPlane any point know to be in the plane * @param points an array of points to test * @return false if any of the points is not in the plane */ public static boolean allCoplanar(Vector3d planeNormal, Point3d pointInPlane, Point3d... points) { for (Point3d point : points) { double distance = StereoTool.signedDistanceToPlane(planeNormal, pointInPlane, point); if (distance < PLANE_TOLERANCE) { continue; } else { return false; } } return true; }
@Test public void positivePointPlaneDistanceTest() { // the normal for the Y-Z plane is X Vector3d planeNormal = new Vector3d(XAXIS); planeNormal.normalize(); // an arbitrary point in the Y-Z plane Point3d pointInPlane = new Point3d(0, 1, 1); // make a positive point on the X axis = same direction as the normal Point3d pointToMeasurePos = new Point3d(2, 0, 0); double distancePos = StereoTool.signedDistanceToPlane(planeNormal, pointInPlane, pointToMeasurePos); Assert.assertEquals(2.0, distancePos, 0.1); }
@Test public void negativePointPlaneDistanceTest() { // the normal for the Y-Z plane is X Vector3d planeNormal = new Vector3d(XAXIS); planeNormal.normalize(); // an arbitrary point in the Y-Z plane Point3d pointInPlane = new Point3d(0, 1, 1); // make a negative point on the X axis = opposite direction to normal Point3d pointToMeasureNeg = new Point3d(-2, 0, 0); double distance = StereoTool.signedDistanceToPlane(planeNormal, pointInPlane, pointToMeasureNeg); Assert.assertEquals(-2.0, distance, 0.1); }