Last active
December 14, 2015 05:59
-
-
Save andrewdolce/5039413 to your computer and use it in GitHub Desktop.
choose turn direction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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