Skip to content

Commit

Permalink
added Constraint.pointAWorld and Constraint.pointBWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Sep 14, 2019
1 parent 94e9614 commit 3c32969
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/constraint/Constraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,32 @@ var Common = require('../core/Common');
}
};

/**
* Returns the world-space position of `constraint.pointA`, accounting for `constraint.bodyA`.
* @method pointAWorld
* @param {constraint} constraint
* @returns {vector} the world-space position
*/
Constraint.pointAWorld = function(constraint) {
return {
x: (constraint.bodyA ? constraint.bodyA.position.x : 0) + constraint.pointA.x,
y: (constraint.bodyA ? constraint.bodyA.position.y : 0) + constraint.pointA.y
};
};

/**
* Returns the world-space position of `constraint.pointB`, accounting for `constraint.bodyB`.
* @method pointBWorld
* @param {constraint} constraint
* @returns {vector} the world-space position
*/
Constraint.pointBWorld = function(constraint) {
return {
x: (constraint.bodyB ? constraint.bodyB.position.x : 0) + constraint.pointB.x,
y: (constraint.bodyB ? constraint.bodyB.position.y : 0) + constraint.pointB.y
};
};

/*
*
* Properties Documentation
Expand Down

0 comments on commit 3c32969

Please sign in to comment.