Last active
December 16, 2018 14:31
-
-
Save bali182/de8ee51afb3a97415c9f8cb8025ec6f6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export class OneRepMaxCalculator { | |
private readonly weight: number | |
private readonly repetitions: number | |
private readonly smallestPlate: number | |
constructor(weight: number, repetitions: number, smallestPlate: number = 5) { | |
this.weight = weight | |
this.repetitions = repetitions | |
this.smallestPlate = smallestPlate | |
} | |
private toSmallestPlate(weight: number): number { | |
const roundedWeight = Math.round(weight) | |
const { smallestPlate } = this | |
if (roundedWeight % smallestPlate === 0) { | |
return roundedWeight | |
} | |
const fullSmallestPlate = Math.floor(roundedWeight / smallestPlate) | |
const differenceA = roundedWeight - fullSmallestPlate * smallestPlate | |
const differenceB = smallestPlate - differenceA | |
if (differenceA < smallestPlate / 2) { | |
return roundedWeight - differenceA | |
} else { | |
return roundedWeight + differenceB | |
} | |
} | |
epley(): number { | |
return this.toSmallestPlate(this.weight * (1 + this.repetitions / 30)) | |
} | |
brzycki(): number { | |
return this.toSmallestPlate(this.weight * (36 / (37 - this.repetitions))) | |
} | |
mcGlothin(): number { | |
return this.toSmallestPlate((100 * this.weight) / (101.3 - 2.67123 * this.repetitions)) | |
} | |
lombardi(): number { | |
return this.toSmallestPlate(this.weight * Math.pow(this.repetitions, 0.1)) | |
} | |
oConner(): number { | |
return this.toSmallestPlate(this.weight * (1 + this.repetitions / 40)) | |
} | |
average(): number { | |
return this.toSmallestPlate( | |
(this.epley() + this.brzycki() + this.mcGlothin() + this.lombardi() + this.oConner()) / 5 | |
) | |
} | |
} | |
const calc = new OneRepMaxCalculator(100, 6) | |
console.log('epley', calc.epley()) | |
console.log('brzycki', calc.brzycki()) | |
console.log('mcGlothin', calc.mcGlothin()) | |
console.log('lombardi', calc.lombardi()) | |
console.log('oConner', calc.oConner()) | |
console.log('average', calc.average()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment