move
this.move = function(dt)
{
var t, a, c, dtdt;
dtdt = dt * dt;
a = this.force.getX() / this.mass;
c = this.cur.getX();
t = (2.0 - this.friction) * c - (1.0 - this.friction) * this.prev.getX() + a * dtdt;
this.prev.setX(c);
this.cur.setX(t);
a = this.force.getY() / this.mass;
c = this.cur.getY();
t = (2.0 - this.friction) * c - (1.0 - this.friction) * this.prev.getY() + a * dtdt;
this.prev.setY(c);
this.cur.setY(t);
}
this.setFriction = function(friction)
{
this.friction = friction;
}
this.getVelocity = function()
{
var cXpX, cYpY;
cXpX = this.cur.getX() - this.prev.getX();
cYpY = this.cur.getY() - this.prev.getY();
return cXpX * cXpX + cYpY * cYpY;
}
this.draw = function(ctx, scaleFactor)
{
ctx.lineWidth = 2;
ctx.fillStyle = '#000000';
ctx.strokeStyle = '#000000';
ctx.beginPath();
ctx.arc(this.cur.getX() * scaleFactor,
this.cur.getY() * scaleFactor,
4.0, 0.0, Math.PI * 2.0, true);
ctx.fill();
}
}