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 :)