/// <summary> /// Computes the intersection between a curve and a plane.<br/> /// https://www.parametriczoo.com/index.php/2020/03/31/plane-and-curve-intersection/ /// </summary> /// <param name="crv">The curve to intersect.</param> /// <param name="pl">The plane to intersect with the curve.</param> /// <param name="tolerance">Tolerance set per default at 1e-6.</param> /// <returns>If intersection found a collection of <see cref="CurvePlaneIntersectionResult"/> otherwise the result will be empty.</returns> public static List <CurvePlaneIntersectionResult> CurvePlane(NurbsBase crv, Plane pl, double tolerance = 1e-6) { List <NurbsBase> bBoxRoot = BoundingBoxOperations.BoundingBoxPlaneIntersection(new LazyCurveBBT(crv), pl); List <CurvePlaneIntersectionResult> intersectionResults = bBoxRoot.Select( x => IntersectionRefiner.CurvePlaneWithEstimation(crv, pl, x.Knots[0], x.Knots[0], tolerance)).ToList(); return(intersectionResults); }
/// <summary> /// Computes the self intersections of a curve. /// </summary> /// <param name="crv">The curve for self-intersections.</param> /// <param name="tolerance">Tolerance set per default at 1e-6.</param> /// <returns>If intersection found a collection of <see cref="CurvesIntersectionResult"/> otherwise the result will be empty.</returns> public static List <CurvesIntersectionResult> CurveSelf(NurbsBase crv, double tolerance = 1e-6) { List <Tuple <NurbsBase, NurbsBase> > bBoxTreeIntersections = BoundingBoxOperations.BoundingBoxTreeIntersection(new LazyCurveBBT(crv), 0); List <CurvesIntersectionResult> intersectionResults = bBoxTreeIntersections .Select(x => IntersectionRefiner.CurvesWithEstimation(x.Item1, x.Item2, x.Item1.Knots[0], x.Item2.Knots[0], tolerance)) .Where(crInRe => Math.Abs(crInRe.ParameterA - crInRe.ParameterB) > tolerance) .Unique((a, b) => Math.Abs(a.ParameterA - b.ParameterA) < tolerance * 5); return(intersectionResults); }