public
Created

  • Download Gist
LogarithmicSpiralTest.as
ActionScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
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);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.