pjz99 opened this issue on Sep 30, 2008 · 17 posts
Have you ever tried to model a braid? I've been looking into how to do this and I found a couple of methods, but they involved manually setting point values for the spline - very nasty stuff and not easy to adjust. I really wanted to do this using the Formula spline to do the heavy lifting. Here's what I came up with.
First, consider the structure of a braid:
This is a Formula spline with default settings. The formula plugged into the Y parameter actually gives us something pretty close to what we are looking for, although its range is only one wave. The formula is: 100.0*Sin(t*pi) I do wish I'd payed attention in my math classes. At any rate it isn't that necessary to have a fundamental understanding of the formula, only what it does. In this case it very conveniently produces a curve that is perfect for this purpose.
Let's expand the range - basically, the period of the wave is extended from a range of -1 / +1, to -5 / +5. Tmin is the value for the start of the curve, and Tmax is the value for the end - so X will range from 100 * -5, or -500, to 100 * 5, or +500, giving us a spline that is 1000 units in size on the x-axis. Unfortunately the spline becomes all jagged - since Samples is still at default, the spline is being drawn with 20 control points, and there is no interpolation going on to smooth the curve. Increase samples or enable Cubic interpolation, or both.
Unfortunately, at this point the curve is strictly two dimensional, and we need to disturb it along the Z-axis in order to create a proper braid. While you could make the spline editable and start pushing and pulling control points, that's very messy. What we need is a formula plugged into the Z parameter of the Formula spline, to make the values of the Z coordinates match the shape we want. The length-wise cross section of a braid is a figure eight - that is, each strand of the braid loops one way, and then the other. I racked my poor atrophied mathbrain and realized that the original sine wave formula already plugged in by default is nearly what we want, with a small change: 100.0*Sin(t*2*pi) This gives us a reasonable figure eight cross section like so.
And here is a simple couple of instances added, with the first instanced moved to x: 333 and the second moved to x: 666. I'm sure there is a mathematical reason why those are the correct values to move the 2nd and 3rd strands to, but my mathbrain is out of gas at this point. IDEALLY, I'd figure out how to modify the formulae for separate 2nd and 3rd strands to do this correctly, or even better, a smarter person would tell me what I should have done. Since my goal is to convert this structure to polygons at some point and weld it onto something else, this is not bad to start with.
Since the whole structure is still parametric, it is very easy to control and adjust - e.g. you want to have a low polygon structure like so. Just make the circle primitive that the SweepNURBS is extruding into an editable spline, and change the point interpolation (Intermediate Points setting) to NONE. Also change the point interpolation settings for the Formula spline. This is a little organic and requires some experimentation depending on the shape you're looking for, to find a smooth enough curve that is still a lower polygon count.
A couple of variations obtained by fiddling with the extrude shape (ellipse instead of circle) and a tweak of the Y parameter of the formula. If we were doing this with setting point values manually this would be a real pain.
Attached Link: http://www.codeworkers.de/reeperx/
Try Reeper plug in :) Tihomir
Open your mind and share the knowledge!
These are the formulae to use if you want the least amount of wasted geometry, although since they're now separate formulae it's harder to adjust the whole structure - even better would be some method of passing values between the separate formula splines, but this is good enough for my purposes.