/** * Tests if the two given lines are collinear given a tolerance on the angle between in the range ]0; <i>pi</i>/2[. * This method returns {@code true} if the two lines are collinear, whether they are pointing in the same direction or in opposite directions. * * <p> * Edge cases: * <ul> * <li> if the direction magnitude of either line is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param pointOnLine1 point located on the first line. Not modified. * @param lineDirection1 the first line direction. Not modified. * @param pointOnLine2 point located on the second line. Not modified. * @param lineDirection2 the second line direction. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @param distanceEpsilon tolerance on the distance to determine if {@code pointOnLine2} belongs to the first line segment. * @return {@code true} if the two line segments are collinear, {@code false} otherwise. */ public static boolean areLinesCollinear(Point2d pointOnLine1, Vector2d lineDirection1, Point2d pointOnLine2, Vector2d lineDirection2, double angleEpsilon, double distanceEspilon) { return areLinesCollinear(pointOnLine1.getX(), pointOnLine1.getY(), lineDirection1.getX(), lineDirection1.getY(), pointOnLine2.getX(), pointOnLine2.getY(), lineDirection2.getX(), lineDirection2.getY(), angleEpsilon, distanceEspilon); }
/** * Tests if the two given lines are collinear given a tolerance on the angle between in the range ]0; <i>pi</i>/2[. * This method returns {@code true} if the two lines are collinear, whether they are pointing in the same direction or in opposite directions. * * <p> * Edge cases: * <ul> * <li> if the direction magnitude of either line is below {@code 1.0E-7}, this method fails and returns {@code false}. * </ul> * </p> * * @param pointOnLine1 point located on the first line. Not modified. * @param lineDirection1 the first line direction. Not modified. * @param pointOnLine2 point located on the second line. Not modified. * @param lineDirection2 the second line direction. Not modified. * @param angleEpsilon tolerance on the angle in radians. * @param distanceEpsilon tolerance on the distance to determine if {@code pointOnLine2} belongs to the first line segment. * @return {@code true} if the two line segments are collinear, {@code false} otherwise. */ public static boolean areLinesCollinear(Point3d pointOnLine1, Vector3d lineDirection1, Point3d pointOnLine2, Vector3d lineDirection2, double angleEpsilon, double distanceEspilon) { return areLinesCollinear(pointOnLine1.getX(), pointOnLine1.getY(), pointOnLine1.getZ(), lineDirection1.getX(), lineDirection1.getY(), lineDirection1.getZ(), pointOnLine2.getX(), pointOnLine2.getY(), pointOnLine2.getZ(), lineDirection2.getX(), lineDirection2.getY(), lineDirection2.getZ(), angleEpsilon, distanceEspilon); }
double lineDirection2x = secondPointOnLine2.getX() - firstPointOnLine2.getX(); double lineDirection2y = secondPointOnLine2.getY() - firstPointOnLine2.getY(); return areLinesCollinear(pointOnLine1x, pointOnLine1y, lineDirection1x, lineDirection1y, pointOnLine2x, pointOnLine2y, lineDirection2x, lineDirection2y, angleEpsilon, distanceEspilon);
double lineDirection2y = secondPointOnLine2.getY() - firstPointOnLine2.getY(); double lineDirection2z = secondPointOnLine2.getZ() - firstPointOnLine2.getZ(); return areLinesCollinear(pointOnLine1x, pointOnLine1y, pointOnLine1z, lineDirection1x, lineDirection1y, lineDirection1z, pointOnLine2x, pointOnLine2y, pointOnLine2z, lineDirection2x, lineDirection2y, lineDirection2z, angleEpsilon, distanceEspilon);