(n)certainties – Columbia – Fall 2008

cv_trajectory

1: run trajectory.rvb
2: run splitcurves.rvb

1: trajectory
Option Explicit

‘Script written by
‘Script will prompt user for existing point(s)

Call Trajectory()
Sub Trajectory()

Dim FrstPt : FrstPt = Rhino.GetPointCoordinates (“first pts”)
If IsNull (FrstPt) Then Exit Sub
Dim CPts(), trajec()
Dim i, q, v
For q = 0 To Ubound(FrstPt)

Dim count : count = 9 ‘CInt( random(3,9))
ReDim CPts(count) : CPts(0) = FrstPt(q)

For i=1 To count

ReDim Preserve RPts(i)
ReDim Preserve SPts(i)
ReDim Preserve trajec(i-1)
ReDim Preserve arrPoints(i-1)

‘ADD NEW POINT
v = i-1
CPts(i) = Rhino.PointAdd(CPts(v), funcVector(CPts,v))
trajec(v) = Rhino.AddLine (CPts(v), CPts(i))
‘Rhino.AddPoint (CPts(i))

Next

Dim trajectory, trPt, strCurve
trajectory = Rhino.JoinCurves (trajec,True)
trPt = Rhino.CurveEditPoints(trajectory(0))
strCurve = Rhino.AddInterpCurve(trPt) ‘thanks Adolfo

Call Rhino.AddLayer (“trajectory”, RGB(255,0,0))
Call Rhino.AddLayer (“curves”, RGB(255,0,255))
Call Rhino.ObjectLayer (trajectory, “trajectory”)
Call Rhino.ObjectLayer (strCurve, “curves”)

Next

End Sub

Function random(min,max)
Randomize
random = (max-min) * Rnd + min
End Function

Function funcVector(CenterPoint,n)

Dim x, y, z
Dim min : min = 50
Dim max : max = 250

‘If CenterPoint(n)(0) > CenterPoint(0)(0) Then
If CenterPoint(n)(0) > 0 Then
x = random(-max,min)
Else
x = random(-min,max)
End If

‘If CenterPoint(n)(1) > CenterPoint(0)(1) Then
If CenterPoint(n)(1) > 0 Then
y = random(-max,min)
Else
y = random(-min,max)
End If

z = random(250,500)

funcVector = Array(x, y, z)

End Function

2 Split Curve
Option Explicit

‘Script written by
’script will prompt user for existing curves

Call Main()
Sub Main()

Dim crvObjectsT : crvObjectsT = Rhino.GetObjects(“Pick curve(s)”, 4)
If IsNull(crvObjectsT) Then Exit Sub

Dim intL : intL = 1000

Dim k : k = -1

Dim i
For i = 0 To Ubound(crvObjectsT)

Dim crvDomain : crvDomain = Rhino.CurveDomain(crvObjectsT(i))
Dim crvLength : crvLength = Rhino.CurveLength(crvObjectsT(i))

Dim intUnits : intUnits = CInt(crvLength/intL)

If intUnits > 1 Then
Dim arrCrvP : arrCrvP = Rhino.DivideCurve (crvObjectsT(i), intUnits , True, False)
Dim crvObjects : crvObjects = Rhino.SplitCurve (crvObjectsT(i), arrCrvP)
Dim j
For j = 0 To ubound(crvObjects)
Call Rhino.RebuildCurve (crvObjects(j),5,6)
Next
End If
Next

End Sub

Leave a Comment

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment