I’ve got a particular curve that I would like to have a function for. It’s an outward spiral on the left hand side, and it crosses over to an inward spiral on the right hand side. It’s further stretched along z, with the inner tips of the spirals forming the apex of the cones. Kind of like a (spiral) bra. Any software that will assist me in finding such a function, or does anyone know of one?
What you’re looking for is regression software, but I am not aware of any that will deal with graphical input, much less 3D. Most will take in a set of data points and will do a curve fit for a specific type of curve (I think even Microsoft Excel can do that). However, I am not sure what you describe is even a function, much less a polynomial one, which makes finding a curve exceedingly difficult.
What you could do if you have access to a 3D graphics package that supports some sort of splines, like NURBS. Approximately model your curve using splines and then export the spline data in some text readable format. Figure out the math behind the particular type of splines the package used, and you’ve got yourself a set of piecewise polynomial curves representing your spiral.
There are certainly functions that would do what you describe. I don’t think you want regression software. I think you just want to be able to play with functions and look at their graphs until you like what you see.
Also, it sounds like you want to create a dextral spiral and a sinestral spiral, and join them together on the outside.
It might be easier to think of the function you want by looking at only one half, say the right half. Let your curve start at the origin and begin with a slope of 1. Then, it starts spiraling inward toward the point (1,0). So next you take the reflection of this curve. That is, every (x,y) point you have, also create the point (-x,-y).
As Napier says, this is more a matter of starting with functions you understand and changing them to get what you want. For example, you can get a spiral curve evenly spaced around a cone with
(x,y,z) = ((1-t)sin(g t),-(1-t)cos(g t),t) , t in [0,1],
where larger values of g make the curve wrap more times around the cone. Something like this makes a reasonable choice for half of your curve. If you want to join it to a spiral going in the opposite direction, it is useful to know some functions that act like smooth sign functions. One of these is tanh(t), though there are lots of others. Now I’d like to displace the above curve along x, so that the apex of the cones are at (±a,0,1) say. This gives
(x,y,z) = ( tanh(gt)(a + (1-t[sup]2[/sup])sin(g t[sup]2[/sup])),-(1-t[sup]2[/sup])cos(g t[sup]2[/sup]),t[sup]2[/sup] ) , t in [-1,+1].
This looks complicated, but all I’ve done is displace the curve by (a,0,0), replace t by t[sup]2[/sup] in the first equation (giving two copies of the same parametric curve, one for t in [-1,0] and one for t in [0,+1]) and then multiply the x coordinate by a tanh function so that one of the copies is reflected in the yz plane.
Oh, and I forgot: Reasonable starting choices might be a=1.2, g=50.
Thanks guys. I will play with this in Matlab when I get some time and post pics if I find it.
Based on such a bad (incorrect even) description, that’s a pretty impressive curve. Here’s the function, the plot and the reference image.
And the Matlab source code:
a=1.5;g=35;t=-1:.0001:1;plot3(tanh(g.*t).*(a+(1-t.^2).*sin(g.*t.^2)),-(1-t.^2).*cos(g.*t.^2),t.^2)
Ah, the photo has both spirals curving in the same sense (180° rotation symmetry, not bilateral reflection symmetry). In that case, try something like
(x,y,z) = ( tanh(gt)(a + (1-t[sup]2[/sup])sin(g t[sup]2[/sup]-b)),tanh(gt)(1-t[sup]2[/sup])cos(g t[sup]2[/sup]-b),t[sup]2[/sup] )
with b=1 or so. (This adds a tanh factor in y to flip one of the spirals; the additional phase is needed to make the two spirals meet relatively cleanly.)
Oh, and doing an “axis equal” in Matlab will make the curve look less squashed, too.
Here’s the function, the plot , the reference image and source code:
a=1.2;g=20;b=1;t=-1:.0001:1;h=plot3(tanh(g.*t).*(a+(1-t.^2).*sin(g.*t.^2-b)),tanh(g.*t).*(1-t.^2).*cos(g.*t.^2)-b,t.^2);axis equal;grid on;
This is undoubtedly the best GQ answer I’ve seen. Thanks Omphaloskeptic
A bug in my source code above. -b should have been inside the cosine. Here’s the best one yet.
Thought you might find this fractal that I stumbled upon in XaoS interesting…