GE Lua Documentation

Press F to search!

smoothmin

Definition


-- @/lua/common/mathlib.lua:1216

function smoothmin(a, b, k)
  k = k or 0.1
  local h = max(min(0.5+(b-a)/k, 1), 0)
  return h*a + (1-h) * (b - h*k*0.5)
end

Callers

@/lua/common/mathlib.lua
function smoothmax(a, b, k)
  return smoothmin(a, b, -k)
end
@/lua/vehicle/powertrain/combustionEngine.lua
  --blend pure throttle with the constant power map
  local throttleMap = smoothmin(max(throttle + throttle * device.maxPowerThrottleMap / (torque * device.forcedInductionCoef * engineAV + 1e-30) * (1 - throttle), 0), 1, (1 - throttle) * 0.8) --0.8 can be tweaked to reduce he peakiness of the throttlemap adjusted torque curve