Code with Misuse: |
class SubLine { /** Get the intersection of the instance and another sub-line. * <p> * This method is related to the {@link Line#intersection(Line) * intersection} method in the {@link Line Line} class, but in addition * to compute the point along infinite lines, it also checks the point * lies on both sub-line ranges. * </p> * @param subLine other sub-line which may intersect instance * @param includeEndPoints if true, endpoints are considered to belong to * instance (i.e. they are closed sets) and may be returned, otherwise endpoints * are considered to not belong to instance (i.e. they are open sets) and intersection * occurring on endpoints lead to null being returned * @return the intersection point if there is one, null if the sub-lines don't intersect */ public Vector3D intersection(final SubLine subLine, final boolean includeEndPoints) {
// compute the intersection on infinite line Vector3D v1D = line.intersection(subLine.line);
// check location of point with respect to first sub-line Location loc1 = remainingRegion.checkPoint(line.toSubSpace(v1D));
// check location of point with respect to second sub-line Location loc2 = subLine.remainingRegion.checkPoint(subLine.line.toSubSpace(v1D));
if (includeEndPoints) { return ((loc1 != Location.OUTSIDE) && (loc2 != Location.OUTSIDE)) ? v1D : null; } else { return ((loc1 == Location.INSIDE) && (loc2 == Location.INSIDE)) ? v1D : null; }
}
}
|