• 9
• 16
• 15
• 12
• 9

# Braid algorithm

This topic is 2074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, how difficult would it be to create an algorithm that generate a braid like this: http://www.wikihow.com/Braid

I suppose one should compute 3 elicoidal paths for each hair?

##### Share on other sites
My initial impression is that it's just three helices with 120 degrees phase shifts.

edit: Played a bit with it. It's almost three helices: the path for helix n is p[sub]n[/sub](t) = [t, sin(t*2*pi+phi), cos(t*4*pi+2*phi+pi/2)] where phi is 2*n*pi/6. Edited by Brother Bob

##### Share on other sites
You can probably create an initial rough shape with the same topology and then smooth it out while constraining the distances between the three curves (so that you can construct tubes around the curves.

EDIT: This idea can be used to create more general braids. In this case, it's probably also possible to come up with an exact solution. Edited by apatriarca

##### Share on other sites
My wild guess is to use Bezier curves.

It kinda reminds me, when I was a kid, I use to frequent a bakery, their specialty was a braided bread just like that one. Good times...

But anyways, I think you can find something useful out of Bezier curves for this.

Good luck

##### Share on other sites
The path of each strand isn't a helix - when viewed along the length of the braid it's a figure-eight (remember when you make one you always lift the outer strand up before shifting it over back into the braid). So it could be constructed using this equation:

 x(t) = a sin(t) y(t) = a sin(t) cos(t) 

with a 120 degree phase shift for each strand, where t increases along the braid.

##### Share on other sites
Thank you very much for all your suggestions, I'll try to code something next days and show what I can come up with. MrRowl, unfortunately the image with the equation doesn't show, would it be possible for you to post it again? Many thanks

##### Share on other sites
Sorry about that - I guess it was a dynamically created image. I've edited the post now.

##### Share on other sites
Thank you very much MrRowl. Just a clarification, the formula would be:

x(t) = a * sin(t)
y(t) = a * sin(t) * cos(t)

Right? Where a is a constant value to give the braid some dimension.

##### Share on other sites

Right? Where a is a constant value to give the braid some dimension.

Yes.