copperpen, on 05 September 2013 - 03:57 AM, said:
In the SteamLocomotive.cs there is a line dealing with steam usage
SteamUsageFactor = 2 * NumCylinders * 3.281f * CylinderDiameterM / 2 * 3.281f * CylinderDiameterM / 2 * 3.281f * CylinderStrokeM / (2 * DriverWheelRadiusM)
There's a rather obvious error in this formula: Every value is converted from metric to feet except for DriversWheelRadiusM - which is in meters (hence the "m".
In addition, each cylinder fills twice and makes 2 power strokes for every revolution of the wheel. Is that why there's a 2 * before DriverWheelRadiusM?
I think that this could be much better written, much more clearly:
And the formula for the volume of a cylinder is PI * Radius^2 * Height.
SteamUsageFactor = 4 * (NumCylinders * ( Math.Pi * ( 3.281f * CylinderDiameterM /2 ) * ( 3.281f * CylinderDiameterM / 2 ) ) * ( 3.281f * CylinderStrokeM )) / DriverWheelRadiusM * 3.281f;
And, yes, I know this code won't compile, Math.Pi must be cast...
Robert