@ -143,22 +143,25 @@ namespace Simulator {
let outing : Outing = { distance : 0 , ascendingElevation : 0 } ;
let consumption : ConsumptionData = { motorEnergy : 0 , humanEnergy : 0 , averageSpeed : 0 } ;
let resetConsumption = function ( outConsumption : ConsumptionData ) {
consumption . motorEnergy = 0 ; consumption . humanEnergy = 0 ; consumption . averageSpeed = 0 ;
} ;
let flatTerrainRatio = MathUtils . clamp ( planning . flatTerrainRatio , 0.0 , 1.0 ) ;
if ( planning . dailyAscendingElevation <= 0 ) flatTerrainRatio = 1.0 ;
let flatDistance = planning . dailyDistance * flatTerrainRatio ;
consumption = { motorEnergy : 0 , humanEnergy : 0 , averageSpeed : 0 } ;
resetConsumption ( consumption ) ;
vehicle . consumption ( flatDistance , 0 , consumption ) ;
result . flatTerrainSpeed = consumption . averageSpeed ;
let uphillDistance = planning . dailyDistance * ( 1.0 - flatTerrainRatio ) * 0.5 ;
consumption = { motorEnergy : 0 , humanEnergy : 0 , averageSpeed : 0 } ;
resetConsumption ( consumption ) ;
vehicle . consumption ( uphillDistance , planning . dailyAscendingElevation , consumption ) ;
result . uphillSpeed = consumption . averageSpeed ;
let downhillDistance = planning . dailyDistance * ( 1.0 - flatTerrainRatio ) * 0.5 ;
consumption = { motorEnergy : 0 , humanEnergy : 0 , averageSpeed : 0 } ;
resetConsumption ( consumption ) ;
vehicle . consumption ( downhillDistance , - planning . dailyAscendingElevation , consumption ) ;
result . downhillSpeed = consumption . averageSpeed ;
@ -174,8 +177,7 @@ namespace Simulator {
planning . getOuting ( day % 7 , hour , outing ) ;
consumption . motorEnergy = 0 ; consumption . humanEnergy = 0 ; consumption . averageSpeed = 0 ;
resetConsumption ( consumption ) ;
vehicle . consumption ( outing . distance * flatTerrainRatio , 0 , consumption ) ;
vehicle . consumption ( outing . distance * ( 1.0 - flatTerrainRatio ) * 0.5 , outing . ascendingElevation , consumption ) ;
vehicle . consumption ( outing . distance * ( 1.0 - flatTerrainRatio ) * 0.5 , - outing . ascendingElevation , consumption ) ;