Guest User

Untitled

a guest
May 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.Graphics;
  4. import flash.display.Shape;
  5. import flash.display.Sprite;
  6. import flash.geom.Point;
  7.  
  8. public class LogarithmicSpiralTest extends Sprite
  9. {
  10. public function LogarithmicSpiralTest()
  11. {
  12. var shape:Shape = new Shape();
  13. addChild(shape);
  14. shape.x = shape.y = 200;
  15. shape.graphics.lineStyle(0, 0xff0000, 1.0, true);
  16. plot(shape.graphics);
  17. }
  18.  
  19. private function plot(canvas:Graphics):void
  20. {
  21. const eightPi:Number = Math.PI * 8;
  22. var interval:Number = Math.PI/20; // this is the space between rays on the Wolfram page
  23.  
  24. var steps:uint = 160;
  25.  
  26. var point:Point;
  27. var lastPoint:Point = new Point(0, 0);
  28.  
  29. canvas.moveTo(lastPoint.x, lastPoint.y);
  30. for (var theta:Number = interval; --steps > -1; theta += interval)
  31. {
  32. point = Point.polar(r(theta), theta);
  33. // flip y for Flash coordinate system:
  34. canvas.lineTo(point.x, -point.y);
  35. lastPoint = point;
  36. }
  37. }
  38. }
  39. }
  40.  
  41. function r(theta:Number):Number
  42. {
  43. const a:Number = 0.25;
  44. const b:Number = 0.25;
  45. return a * Math.exp(b * theta);
  46. }
Add Comment
Please, Sign In to add comment