 # Closest distance between two curves CurveCurveIntersection

Hi,

How I can compute closest distance between two curves?

I use curve curve intersection, but it is sensitive to tolerance.
If I set tolerance to 10 it gives good result and if 100 it is way off.
Is there some sort of way of to set the tolerance so that always closest distance is taken?CCP.gh (19.7 KB)

Is this is the right method?

`````` private void RunScript(List<Curve> x, object y, ref object A, ref object B)
{
double maxDistance, maxt0, maxt1,minDistance,mint0,mint1;
Rhino.Geometry.Curve.GetDistancesBetweenCurves(x, x, 1000, out maxDistance, out maxt0, out maxt1, out minDistance, out mint0, out mint1);
A = x.PointAt(mint0);
B = x.PointAt(mint1);
C =  x.PointAt(maxt0);
D = x.PointAt(maxt1);
}``````
1 Like

Works like magic.

Do you know what is the difference between the two methods?
Is one faster than the other?

``````x.ClosestPoints(x,out p0, out p1);

Rhino.Geometry.Curve.GetDistancesBetweenCurves(...)``````
1 Like

Afraid I don’t, but we could look up the source on GitHub. A quick performance comparison test might be faster though 1 Like