math: animation(s)


  • sine = opposite / hypotenuse [03]
  • cosine = adjacent / hypotenuse
  • tangent = opposite / adjacent
  • radians = degrees * Math.PI / 180
  • degrees = radians * 180 / Math.PI
  • rotation = Math.atan2(dy,dx) * 180 / Math.PI
  • distance = Math.sqrt(dx*dx + dy*dy);
  • (rotational) vx = speed * Math.cos(angle); [05]
  • (rotational) vy = speed * Math.sin(angle);
  • (rotational) ax = force * Math.cos(angle);
  • (rotational) ay = force * Math.sin(angle);
  • x1 = Math.cos(angle) * x - Math.sin(angle) * y; [10]
  • y1 = Math.cos(angle) * y + Math.sin(angle) * x;
  • distance = Math.sqrt(dx*dx + dy*dy + dz*dz); [15]

assumption(s) -- dx = ms.X - spr.x; dy = ms.Y - spr.y;