# Zack Aman

## 15 Feb 2015

Parametric Jellyfish by @zackaman is a rhinopython script for generating jellyfish with different bodies and tentacles.

The idea for the parametric jellyfish actually started as a flower.

I thought a flower with a variable number and shape of petals along with some swirly stamens would make for a nice parametric object.  After doing the first (non-parametric) sketch above, however, I realized I mostly wanted to focus on the swirly bits, so I decided to turn it upside down and make it a jellyfish.

The script takes several variables: body height and width, number of tentacles, tentacle height, tentacle swirl, and tentacle bend. The tentacles are generated by creating an interpolated arc for each tentacle, and generating the points with a circle per bend, plus some randomness in height between circles and radius.

Some sketches (can’t figure out how to make WordPress not rotate these images):

A basic jellyfish, with a plain head, five tentacles, no swirl, and no bend in the tentacles:

A slightly more complicated jellyfish, with three tentacles, no swirl, but a fair amount of bend:

A nice pancake top jellyfish.  This one has a wide but shallow body and just a slight swirl and bend:

A complex jellyfish, with many tentacles, a large amount of bend a large amount of swirl:

Python script code:

```import rhinoscriptsyntax as rs
import math
import random

origin = (0,0,0)

#make jellyfish body
#get height
bodyHeight = rs.GetInteger("Set body height (1-20)", 5, 1, 20)
print(bodyHeight)

#set three points to make interpolated curve: origin, origin + radius / height, some midpoint (half of height, random radius added)
bodyList = []
bodyList.append(origin)
midpoint = (0, midRadius, 0 - (bodyHeight / 2))
bodyList.append(midpoint)
endpoint = (0, bodyRadius, 0 - bodyHeight)
bodyList.append(endpoint)
print(bodyList)

bodyAxis = [(0,0,0), (0,0,1)]
print("bodySurface")
print(bodySurface)

#bodySolid = rs.OffsetSurface(bodySurface, 10, 0.01, False, True)
if rs.IsSurface(bodySurface):
print("is a surface")
#bodySolid = rs.OffsetSurface(bodySurface, 1)
bodySolid = rs.ExtrudeSurface(bodySurface, centerLine)
print("bodySolid")
print(bodySolid)

#make jellyfish tentacles
#get number of tentacles
tentacleNum = rs.GetInteger("How many tentacles? (1-10)", 5, 1, 10)
print(tentacleNum)
#get swirliness - 0 : num tentacles, governs how far over the tentacle wil move to the next circle
tentacleSwirl = rs.GetInteger("How much swirl? (0 - "+str(tentacleNum)+")", 0, 0, tentacleNum)
print(tentacleSwirl)
#get bendiness
tentacleBend = rs.GetInteger("How much bendiness in tentacles? (2-10)", 3, 2, 10)
print(tentacleBend)
#get height - use variation from 75% - 125%
tentacleHeight = rs.GetInteger("Set tentacle height (5-50)", 20, 5, 50)
print(tentacleHeight)

curHeight = -0.5
curAngle = 0
tentaclePoints = []

#for bendiness, set up circle of points
for i in range(0, tentacleBend):
#set up circle

print(curHeight)
bendPoints = []

#place points around circle
for j in range(0, tentacleNum):
if(i == 0):
curPoint = (0, 0, -1)
bendPoints.append(curPoint)
else:
bendPoints.append(curPoint)
curAngle += tentacleArc

tentaclePoints.append(bendPoints)

curHeight -= abs(tentacleHeight/tentacleBend * 5 * random.random())

print tentaclePoints

#for each tentacle
for i in range(0, tentacleNum):
curTentacle = []
curIndex = i
for j in range(0, tentacleBend):
curTentacle.append(tentaclePoints[j][curIndex])
curIndex += tentacleSwirl
if(curIndex >= tentacleNum):
curIndex = curIndex % tentacleNum

print(curTentacle)

#tentacleCross = rs.AddCircle([(1,0,-1),(1,0, -1),(10,-1,-1), (0,1,-1)], 1)