Notifications
Clear all

[Closed] Spiral Tower

Hi

I’ve made a parametrical tower, based on parametrisized curves made of Points.

h=100
  num = 100 -- aantal punten per spiraal
  spNum = 15 -- aantal spiralen 
  for j = 1 to spNum do
  (
  	for i = 1 to num do
  	(
  		shift  = 360/spNum*j
  		Radius = sin ( (100/num*i)+80 ) *15
  		a = cos((360/num*i) + shift)*radius
  		b = sin((360/num*i) + shift)*radius
  		c = h/ num*i
  		Pnt01 = Point pos: [a,b,c] display: box
  	)
  )

The question is how to make a mesh of it and when it’s possible to thicken the structural spirals. Maybe by lattice?

h=100
  num = 100 -- aantal punten per spiraal
  spNum = 15 -- aantal spiralen 
  vert_array = #()
  face_array = #()
  for j = 1 to spNum do
  (
  	for i = 1 to num do
  	(
  		shift  = 360/spNum*j
  		Radius = sin ( (100/num*i)+80 ) *15
  		a = cos((360/num*i) + shift)*radius
  		b = sin((360/num*i) + shift)*radius
  		c = h/ num*i
  		vert_array [i] = [a,b,c] 
  		for v = 1 to 15 do
  		(
  			append face_array [v, v+1, v+99]
  			append face_array [v+1, v+99, v+100]
  		)
  		theMesh = mesh verts: vert_array faces: face_array
  	)
  )

First code works well. The second, i made some mistakes, can somebody correct them?

Thanks in advance!
–D.

2 Replies

Hi Davy,

Here you go!

(
	h			= 45.	-- height
	num			= 20	-- points per spiral
	spNum		= 5		-- number of spirals
	turns		= .5	-- number of complete turns
	radius		= 15.	-- start radius
	autosmooth	= true	-- apply smoothing groups
	weldtop		= true	-- weld top vertices
	
	vert_array = #()
	face_array = #()
	
	v = 0 -- current vertex index
	w = (spNum-1) * num -- see code block at line 23 ( if j == spNum then ... )
	
	for j = 1 to spNum do
	(
		for i = 1 to num do
		(
			shift = 360/spNum*j
			r = sin((100/num*i)+80)*radius
			a = cos((turns*360/num*i)+shift)*r
			b = sin((turns*360/num*i)+shift)*r
			c = h/(num-1)*(i-1)
			
			append vert_array [a,b,c]
			
			v += 1 -- increment vertex counter
			
			if i < num then
			(
				if j == spNum then
				(
					-- connect last spiral to faces on opposite side (first spiral)
					append face_array [v, v-w, v+1]
					append face_array [v-w+1, v+1, v-w]
				)
				else
				(
					append face_array [v, v+num, v+1]
					append face_array [v+num+1, v+1, v+num]
				)
			)
		)
	)
	
	theMesh = mesh vertices:vert_array faces:face_array
	
 	theFaces = face_array.count
	for f = 1 to theFaces do
	(
		-- hide diagonal edges
		setEdgeVis theMesh f 2 false
		-- apply separate smoothing groups to each spiral
 		setFaceSmoothGroup theMesh f (if autosmooth then (2 ^ ((f-1) / ((num-1)*2))) else 0)
	)
	
	-- weld top vertices
	if weldtop then meshop.weldVertSet theMesh (for v = num to (num*spNum) by num collect v)
	
	-- update the mesh to reflect changes
	update theMesh
)

Cheers,
Martijn

Great!
Thank you, Martijn!!!