20100916

day 16: theta radius


I've been at a symposium today, and not had much food due to a rough morning at home (son had really bad cramp in both legs, poor guy), so brain is tired this evening.
I did manage to write this:

which seems to not work very well on hascanvas.com page, but seems to be ok in the embedded version here and is fine in firefox 4 and in processing &rerr; code below:
float cx, cy, mX, mY, mTheta, mRadius;

void setup()
{
    size(480, 480);
    smooth();

    cx = width/2;
    cy = height/2;
}

void draw() {
  background(222);
  stroke(0);
  fill(123);
  ellipse(mouseX, mouseY, 30, 30);
  
  translate(cx, cy);
  mX = mouseX-cx;
  mY = mouseY-cy;
  mRadius = sqrt(sq(mX)+sq(mY));
  noFill();
  mRadius *= 2;
  ellipse(0,0,mRadius,mRadius);
  mTheta = atan2(mY,mX);
  rotate(mTheta);
  line(0, 0, 345, 0);
}

No comments:

Post a Comment