LighthouseInMalta_generative&parametric model

In order to help Paolo developing his thesis, i've produced a code for producing slim 3d-models to be analized and optimized.

The code is running in rhinoscript and it produces lighthouse models which has a fixed geometry. On the other hand, this geometry strongly depends on parametersThe script delete everything you've modeled in rhino and creates a lighthouse instance. 

Before publishing the script, i couple of remarks on its structure:

  1. first part contains:
    1. select all and delete commands
    2. a number of system parameters. Modifing these parameters it is possible to instantiate different lighthouses
    3. execute command (calling subroutine)
  2. main subroutine:
    1. defines  hyperboloids and core point clouds...
    2. ...and draws correspondent surface
    3. defines elix point clouds
    4. ...and draws correspondent surface
  3. each surface is defined by a different function, which assign (x,y,z) point to any (u,v) coordinate.

 

Here i post the code. You'll find correspondent .txt file in attachment

 


 

'iperboloide_v3

'i. riparametrizzati i raggi
'ii. cambiata eccentricità
'iii. aggiunto iperboloide interno (resta da verificare r_base)
'iv. aggiunta seconda elica

Rhino.enableRedraw False
Rhino.command "_SelAll"
Rhino.command "_Delete"

'dimensional parameter

'heigth[m]
h_base=1
h_top=11
'radius [m]
r_bottleneck=2
delta_r_base=1

'wind direction parameter

'rotation: counterclockwise [degrees]
counterclockwise=0
'eccentricity: r_y/r_x [1,+oo
eccentricity=1
'downwind shift [m]
shift=0
'downwind lift [m]
lift=0

'elix parameter

'revolution number
revolutions=5
'elix count
count=1

Call pointassignment()
Rhino.enableRedraw True

Sub pointassignment()
' _creates a number of Array contaning a n*m grid of points
' defining different surfaces, according to corresondent function.
' _create elix as well

n = 50
m = 50

rm=revolutions*m

Dim pts_hyp() ' points on outer hyperboloid
ReDim pts_hyp(n*m-1) ' n x m elemnts, from 0 to n*m-1

Dim pts_inthyp() ' points on inner hyperboloid
ReDim pts_inthyp(n*m-1)

Dim pts_core() ' points on cylindric core
ReDim pts_core(n*m-1)

Dim pts_extelix() ' points on outer elix
ReDim pts_extelix(3*rm-1) ' 3 points per row, revolutions*m rows

Dim pts_intelix() ' points on inner elix
ReDim pts_intelix(3*rm-1)

' rows
For i=0 To n-1
u = i/(n-1) ' u va da 0 a 1
' columns
For j = 0 To m-1
v = j/(m-1) ' v va da 0 a 1

' (i,j)-th point has (i*m+j)-th position
pts_hyp(i*m+j) = hyperboloid(u,v)
pts_inthyp(i*m+j) = hyperboloid_interior(u,v)
pts_core(i*m+j) = centralcore_physical(u,v)

Next
Next

' drawing hyperboloids and core surfaces
Rhino.addSrfPtGrid Array(n,m), pts_hyp
Rhino.addSrfPtGrid Array(n,m), pts_inthyp
Rhino.addSrfPtGrid Array(n,m), pts_core

For l=0 To count-1

For k=0 To rm-1

'elix parametric intrinsic coordinate
v = k/(rm-1) ' u va da 0 a 1
u=v*revolutions+l/(count)

'elix points
pts_extelix(3*k + 0)=hyperboloid(u-0.25,v)
pts_extelix(3*k + 1)=midpoint_ext(u-0.25,v)
pts_extelix(3*k + 2)=hyperboloid_interior(u-0.25,v)

pts_intelix(3*k + 0)=hyperboloid_interior(0.25-u,v)
pts_intelix(3*k + 1)=midpoint_int(0.25-u,v)
pts_intelix(3*k + 2)=centralcore(0.25-u,v)

Next

' drawingelix
Rhino.addSrfPtGrid Array(rm,3), pts_extelix
Rhino.addSrfPtGrid Array(rm,3), pts_intelix

Next
End Sub

Function hyperboloid(u,v)
' hyperboloid(u,v) defines outer hyerboloid surface
' calculatin for each (u,v) couple its correspondent 3d point
' u&v are curvilinear surface's coordinates.
' NOTE: sections on the top have same area.

'conversions
counterclockwise_r=Rhino.Pi*counterclockwise/180
r_base=r_bottleneck+delta_r_base

'cylindrical coordinates
theta=2*Rhino.Pi*u
z=(h_top-h_base+0.5*lift*(cos(theta+Rhino.pi)-1))*(-v)
r=Sqr((r_bottleneck)^2+ _
(2*delta_r_base*r_bottleneck+delta_r_base^2)*(-v)^2)

'cartesian coordinates
x=r*(cos(theta))+shift*(r-r_bottleneck)/r_base
y=r*eccentricity*sin(theta)

'rotating/traslating
x_finale=x*cos(counterclockwise_r)-y*sin(counterclockwise_r)
y_finale=x*sin(counterclockwise_r)+y*cos(counterclockwise_r)
z_finale=z+h_top

hyperboloid = Array(x_finale,y_finale,z_finale)

End Function

Function hyperboloid_interior (u,v)
'hyperboloid_interior(u,v) defines inner hyerboloid surface
'NOTE: section on the base do NOT have same area

'conversions
counterclockwise_r=Rhino.Pi*counterclockwise/180
r_top=Sqr(0.5*(r_bottleneck^2+(3.5/2)^2))
delta_r_intbase=delta_r_base/2
r_intbase=r_top+delta_r_intbase

'cylindrical coordinates
theta=2*Rhino.Pi*u
z=(h_top-0.7*h_base)*(-v)
r=Sqr((r_top)^2+ _
(2*delta_r_intbase*r_top+delta_r_intbase^2)*(-v)^2)

'cartesian coordinates
x=r*(cos(theta))+shift*(r-r_top)/r_intbase
y=r*eccentricity*sin(theta)

'rotating/traslating
x_finale=x*cos(counterclockwise_r)-y*sin(counterclockwise_r)
y_finale=x*sin(counterclockwise_r)+y*cos(counterclockwise_r)
z_finale=z+h_top

hyperboloid_interior = Array(x_finale,y_finale,z_finale)

End Function

Function centralcore(u,v)
' centralcore(u,v) defines core surface, whose (u,v) points
' are in correspondence with hyperboloyd(u,v) points

'cylindrical coordinates
theta=2*Rhino.Pi*u
z=v*(h_base-h_top)+h_top
r=3.5/2 '[m]

'cartesian coordinates
x=r*cos(theta)
y=r*sin(theta)

centralcore = Array(x,y,z)

End Function

Function centralcore_physical(u,v)
' centralcore_physical(u,v) defines core real surface

'coordinate cilindriche
theta=2*Rhino.Pi*u
z=(h_top+h_base)*v
r=3.5/2

'coordinate cartesiane
x=r*cos(theta)
y=r*sin(theta)

centralcore_physical = Array(x,y,z)

End Function

Function midpoint_ext(u,v)
' finds midpoint betwene correspondent (u,v) in outer and inner hyperboloid

hyp=hyperboloid(u,v)
cc=hyperboloid_interior(u,v)
midpoint_ext=Array( _
0.5*(hyp(0)+cc(0)), _
0.5*(hyp(1)+cc(1)), _
0.5*(hyp(2)+cc(2)))

End Function

Function midpoint_int(u,v)
' finds midpoint between correspondent (u,v) in inner hyperboloid and core

hyp=hyperboloid_interior(u,v)
cc=centralcore(u,v)
midpoint_int=Array( _
0.5*(hyp(0)+cc(0)), _
0.5*(hyp(1)+cc(1)), _
0.5*(hyp(2)+cc(2)))

 End Function

AllegatoDimensione
Plain text icon iperboloide_v3.txt5.33 KB