Curve curve intersection in GH C# - why am I getting only one intersection point?

Hello everyone,
here’s a simple script i’m starting, however I it’s not outputting the second intersection point.

Interval domain = new Interval (0, 1);// to reparametrize the input curve
wall.Domain = domain;
openings.Domain = domain;

Point3d point1 = Rhino.Geometry.Intersect.Intersection.CurveCurve(wall, openings, 0.001, 0)[0].PointA;
Point3d point2 = Rhino.Geometry.Intersect.Intersection.CurveCurve(wall, openings, 0.001, 0)[0].PointB;

A = point1;
B = point2;

I think you want to get PointA of both the intersection events that are generated:

Point3d point1 = Rhino.Geometry.Intersect.Intersection.CurveCurve(wall, openings, 0.001, 0)[0].PointA;
Point3d point2 = Rhino.Geometry.Intersect.Intersection.CurveCurve(wall, openings, 0.001, 0)[1].PointA;

A = point1;
B = point2;

You need to check if curves overlap so that you can take A2 B2 points.
Here is sample for another issue I solved before.

public static List<Point3d> IntersectTwoCurves(this Curve c0, Curve c1, double t = 0.01) {


    var ccx = Rhino.Geometry.Intersect.Intersection.CurveCurve(c0, c1, t, 5 * t);


    var point3ds = new List<Point3d>();

    for (int i = 0; i < ccx.Count; i++) {

        point3ds.Add(0.5 * (ccx[i].PointA + ccx[i].PointB));

        if (ccx[i].IsOverlap) 
            point3ds.Add(0.5 * (ccx[i].PointA2 + ccx[i].PointB2));

    }

    return point3ds;


}
2 Likes