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); }
/** * <p>Given three points (A, B, C), makes the vectors A-B and A-C, and makes * the cross product of these two vectors; this has the effect of making a * third vector at right angles to AB and AC.</p> * * <p>NOTE : the returned normal is normalized; that is, it has been * divided by its length.</p> * * @param ptA the 'middle' point * @param ptB one of the end points * @param ptC one of the end points * @return the vector at right angles to AB and AC */ public static Vector3d getNormal(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); normal.normalize(); return normal; }
StereoTool.getRawNormal(pointA, pointB, pointC, normalA, tmpX, tmpY); StereoTool.getRawNormal(pointB, pointC, pointD, normalB, tmpX, tmpY); StereoTool.getRawNormal(pointC, pointD, pointA, normalC, tmpX, tmpY);