/** * Tests if the two planes are parallel by testing if their normals are collinear. * The latter is done given a tolerance on the angle between the two normal axes in the range ]0; <i>pi</i>/2[. * * <p> * Edge cases: * <ul> * <li> if the length of either normal is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param otherPlane the other plane to do the test with. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @return {@code true} if the two planes are parallel, {@code false} otherwise. */ public boolean isParallel(Plane3d otherPlane, double angleEpsilon) { return GeometryTools.areVectorsCollinear(normal, otherPlane.normal, angleEpsilon); }
/** * Tests if the two given planes are coincident: * <ul> * <li> {@code planeNormal1} and {@code planeNormal2} are collinear given the tolerance {@code angleEpsilon}. * <li> the distance of {@code pointOnPlane2} from the first plane is less than {@code distanceEpsilon}. * </ul> * <p> * Edge cases: * <ul> * <li> if the length of either normal is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param pointOnPlane1 a point on the first plane. Not modified. * @param planeNormal1 the normal of the first plane. Not modifed. * @param pointOnPlane2 a point on the second plane. Not modified. * @param planeNormal2 the normal of the second plane. Not modified. * @param angleEpsilon tolerance on the angle in radians to determine if the plane normals are collinear. * @param distanceEpsilon tolerance on the distance to determine if {@code pointOnPlane2} belongs to the first plane. * @return {@code true} if the two planes are coincident, {@code false} otherwise. */ public static boolean arePlanesCoincident(Point3d pointOnPlane1, Vector3d planeNormal1, Point3d pointOnPlane2, Vector3d planeNormal2, double angleEpsilon, double distanceEpsilon) { if (!areVectorsCollinear(planeNormal1, planeNormal2, angleEpsilon)) return false; else return distanceFromPointToPlane(pointOnPlane2, pointOnPlane1, planeNormal1) < distanceEpsilon; }
double pointOnLine2y, double lineDirection2x, double lineDirection2y, double angleEpsilon, double distanceEspilon) if (!areVectorsCollinear(lineDirection1x, lineDirection1y, lineDirection2x, lineDirection2y, angleEpsilon)) return false;
double lineDirection2y, double lineDirection2z, double angleEpsilon, double distanceEspilon) if (!areVectorsCollinear(lineDirection1x, lineDirection1y, lineDirection1z, lineDirection2x, lineDirection2y, lineDirection2z, angleEpsilon)) return false;
/** * Tests if the two given vectors are collinear given a tolerance on the angle between the two vector axes in the range ]0; <i>pi</i>/2[. * This method returns {@code true} if the two vectors are collinear, whether they are pointing in the same direction or in opposite directions. * * <p> * Edge cases: * <ul> * <li> if the length of either vector is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param firstVector the first vector. Not modified. * @param secondVector the second vector. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @return {@code true} if the two vectors are collinear, {@code false} otherwise. */ public static boolean areVectorsCollinear(Vector2d firstVector, Vector2d secondVector, double angleEpsilon) { return areVectorsCollinear(firstVector.getX(), firstVector.getY(), secondVector.getX(), secondVector.getY(), angleEpsilon); }
/** * Tests if the two given vectors are collinear given a tolerance on the angle between the two vector axes in the range ]0; <i>pi</i>/2[. * This method returns {@code true} if the two vectors are collinear, whether they are pointing in the same direction or in opposite directions. * * <p> * Edge cases: * <ul> * <li> if the length of either vector is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param firstVector the first vector. Not modified. * @param secondVector the second vector. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @return {@code true} if the two vectors are collinear, {@code false} otherwise. */ public static boolean areVectorsCollinear(Vector3d firstVector, Vector3d secondVector, double angleEpsilon) { return areVectorsCollinear(firstVector.getX(), firstVector.getY(), firstVector.getZ(), secondVector.getX(), secondVector.getY(), secondVector.getZ(), angleEpsilon); }