I think there is an error in the MinimumDistance method of Rhino.Geometry.Line. When there are two colinear lines with different directions and the endpoints towards each other, it measures not the Minimum Distance, but the distance from end of line to the start of the other line (but end to end would be the minimum). But already the slightest angle between the lines result in correct results.
Please share a 3dm file with such a setup and code to reproduce the problem.
LineMinimumDistanceError.3dm (38.3 KB)
I checked it with this small python script
import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
from scriptcontext import doc
ids = rs.GetObjects(“sel two lines”)
lines = [doc.Objects.Find(id).Geometry.Line for id in ids]
print lines[0].MinimumDistanceTo(lines[1])
Could you reproduce the error? I’ve installed the latest update but it is still the same.
Hi @philipp.rumpf,
The function does not do any colinear testing or endpoint switching. This is up-to-you to decide if this is necessary.
– Dale
I can reproduce the bug.
You are not telling him anything he doesn’t already know.
The OP is handing you a bug report on a silver platter.
Not only did he provide example geometry and example code he also clearly explained the specific conditions that allow you to observe the bug. Create any two lines that are collinear and have their endpoints closest to each other and Line.MinimumDistanceTo will produce incorrect results.
@jim thank you for bringing the point home. I have created a YT ticket for this.
And I should have picked this up sooner, as I asked for a repro and @philipp.rumpf provided it about two months ago.
Of course it was easy to set up a function which gives the right results back, so I didn’t use this function any more. I just thought a function with this name should give back the minimum distance in any cases
. Thanks to all.