Reputation: 107
I'm trying to calculate the torque in a java program but I having some problems on how to convert the formula to code
and here is my code:
torque = CYLINDER_LOAD_FACTOR * ( ( Math.pow( (displacement / numberOfCylinders), 2) * Math.exp(TORQUE_CONSTANT) * 0.59 ) );
Upvotes: 1
Views: 251
Reputation: 405955
This entire expression should be raised to the power of 0.59,
( Math.pow( (displacement / numberOfCylinders), 2) * Math.exp(TORQUE_CONSTANT) )
but you're multiplying by that amount. Try the following:
torque = CYLINDER_LOAD_FACTOR * Math.pow( Math.pow( (displacement / numberOfCylinders), 2) * Math.exp(TORQUE_CONSTANT), 0.59 );
Upvotes: 2