• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Braid algorithm

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1Alessandro  Members

Posted 13 July 2012 - 02:30 PM

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?

### #2Brother Bob  Moderators

Posted 13 July 2012 - 02:57 PM

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 pn(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, 13 July 2012 - 04:24 PM.

### #3apatriarca  Members

Posted 13 July 2012 - 04:25 PM

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, 13 July 2012 - 05:02 PM.

### #4Acotoz  Members

Posted 14 July 2012 - 12:31 AM

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

### #5MrRowl  Members

Posted 16 July 2012 - 03:37 AM

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.

### #6Alessandro  Members

Posted 19 July 2012 - 10:53 AM

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

### #7MrRowl  Members

Posted 19 July 2012 - 04:27 PM

Sorry about that - I guess it was a dynamically created image. I've edited the post now.

### #8Alessandro  Members

Posted 20 July 2012 - 03:34 AM

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.

### #9MrRowl  Members

Posted 20 July 2012 - 03:46 AM

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

Yes.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.