Skip to content

Instantly share code, notes, and snippets.

@andrewdolce
Last active December 14, 2015 05:59
Show Gist options
  • Save andrewdolce/5039263 to your computer and use it in GitHub Desktop.
Save andrewdolce/5039263 to your computer and use it in GitHub Desktop.
calculateThrusterValues() function
MLTS.prototype.calculateThrusterValues = function() {
this.maxForward = 0;
this.maxBackward = 0;
this.maxRight = 0;
this.maxLeft = 0;
this.maxCCW = 0;
this.maxCW = 0;
this.model.thrusters.forEach(function( thruster ) {
if ( thruster.isAttached ) {
var eps = 0;
this.maxForward += thruster.localForce[0] > eps ? thruster.localForce[0] : 0;
this.maxRight += thruster.localForce[1] > eps ? thruster.localForce[1] : 0;
this.maxBackward += thruster.localForce[0] < -eps ? -thruster.localForce[0] : 0;
this.maxLeft += thruster.localForce[1] < -eps ? -thruster.localForce[1] : 0;
this.maxCCW += thruster.torque > eps ? thruster.torque : 0;
this.maxCW += thruster.torque < -eps ? -thruster.torque : 0;
}
}, this );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment