Astroid Pedal Curve Variation

Actionscript:
  1. var xp:Number = 0;
  2. var yp:Number = 0;
  3. var t:Number = 0;
  4. var r:Number = 200;
  5. x = stage.stageWidth / 2;
  6. y = stage.stageHeight / 2;
  7.  
  8. graphics.lineStyle(0,0x000000);
  9. addEventListener(Event.ENTER_FRAME, onRun);
  10. function onRun(evt:Event):void {
  11.     r = 200 * Math.cos(t / 10);
  12.     xp = r * Math.pow(Math.cos(t), 3);
  13.     yp = r * Math.pow(Math.sin(t), 3);
  14.     if (t == 0){
  15.       graphics.moveTo(xp, yp);
  16.     }else{
  17.       graphics.lineTo(xp, yp);
  18.     }
  19.     t += 0.1;
  20. }

While browsing mathworld I decided to do a variation on this curve . The above snippet will draw something like this:

This entry was posted in Math, misc and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*