Skip to content

Instantly share code, notes, and snippets.

@nodename
Created July 3, 2010 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nodename/462269 to your computer and use it in GitHub Desktop.
Save nodename/462269 to your computer and use it in GitHub Desktop.
package
{
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Point;
public class LogarithmicSpiralTest extends Sprite
{
public function LogarithmicSpiralTest()
{
var shape:Shape = new Shape();
addChild(shape);
shape.x = shape.y = 200;
shape.graphics.lineStyle(0, 0xff0000, 1.0, true);
plot(shape.graphics);
}
private function plot(canvas:Graphics):void
{
const eightPi:Number = Math.PI * 8;
var interval:Number = Math.PI/20; // this is the space between rays on the Wolfram page
var steps:uint = 160;
var point:Point;
var lastPoint:Point = new Point(0, 0);
canvas.moveTo(lastPoint.x, lastPoint.y);
for (var theta:Number = interval; --steps > -1; theta += interval)
{
point = Point.polar(r(theta), theta);
// flip y for Flash coordinate system:
canvas.lineTo(point.x, -point.y);
lastPoint = point;
}
}
}
}
function r(theta:Number):Number
{
const a:Number = 0.25;
const b:Number = 0.25;
return a * Math.exp(b * theta);
}
@nodename
Copy link
Author

nodename commented Jul 3, 2010

A comment on http://xtyler.com/code/104 asked how to implement the formula at http://mathworld.wolfram.com/LogarithmicSpiral.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment