algorithmic modeling for Rhino
Tags:
Function ClosestPtToPtList (ByRef testPt as On3dPoint, _
ByRef PtList as List(of On3dPoint)) as Integer
Dim minDistIDX as Integer = 0 'set to first index
Dim minDist as double = Dist_NoSquare(testPt, ptList(0))
Dim currDist as double
For i as integer = 1 to ptList.Count - 1
currDist = Dist_NoSquare(testPt, ptList(i))
If minDist > currDist Then
minDist = currDist
minDistIDX = i
End If
Next
Return minDistIDX
End Function
Function Dist_NoSquare (ByRef pt1 as On3dpoint, _
ByRef pt2 as On3dpoint) as double
'This is basically the Pythagorean theorem with an extra dimension
Dim dX, dY, dZ as double
dX = pt2.x - pt1.x
dY = pt2.y - pt1.y
dZ = pt2.z - pt1.z
Return dX^2 + dY^2 +dZ^2
End Function
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by