Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


fix Body.getVelAtPoint etc and (hopefully) Body.eachConstraint #9

merged 1 commit into from

2 participants

Tom Novelli Jeremy Apthorp
Tom Novelli

BTW, I don't have any code to test .eachConstraint... in the C version I see func(body, constraint, data); but in your port it's func(constraint); -- should that be ? Gahhh, OO strikes again...

Jeremy Apthorp

Nope, just func(constraint). The rest of the information will be available in the closure of func, because JavaScript is awesome and has closures.

Jeremy Apthorp nornagon merged commit d0a855b into from
Jeremy Apthorp

PS thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/cpBody.js
8 lib/cpBody.js
@@ -292,19 +292,19 @@ Body.prototype.applyImpulse = function(j, r)
Body.prototype.getVelAtPoint = function(r)
- return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), body.w));
+ return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), this.w));
/// Get the velocity on a body (in world units) at a point on the body in world coordinates.
Body.prototype.getVelAtWorldPoint = function(point)
- return this.getVelAtPoint(vsub(point, body.p));
+ return this.getVelAtPoint(vsub(point, this.p));
/// Get the velocity on a body (in world units) at a point on the body in local coordinates.
Body.prototype.getVelAtLocalPoint = function(point)
- return this.getVelAtPoint(vrotate(point, body.rot));
+ return this.getVelAtPoint(vrotate(point, this.rot));
Body.prototype.eachShape = function(func)
@@ -318,7 +318,7 @@ Body.prototype.eachConstraint = function(func)
var constraint = this.constraintList;
while(constraint) {
- var next =;
+ var next =;
constraint = next;
Something went wrong with that request. Please try again.