private static boolean isSquarePlanar(Point3d pointA, Point3d pointB, Point3d pointC, Point3d pointD, Vector3d normal) { // define a plane using ABC, also checking that the are not colinear Vector3d vectorAB = new Vector3d(); Vector3d vectorAC = new Vector3d(); getRawNormal(pointA, pointB, pointC, normal, vectorAB, vectorAC); if (StereoTool.isColinear(normal)) return false; // check that F is in the same plane as CDE return StereoTool.allCoplanar(normal, pointC, pointD); }
/** * Checks the three supplied points to see if they fall on the same line. * It does this by finding the normal to an arbitrary pair of lines between * the points (in fact, A-B and A-C) and checking that its length is 0. * * @param ptA * @param ptB * @param ptC * @return true if the tree points are on a straight line */ public static boolean isColinear(Point3d ptA, Point3d ptB, Point3d ptC) { Vector3d vectorAB = new Vector3d(); Vector3d vectorAC = new Vector3d(); Vector3d normal = new Vector3d(); StereoTool.getRawNormal(ptA, ptB, ptC, normal, vectorAB, vectorAC); return isColinear(normal); }
@Test public void colinearTestWithNearlyColinearPoints() { Point3d pointA = new Point3d(1, 1, 1); Point3d pointB = new Point3d(2, 2.001, 2); Point3d pointC = new Point3d(3, 3, 3); Assert.assertTrue(StereoTool.isColinear(pointA, pointB, pointC)); }
@Test public void colinearTestWithNonColinearPoints() { Point3d pointA = new Point3d(1, 1, 1); Point3d pointB = new Point3d(2, 3, 2); Point3d pointC = new Point3d(3, 3, 3); Assert.assertFalse(StereoTool.isColinear(pointA, pointB, pointC)); }
@Test public void colinearTestWithColinearPoints() { Point3d pointA = new Point3d(1, 1, 1); Point3d pointB = new Point3d(2, 2, 2); Point3d pointC = new Point3d(3, 3, 3); Assert.assertTrue(StereoTool.isColinear(pointA, pointB, pointC)); }
Point3d pointF = atomF.getPoint3d(); boolean isColinearABF = StereoTool.isColinear(pointA, pointB, pointF); if (isColinearABF) {
boolean isColinearABG = isColinear(pointA, pointB, pointG); if (!isColinearABG) return false;