mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
derive velocity from position in setters
This commit is contained in:
parent
fe985288d6
commit
b6de9ed8c5
1 changed files with 3 additions and 3 deletions
|
@ -549,8 +549,8 @@ var Axes = require('../geometry/Axes');
|
|||
var timeScale = body.deltaTime / Body.timeUnit;
|
||||
body.positionPrev.x = body.position.x - velocity.x * timeScale;
|
||||
body.positionPrev.y = body.position.y - velocity.y * timeScale;
|
||||
body.velocity.x = velocity.x * timeScale;
|
||||
body.velocity.y = velocity.y * timeScale;
|
||||
body.velocity.x = (body.position.x - body.positionPrev.x) / timeScale;
|
||||
body.velocity.y = (body.position.y - body.positionPrev.y) / timeScale;
|
||||
body.speed = Vector.magnitude(body.velocity);
|
||||
};
|
||||
|
||||
|
@ -599,7 +599,7 @@ var Axes = require('../geometry/Axes');
|
|||
Body.setAngularVelocity = function(body, velocity) {
|
||||
var timeScale = body.deltaTime / Body.timeUnit;
|
||||
body.anglePrev = body.angle - velocity * timeScale;
|
||||
body.angularVelocity = velocity * timeScale;
|
||||
body.angularVelocity = (body.angle - body.anglePrev) / timeScale;
|
||||
body.angularSpeed = Math.abs(body.angularVelocity);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue