Last active
April 7, 2019 16:34
-
-
Save hungtruong/718f50f48c32b324a2f25a80c78ae46b to your computer and use it in GitHub Desktop.
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
func wattage(for ftp: Int, interval: TimeInterval) -> Int { | |
switch self { | |
case .warmup(duration: let duration, powerLow: let powerLow, powerHigh: let powerHigh): | |
return Int((((interval / duration) * (powerHigh - powerLow)) + powerLow) * Double(ftp)) | |
case .steady(duration: _, power: let power): | |
return Int(power * Double(ftp)) | |
case .intervals(reps: _, onDuration: _, offDuration: _, onPower: _, offPower: _): | |
return 0 | |
case .cooldown(duration: let duration, powerLow: let powerLow, powerHigh: let powerHigh): | |
return Int(((((duration - interval) / duration) * (powerHigh - powerLow)) + powerLow) * Double(ftp)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment