trig.flx

Animation flash

trig.flx
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

P f(double x, double t)
{
  return P(2*(1+x), Sin(x+t));
}

domain R(P(0,0), P(1,1), mesh(60,24), mesh(120, 72));

int main(int argc, char* argv[])
{
  if (argc == 3)
    {
      char* arg;
      double temp1, temp2;
      temp1=strtod(argv[1], &arg);
      temp2=strtod(argv[2], &arg);

      tix=temp1/temp2;
    }

  bounding_box(P(-1.1,-1.1),P(1.1,1.1));
  unitlength("1in");
  picture(P(2,2));

  begin();
  revolutions();

  rgb(0.9,0.9,0.9);

  grid(1,1);
  black();
  crop();

  P ctr=polar(0.5,tix);
  P rim=polar(0.5,tix)+polar(0.5,-tix);
  P rim2=polar(0.5,tix)+polar(0.5,0.5-tix);

  ellipse(ctr, P(0.5,0.5)); // small wheel

  bold();
  ellipse(P(0,0), P(1,1)); // big wheel

  green();
  line(P(1,0), P(-1,0));

  blue();
  line(P(0,1), P(0,-1));

  red();
  line(ctr,rim);
  line(ctr,rim2);

  ddot(rim);
  ddot(rim2);

  blue();
  crop_box(P(2,-1), P(4,1));
  plot(f, R.slice2(tix));

  crop(false);
  dashed();
  pen(0.15);
  line(P(0,Sin(tix)), f(0,tix));

  end();
}