Tuesday, April 24, 2012

Spheres On Surface:Radius Linked to Curvature


import rhinoscriptsyntax as rs
import random
from math import *

srf = rs.GetObject('select surface',8)
uDom = rs.SurfaceDomain(srf,0)
vDom = rs.SurfaceDomain(srf,1)

uDivide = 20
vDivide = 20

Ustep = (uDom[1]-uDom[0])/int(uDivide)
Vstep = (vDom[1]-vDom[0])/int(vDivide)
rs.EnableRedraw(False)
ptL = []
rowList = []
sphereL = []
for i in rs.frange(uDom[0],uDom[1],Ustep):
    colList = []
    for j in rs.frange(vDom[0],vDom[1],Vstep):
        eval = rs.EvaluateSurface(srf,i,j)
        curvature = rs.SurfaceCurvature(srf,(i,j))
        curve4 = curvature[4]
        if curve4<.01:
            curve4 = .01
        frame = rs.SurfaceFrame(srf,(i,j))
        sphere = rs.AddSphere(frame,curve4*20)
        sphereL.append(sphere)
        colList.append(eval)
    rowList.append(colList)
for i in range (0,len(rowList)):
    rs.AddPoints(rowList[i])
rs.EnableRedraw(True)

No comments:

Post a Comment