arch after arch

Now how would I go about doing this.
I'm trying to randomly rotate the position of each arc 90 degrees from the previous arch. Trying to make it look like something similar to the image below.

(
	clearlistener()
	delete objects
	local radiusA = 10.0
	local steps = 4
	local knotsPerArch = 6
	local rotAngle = 180.0 / knotsPerArch
	local startPos = [0,0,0]
	local sp = splineShape wirecolor:yellow
	local posArr = #() 
 
	fn shuffleIndexes count = --unique Random order
	(
		list = #() 	
		list.count = count
		for k = 1 to count do 
		(
			i = random 1 k
			list[k] = list[i]
			list[i] = k
		)
		return list
	)
 
	addnewSpline sp
	addKnot sp 1 #corner #curve sp.pos --first knot created at origin
 
	for s = 1 to steps do
	(
		format "Arch: %\n" s
		ids = shuffleIndexes 3
		for k = 2 to knotsPerArch+1 do --skip first knot which is always created at origin
		(							
			calcX = radiusA * cos((k-1) * rotAngle)
			calcY = radiusA * sin((k-1)* rotAngle)
 
			pos = [0,calcX,calcY] + startPos --include nodes matrix
 
			newPos = [pos[ids[1]],pos[ids[2]],pos[ids[3]]]
 
			append posArr pos
 			point pos:newPos size:2 wirecolor:(red/(s as float))
		)
		startPos += [0,(radiusA*2),0]
	)
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

or maybe this

(
	delete objects
	local splKnots = 5, kAngle = 180.0 / (splKnots-1), num = 10, origin = [0,0,0], allArchs = #()
	for s = 1 to num do
	(
		radius = random 5.0 10.0
		spl = splineShape name:(uniqueName "ArcShape") wirecolor:(random [50,50,50] [255,255,255]) pos:origin isSelected:off
		addNewSpline spl		
		for v = 1 to splKnots do
		(	
			calcX = radius * cos((v-1) * kAngle)
			calcY = radius * sin((v-1)* kAngle)
			pos = [calcX,calcY,0]
			if v == 1 do origin -= pos
			addKnot spl 1 #smooth #curve (pos + origin)
		)
		updateShape spl
		origin = getKnotPoint spl 1 (numKnots spl)
		if (cnt = allArchs.count) != 0 do spl.parent = allArchs[cnt]
		append allArchs spl
	)
	angArr = #((EulerAngles 0 90 0),(EulerAngles 0 -90 0),(EulerAngles 90 0 0),(EulerAngles -90 0 0))
	for m = 2 to allArchs.count do (in coordsys parent rotate allArchs[m] angArr[random 1 4])
)

barigazy

JokerMartini's picture

closer ( delete

closer

(
	delete objects
	local columns = 9
	local columnAngle = 180.0 / (columns-1)
	local steps = 6
	local origin = [0,0,0]
	local allArchs = #()
 
	/*Set Vertices*/
	for s = 1 to steps do
	(
		local radius = random 5.0 10.0
		local col = random [150,150,150] [255,255,255]
		local archArr = #()
 
		for v = 1 to columns do
		(									
			calcX = radius * cos((v-1) * columnAngle)
			calcY = radius * sin((v-1)* columnAngle)
 
			pos = [0,calcX,calcY]--include nodes matrix
 
			if v == 1 do origin = [0,0,0] - pos
 
			setPos = pos + origin
 
			p = point pos:setPos size:2 wirecolor:col
			append archArr p
		)
		append allArchs archArr
	)
 
	/*Offset Vertices*/
	clearlistener()
	for a=2 to allArchs.count do
	(
		preArcSet = allArchs[a-1]
		arcSet = allArchs[a]
		calcOffset = arcSet[1].pos - preArcSet[columns].pos
 
		for p in arcSet do
		(
			p.pos -= calcOffset
		)
	)
)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

barigazy's picture

;)

(
	delete objects
	local columns = 9
	local columnAngle = 180.0 / (columns-1)
	local steps = 5
	local origin = [0,0,0]
	local allArchs = #()
 
	/*Set Vertices*/
	for s = 1 to steps do
	(
		local radius = random 5.0 10.0
		local col = random [150,150,150] [255,255,255]
		local archArr = #()
 
		for v = 1 to columns do
		(	
			num = v-1	
			calcX = radius * cos((num) * columnAngle)
			calcY = radius * sin((num)* columnAngle)
 
			pos = [calcX,calcY,0]--include nodes matrix
			if v == 1 do origin -= pos
			setPos = pos + origin
			case of (
				(s == 1 and v == 1): archArr[v] = point pos:setPos size:2 wirecolor:col
				(s > 1 and v == 1): in ((allArchs[s-1])[allArchs[s-1].count]) (archArr[v] = point pos:setPos size:2 wirecolor:col)
				default: in archArr[v-1] (archArr[v] = point pos:setPos size:2 wirecolor:col)
			)
		)
		origin = archArr[columns].pos
		append allArchs archArr
	)
	angArr = #((EulerAngles 0 90 0),(EulerAngles 0 -90 0),(EulerAngles 90 0 0),(EulerAngles -90 0 0))
	for m = 2 to allArchs.count do (in coordsys parent rotate allArchs[m][1] angArr[random 1 4])
)

barigazy

barigazy's picture

Try to create separate arrays

Try to create separate arrays for the every arch points.(multidimensional array)
Then in coordsys of first point in array change transform (rotation) of other points.
Use rotate "about" first point in array. In your examle you have 4 arrays with 6 points.You can to start from last array:
--rotate about point[19] others (21,22,23,24,25)
--then about point[13] others (14..25) etc.

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.