Intersection in 3D
According to this post
Most 3D lines do not intersect. A reliable method is to find the
shortest line
between two 3D lines. If the shortest line has a lenght of zero(or less than whatever tolerance you specify) then you know that the two original lines intersect.
Therefore, the question become
How can we find the
shortest line
between two 3D lines.
Check this article by Paul
Two examples I read
In short, this article introduced two thoughts/ implementation to get the minimal distance between two 3D lines.
- Write down the lenght of the line segment joining the two lines and then find the minimum
- dot product
If the minimal distance == 0
, then we can say these two lines intersected
Intersection.LineLine in RhinoCommon
Intersection.LineLine
Example code I made:
1 | using Rhino.Geometry.Intersect; |
Also, there’s a componeny called Line|Line
in grasshopper, we can directly use.