Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Add Comment
Please, Sign In to add comment