Definition of divergence in sprial tool?
I am trying to create logarithmic spirals for illustrating many of the spirals in nature, but I am having a hard time translating from the "divergence" to any meaningful factor used to specify the spiral. If Divergence =1 it expands in equal increments, but what is the definition of Divergence = 2 or any other amount? I was hoping it would produce a logarithmic spiral (increasing by the same factor for each turn), but from measurements this does not appear to be the case. Any insight on this?
By the way, if the spiral with divergence >1 is NOT a logarithmic spiral, that feature should be added. In a logarithmic spiral the angle between the radius and the tangent line at any point on the spiral is a constant. It can be specified mathematically as r = a*e^(k*theta). (It could probably be more correctly described as an exponential spiral.)
--David Chandler
I experimented with the Inkscape spiral tool (set to divergence = 10) and compared it to a logarithmic spiral generated with The Geometer's Sketchpad. (see image) The two horizontal lines at the bottom are "sliders" to adjust the two constants: k, which controls the rate of expansion of the spiral, and a, which is just a scale factor. I was able to import an image created with Inkscape and superimpose the computed spiral. Interestingly, I was able to get the two curves to match for over a full turn, but then they diverged. No combination of settings for k and a were able to make the curves match in both the inner and outer parts of the curve. This tells me that something is a little strange in the inkscape tool. Perhaps an approximate algorithm is being used that does a piecewise approximation to a logarithmic spiral. I would like to hear from whoever created the tool or anyone else who understands the math used to create it. http://www.nabble.com/file/6223/Clip1.gif
--David Chandler
On 2/2/07, David Chandler <david@...2097...> wrote:
I am trying to create logarithmic spirals for illustrating many of the spirals in nature, but I am having a hard time translating from the "divergence" to any meaningful factor used to specify the spiral. If Divergence =1 it expands in equal increments, but what is the definition of Divergence = 2 or any other amount? I was hoping it would produce a logarithmic spiral (increasing by the same factor for each turn), but from measurements this does not appear to be the case. Any insight on this?
First of all, Inkscape's spirals will never be mathematically perfect. We can only use Bezier curves, and what we do is just calculate a number of points along a spiral and then use our standard Bezier fitter which returns a path that is smooth and goes through these points. We can improve the precision by spacing the points tighter, but it will still be an approximation.
Now, as for the points themselves, they obey a power law. You can see it for yourself in sp-spiral.cpp, function sp_spiral_get_xy:
http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/sp-sp...
Here's the relevant calculation that converts the argument t to the point on spiral:
double const rad = spiral->rad * pow(t, (double) spiral->exp); double const arg = 2.0 * M_PI * spiral->revo * t + spiral->arg;
return NR::Point(rad * cos (arg) + spiral->cx, rad * sin (arg) + spiral->cy);
I see no problem adding other kinds of spiral, although we cannot change this default one because that would cause a sudden change in all the spirals people have created with Inkscape so far. But we can add a switch to the toolbar that would select from power, logarithmic, or any other kind of spiral.
If you're interested in working on that, I can give you detailed directions. If not, you can just add it to the RFE tracker in the hope that someone will get inspired by it one day :)
participants (2)
-
bulia byak
-
David Chandler