Fish Curve

Actionscript:
  1. var xp:Number = 0;
  2. var yp:Number = 0;
  3. var t:Number = 0;
  4. var a: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.     xp = a * Math.cos(t) - (a * Math.pow(Math.sin(t),2))/Math.sqrt(2);
  12.     yp = a * Math.cos(t) * Math.sin(t);
  13.     if (t == 0){
  14.       graphics.moveTo(xp, yp);
  15.     }else{
  16.       graphics.lineTo(xp, yp);
  17.     }
  18.     t += 0.05;
  19. }

While surfing mathworld I stumbled upon the equation for something called the Fish Curve. This 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 *

*
*