Grasshopper

algorithmic modeling for Rhino

Hi

I am trying to do a little recursive subdivision thing on some triangles but I can't seem to find a way in vb to do something like explode the curve so that I could then get points at t parameter 0.5 and 0...or is there a better way to think about it?

I've looked in the primer and the vb help chm file but can't find anything...
thanks for the help in advance

Views: 920

Replies to This Discussion

Here's a VB that works out pLine vertices - for midpoints I suppose you just find the division of endpoint span summation e.g. midPt = (spanVec(i) + spanVec(i +1)) / 2

Sub RunScript(ByVal inCrv As OnCurve)
Dim spanVec(0) As Double
inCrv.GetSpanVector(spanVec)

Dim arrPt As New List (Of On3dPoint)

For i As Int32 = 0 To spanVec.Length() - 1
Dim pt As New On3dPoint
pt = inCrv.PointAt(spanVec(i))
arrPt.Add(pt)
Next

A = arrPt
End Sub
thanks - I tried that before but I think the parameter averages doesn't work...

but maybe I can do the equivalent with vectors
Try this additional code:

Sub RunScript(ByVal inCrv As OnCurve)
Dim spanNum As New Int32
spanNum = inCrv.SpanCount()

Dim spanVec(0) As Double
inCrv.GetSpanVector(spanVec)

'collect vertices
Dim arrPt As New List (Of On3dPoint)

For i As Int32 = 0 To spanNum
Dim pt As New On3dPoint
pt = inCrv.PointAt(spanVec(i))
arrPt.Add(pt)
Next

'collect midpoints
Dim arrMidPt As New List (Of On3dPoint)

For i As Int32 = 0 To spanNum - 1
Dim nVec As New On3dVector(arrPt(i + 1) - arrPt(i))
nVec = nVec / 2
Dim mPt As New On3dPoint(nVec + arrPt(i))
arrMidPt.Add(mPt)
Next

'removes end vertex if closed
If (inCrv.IsClosed) Then
arrPt.RemoveAt(spanNum)
End If

A = arrPt
B = arrMidPt
End Sub

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service