/// <summary> /// Find intersection point between this and other line using given tolerance. /// Returns null if no intersection, otherwise it returns a point on /// the shortest segment ( the one that's perpendicular to either lines ) /// based on given behavior ( default midpoint ). /// </summary> public Vector3D Intersect(double tol, Line3D other, LineIntersectBehavior behavior = LineIntersectBehavior.MidPoint) { var res = Intersect2(tol, other); if (res != null) { switch (behavior) { case LineIntersectBehavior.MidPoint: return(res.MidPoint); case LineIntersectBehavior.PointOnThis: return(res.From); case LineIntersectBehavior.PointOnOther: return(res.To); } } // not intersection return(null); }
/// <summary> /// Find intersection point between this and other line using given tolerance. /// Returns null if no intersection, otherwise it returns a point on /// the shortest segment ( the one that's perpendicular to either lines ) /// based on given behavior ( default midpoint ). /// </summary> public Vector3D Intersect(double tol, Line3D other, LineIntersectBehavior behavior = LineIntersectBehavior.MidPoint) { var perpSeg = ApparentIntersect(other); if (perpSeg != null && perpSeg.From.EqualsTol(tol, perpSeg.To)) { switch (behavior) { case LineIntersectBehavior.MidPoint: return(perpSeg.MidPoint); case LineIntersectBehavior.PointOnThis: return(perpSeg.From); case LineIntersectBehavior.PointOnOther: return(perpSeg.To); } } // not intersection return(null); }