Finite line intersection, how to determine?


How can quickly I check if a curve intersects with a line that goes from A to B and only check if it intersects between A and B?

The LineCurveIntersection intersects with an infinite line. Is there a “FiniteLineCurveIntersection” option that I don’t know, or do I have to write an evaluation to find out if the coordinates of the intersection is larger or smaller than A or B?

I need the check to be as fast as possible since I work on a mesh splitter that doesn’t fail if the curve runs right through a mesh’s vertice.



By the way, in Rhino6 I get an error on rs.LineCurveIntersection() is it not implemented?

It is listed here:


Hi @Holo, i think the easiest would be to create a finite line curve:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    crv_id = rs.GetObject("Curve", 4, True, False)
    if not crv_id: return
    pts = rs.GetPoints("LinePoints", False, None, None, 2)
    if not pts: return
    crv = rs.coercegeometry(crv_id, True)
    line = Rhino.Geometry.LineCurve(pts[0], pts[1])
    tol = scriptcontext.doc.ModelAbsoluteTolerance
    rc =  Rhino.Geometry.Intersect.Intersection.CurveCurve(crv, line, tol, 0.0)
    print "Found: ", rc.Count

As you say, it may be faster to check if the point(s) found using the infinite line and curve intersection are within your 2 line end points. This seems usuable: line.DistanceTo(testPoint, limitToFiniteSegment)

I cannot find that too. But this seems to be new in V6. (its for infinite line though)