arc intersection failed

arc intersection failed

phantbinh99
Enthusiast Enthusiast
613 Views
3 Replies
Message 1 of 4

arc intersection failed

phantbinh99
Enthusiast
Enthusiast

Hi everyone,

I'm having trouble with intersection detection between two halves of a circle. I've divided the circle into two arcs and am using the [Curve.Intersect] function to check for intersections.

However, even though the circles are clearly connected, I still don't get any intersection points. Am I missing something or doing something wrong?

Any help or suggestions would be greatly appreciated.
```

// Calculate the midpoint of the circle
XYZ center = circle.Center;

double radius = circle.Radius;
XYZ xDirection = circle.XDirection;
XYZ yDirection = circle.YDirection;

 

// Calculate the start, mid, and end points based on the circle's orientation
XYZ startPoint = center + radius * xDirection; // Point at angle 0
XYZ topHalfPoint = center + radius * yDirection; // Point at angle 90
XYZ midPoint = center + radius * (-xDirection); // Point at angle 180 (opposite side)
XYZ bottomHalfPoint = center + radius * -yDirection; // Point at angle 270

 

// Create the two arcs using explicit points
Arc arc1 = Arc.Create(startPoint, midPoint, topHalfPoint);
Arc arc2 = Arc.Create(startPoint, midPoint, bottomHalfPoint); // Continuation of arc1
```
SetComparisonResult setComparisonResult = arc1.Intersect(arc2, out var intersectionResults);
```

The result was disjoint.

phantbinh99_1-1725550559255.png

 

0 Likes
Accepted solutions (2)
614 Views
3 Replies
Replies (3)
Message 2 of 4

Mohamed_Arshad
Advisor
Advisor
Accepted solution

HI @phantbinh99 

 

     Your question is very interesting, I have done some workaround your question, The first point is I have created a Circle using two arc manually and tested its Intersection eventually it is showing Disjoint. I checked the arc end points that also same. 

    

     So I'm concluding that If we make circle by two arc then we can able to calculate its intersection of the two arc. But we can use point comparison to evaluate the results. Kindly check the below code.

 

Sample Code Snippet (Exception Case)

XYZ arc1EndPoint = arc1.GetEndPoint(0);
XYZ arc2EndPoint=arc2.GetEndPoint(0);

XYZ arc1StPoint = arc1.GetEndPoint(1);
XYZ arc2StPoint = arc2.GetEndPoint(1);

if(arc1EndPoint.IsAlmostEqualTo(arc2EndPoint) && arc1StPoint.IsAlmostEqualTo(arc2StPoint))
{
    TaskDialog.Show("Arcs are equal", "Arcs are Subset");
}
else
{
    TaskDialog.Show("Arcs are not equal", "Arcs are not Subset");
}

 

Hope this will helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

Message 3 of 4

phantbinh99
Enthusiast
Enthusiast
Accepted solution
Hi, thanks for helping me. Actually I already have a function that handles the above problem, just like yours

Maybe a little upgrade, you can check if it really overlaps by checking the parameter

```
// Compare parameter ranges to ensure proper matching of overlapping curves.
double originCurveStartParameter = originCurve.GetEndParameter(0);
double originCurveEndParameter = originCurve.GetEndParameter(1);
double maxParameterOfOriginCurve = Math.Max(originCurveStartParameter, originCurveEndParameter);
double minParameterOfOriginCurve = Math.Min(originCurveStartParameter, originCurveEndParameter);

double curveStartParameter = curve.GetEndParameter(0);
double curveEndParameter = curve.GetEndParameter(1);
double maxParameterOfCurve = Math.Max(curveStartParameter, curveEndParameter);
double minParameterOfCurve = Math.Min(curveStartParameter, curveEndParameter);

if (maxParameterOfOriginCurve < minParameterOfCurve || minParameterOfOriginCurve > maxParameterOfCurve)
{
//Overlap
}
```
Message 4 of 4

Mohamed_Arshad
Advisor
Advisor

Yeah, it is checking the overlap of curves, I wrote for Subset


Mohamed Arshad K
Software Developer (CAD & BIM)