2d-spiral functions. Includes archimedean and logarithmic generic spirals. Useful to draw spiral paths in canvas, svg etc.
Usage
var spiral = ; //paint spiral curve in canvascontext;var center = 50 50;context;for var angle = 0; angle <= MathPI * 4; angle+=001 var coords = ; context;context; //fill spiral sectorcontext;var center = center0 center1;context;for var angle = MathPI * 2; angle <= MathPI * 3; angle+=001 var coords = ; context;context;for var angle = MathPI * 5; angle >= MathPI * 4; angle-=001 var coords = ; context;context;context;
API
//include the whole module (logarithmic spiral by default)var spiral = ; //or include just partvar archimedean = ;var logarithmic = ; //get coordinates of a spiral point for passed params;
Most of spirals fall into one of two kinds of generic spirals:
//Golden, or fibonacci spiral https://en.wikipedia.org/wiki/Golden_spiral; //Hyperbolic spiral https://en.wikipedia.org/wiki/Hyperbolic_spiral; //Fermat’s spiral https://en.wikipedia.org/wiki/Fermat%27s_spiral; //Lituus https://en.wikipedia.org/wiki/Lituus_(mathematics);