Intersection curve curve

Hi guys.
I have a problem with this code:

        var intersecciones = Intersection.CurveCurve(curveExterior, curveInterior, 01, 0.01);
        foreach (IntersectionEvent interseccion in intersecciones)
        {
            if (interseccion.IsOverlap)
            {

The original curves are that:

But, interseccion.IsOverlap is false, Cleary, as we can see, there are two segments that intersect. I try to put diferent values of tolerances but it not works.

Can anybody help me?
Thanks in advance.

Can you please provide a sample file for us to test?

Sure, here it is.
FicheroInterseccionesNoVa.3dm (171.3 KB)

Clearly there is only a point intersection here. You can verify using the Intersect command or this sample:

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsIntersectCurves.cs

Dale, Thanks for your answer.
I think I have not explained well.

I am aware that only touch at one point.
I think that I do not understand that the tolerances are used.

If I put a tolerance of 1, All points of the two curves that they distance are less than 1 are considered like intersection.
Is it right?

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Intersect_Intersection_CurveCurve.htm

In this page put something like that.

toleranceType: System.Double
Intersection tolerance. If the curves approach each other to within tolerance,
an intersection is assumed

overlapToleranceType: System.Double
The tolerance with which the curves are tested.

Sorry if it’s a very basic question.

Thanks

@GregArden, can you provide any insight here?

Here is the way I think overlap tolerance for curve/curve intersection works.

  1. First curves are broken up at kinks. So in the example of 2 rectangles we are intersecting a set of 4 lines segments against another set of 4 line segments.

  2. When intersecting a pair of curves without kinks the first step is to find the distance from each curve endpoint to the opposite curve. If there are two endpoints within overlap tolerance we check to see if the intervening curve segment is entirely within overlap tolerance.

  3. After any overlapping segments are removed in step 2 we look for intersections and then test for overlaps between consecutive intersections, using overlap tolerance.

So in conclusion. Just because two segments of curves are within overlap tolerance doesn’t mean they should result in an overlap event. Also, the endpoints of overlap events are always special, either they are curve endpoints, kink points or “true” intersection points.

1 Like

I get it.

Thanks Greg Arden and Dale.

One thing more. I think that the intersecction.CurveCurve has to return “IsOverlap=True” in this pair of curves:
InterseccionOverlapNoFunciona.3dm (18.5 KB)

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        try
        {
            ObjRef[] crvRef;
            Result res = RhinoGet.GetMultipleObjects("Select 2 curves", false, ObjectType.Curve, out crvRef);
            if (res != Result.Success)
                return res;
            List<Curve> curvas = new List<Curve>();
            foreach (ObjRef obj in crvRef)
            {
                curvas.Add((Curve)obj.Geometry());    
            }
            if (curvas.Count != 2)
            {
                return Result.Failure;
            }
            
            var intersecciones = Intersection.CurveCurve(curvas[0], curvas[1], 0.01, 0.01);
            foreach (IntersectionEvent interseccion in intersecciones)
            {
                if (interseccion.IsOverlap == false)
                {
                    MessageBox.Show("No Overlap");
                }
                else
                {
                    MessageBox.Show("Si Overlap");
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        return Result.Success;
    }

Are there any function of rhinoCommon that detect this pair of curves as overlapped?

Thanks in advance.