Skip to content

Instantly share code, notes, and snippets.

@andrewdolce
Last active December 14, 2015 05:59
Show Gist options
  • Save andrewdolce/5039413 to your computer and use it in GitHub Desktop.
Save andrewdolce/5039413 to your computer and use it in GitHub Desktop.
choose turn direction
// Target angle is closest via CW.
var brakeTorque, desiredTorque;
if ( targetAngle < 0 ) {
if ( targetAngle < -Math.PI ) {
console.warn( 'targetAngle < -π: targetAngle =', targetAngle );
}
desiredTorque = maxCW;
brakeTorque = maxCCW;
result.ccw = false;
}
// Target angle is closest via CCW.
else if ( targetAngle > 0 ) {
if ( targetAngle > Math.PI ) {
console.warn( 'targetAngle > π: targetAngle =', targetAngle );
}
desiredTorque = maxCCW;
brakeTorque = maxCW;
result.ccw = true;
}
result.angle = targetAngle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment