[Closed] Braid algorithm
This is the well-known ‘braid’ algorithm:
x(t) = a * sin(t)
y(t) = b * sin(t) * cos(t)
if you need three strand just add phase offset 120 (360/3)
Does anyone known another ‘braid’ algorithms? thanks…
This doesn’t help you but as can be seen here…I couldn’t read maxscript…so my algo was zig and zag
http://www.scriptspot.com/3ds-max/mcg/mcg-braidgen
no limit to number of strands…
Thank you. I’ve seen it already. It’s not really a braid and a things I’m looking for…
Some years ago I saw a ‘braid’ – like spline algorithm based on Lissajous curves, but unfortunately can’t find it anymore
first is i’m not interested in a encrypted script. second is it’s not a ‘braid’ at all. it’s a simple helix algorithm
Not sure if this is useful to your needs, but long ago I made this function to generate sort of a braid like pattern. It was for a very specific case so I hardcoded the numbers that worked for me.
(
	delete objects
	
	theSpline = splineShape ()
	addnewSpline theSpline
	theSpline.steps = 6
	theSpline.wireColor = yellow
	
	width = 100
	
	for i=1 to width-2 do
	(
		u = i*10
		
		x = (6 * sin (u*6) + i) * .5
		y = 2 * cos (u*3)
		z = 10 * sin (u*3)
		
		addKnot theSpline 1 #smooth #curve [x,y,z]
	)
	
	updateShape theSpline
)
Here’s is a really good web for curves (in French):
 https://www.mathcurve.com/courbes3d/lissajous3d/lissajous3d.shtml 
Click on the bottom box “courbe suivante” for access to new curves.
(
	delete objects
	
	theSpline = splineShape ()
	addnewSpline theSpline
	theSpline.steps = 6
	theSpline.wireColor = yellow
	
	ee = 0.1
	
	for t = pi-ee to 115.55*pi+ee by ee do
	(
		x = 3*sin(t)+2*sin(3*t)
		y = cos(t)-2*cos(3*t)
		z = 0.2*(cos(t)+2*sin(4*t))
		
		--addKnot theSpline 1 #smooth #curve [-x,y,z]
		addKnot theSpline 1 #smooth #curve [x,y,z]
	)
	
	updateShape theSpline
)
And this other one, more near a braid:   
 
(
	delete objects
	
	theSpline = splineShape ()
	addnewSpline theSpline
	theSpline.steps = 6
	theSpline.wireColor = yellow
	
	ee = 0.1
	
	for t = pi-ee to 115.55*pi+ee by ee do
	(
		x = 10. * cos(3.*t)
		y = 10. * sin(5.*t)
		z = 1. * sin(22.*t)
		
		addKnot theSpline 1 #smooth #curve [x,y,z]
	)
	
	updateShape theSpline
)
Looks very promising!
here is what i have so far with:
—–x = size.x * (cos(t + offset) + 3 * cos(t + offset))
—–y = (sin(t + offset) – 2 * sin(t + offset)) * x
x = size.x * cos(t + offset)
y = sin(t + offset) * x
where
offset = 360.0 * (n_strand – 1) / strands
ps. i’ve edited that… my bad … there is nothing new
here is a snippet for 3,5,7 strands braids:
delete objects
(
	pp = #()
	sp = splineshape()
	radius = 3
	size = [16,4,0.4,0.4]
	strands = 5
	accuracy = 90
	for k=1 to strands do
	(
		offset = 360.0 * (k-1)/strands
		pp = #()
		for t = 0 to 720 by (180 / accuracy) do
		(
			x = size.x * cos(t + offset)
			y = sin(t + offset) * x
			z = size.z * t
				
			append pp [x,y,z]
		)
		addnewspline sp
		for p in pp do addknot sp k #smooth #curve p
	)
	updateshape sp
	
	sp.render_displayRenderMesh = on
	sp.sides = 6
	sp.thickness = radius*2
	sp
)
