Friday, April 27, 2012

Techno Tulips on surface and development of tail




 import rhinoscriptsyntax as rs
import math as m 
import random as r

surf = rs.GetObject("surface",8) # parameter 1

# DIVIDE THE SURFACE INTO GRID POINTS

d_u = rs.SurfaceDomain(surf,0)
d_v = rs.SurfaceDomain(surf,1)

d_u_len = (d_u[1] - d_u[0])/10
d_v_len = (d_v[1] - d_v[0])/20

# CALLING THE SURFACE TO POPULATE

cntrl_pts_surf = []
listofnormals = []
listofperp = []

attractor_pt1 = rs.GetPoint("attractor point 1") # parameter 2

for i in rs.frange(d_u[0],d_u[1],d_u_len):
    row_list = []
    normaltemplist = []
    perp_line = []
    vector_scale = 0.1
    for j in rs.frange(d_v[0],d_v[1],d_v_len):
        pt = rs.EvaluateSurface(surf,i,j)
        vector_scale = (rs.Distance(attractor_pt1, pt) + vector_scale)/8 # parameter 3
        normal_vector = rs.SurfaceNormal(surf,[i,j])
        normal_vector = rs.VectorUnitize(normal_vector)
        normal_vector = rs.VectorScale(normal_vector,vector_scale)
        normal_vector_pt = rs.VectorAdd(pt,normal_vector)
        normaltemplist.append(normal_vector_pt)
        row_list.append(pt)
        perp_line.append(rs.AddLine(normal_vector_pt, pt))
        row_list.append(pt)
    listofperp.append(perp_line)
    cntrl_pts_surf.append(row_list)
    listofnormals.append(normaltemplist)
rs.DeleteObject(surf)
curve = []

for i in range(0, len(listofperp)):
    for m in range(0, len(listofperp[i])):
        divisions = 20
        circle = []
        val = 1
        for j in range(divisions+1):
            parameter = j/divisions
            val = (val + j)
            radius = (rs.CurveLength(listofperp[i][m])/(2*val)) # parameter 4
            eval_param = rs.CurveParameter(listofperp[i][m],parameter)
            perp_frame = rs.CurvePerpFrame(listofperp[i][m], eval_param)
            circle.append(rs.AddCircle(perp_frame, radius))
        rs.AddLoftSrf(circle)




No comments:

Post a Comment