Grasshopper

algorithmic modeling for Rhino

I've made a model that requires extracting the parameters from CurveCurve intersections between a number of curves (most are linear, some actually are polylines).  Some of the parameters returned are really screwy (I've only noticed the errors on the linear curves), for example returning parameter of 71.2 when the calling getLength on the same exact curve returns 6.55.  Some parameters being returns are negative, oddly enough.  I've attached a screenshot and pasted a short example script.

Dim int As rhino.Geometry.Intersect.CurveIntersections = rhino.Geometry.Intersect.Intersection.CurveCurve(x(0), x(1), 0.001, 0.001)
    print("Len Curve A  " & CStr(x(0).getlength))
    print("Len Curve B  " & CStr(x(1).getlength))
    print("ParamA  " & CStr(int.Item(0).parameterA))
    print("ParamB  " & CStr(int.Item(0).parameterB))

It works fine if I extract the end points of the linear curves and replace the curve with new lines going from startpoint to endpoint and then calling Line.ToNurbsCurve. For now I will use this fix, but this seems like a serious bug (or I am way off base and don't understand how parameters work, which is certainly a possibility).

Anyone have an answer?

Cheers,

Ben

Views: 327

Attachments:

Replies to This Discussion

Hi Ben,

curve parameters do not necessarily correspond with length. You need to use Curve.PointAt(t) in order to go from curve-parameter to 3d-point.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hmm,
Well I did try that, but to no avail. For the linear Curves: Int.Item(k).PointA universally gives the correct answer, but if I grabbed the ParameterA and then called CurveA.PointAt(ParamA) the resulting point was always wayyyyyyyyyyyyy off... and not necessarily even on CurveA if you extend it to infinity.

Another thing to note is that if I go over the lines that are giving me problems, and delete and replace them this seems to fix the issue. It is quite apparently something to do with the specific linear curves that I am working with, which is really odd as they are were all generated by New Line(PtA,PtB) in an earlier script.

Thanks for the fast reply.

Cheers,

Ben
You'll have to supply some curves that don't work. This (very simple) test fails to reproduce the problem:

Private Sub RunScript(ByVal x As Curve, ByVal y As Curve, ByRef A As Object)
  Dim ccx As Rhino.Geometry.Intersect.CurveIntersections = Rhino.Geometry.Intersect.Intersection.CurveCurve(x, y, 0.01, 0.01)
  If (ccx Is Nothing) Then
    Print("No intersections found")
    Return
  End If

  Print("{0} intesection(s) found", ccx.Count)

  Dim pts As New List(Of Point3d)
  For i As Integer = 0 To ccx.Count - 1
    pts.Add(x.PointAt(ccx(i).ParameterA))
  Next

  A = pts
End Sub


--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service