/** * Inverse calculation * * Calculation is done for HR in [bpm] and time is transformed from [s] to [min]. * * @param int $bpm [bpm] * @param int $trimp value to reach */ protected function calculate($bpm, $trimp) { $Factor = new Factor($this->Athlete->gender()); $max = $this->Athlete->knowsMaximalHeartRate() ? $this->Athlete->maximalHR() : Calculator::DEFAULT_HR_MAX; $rest = $this->Athlete->knowsRestingHeartRate() ? $this->Athlete->restingHR() : Calculator::DEFAULT_HR_REST; $hr = max(0, ($bpm - $rest) / ($max - $rest)); $sum = $trimp / ($hr * exp($Factor->B() * $hr)); $this->value = 1 / $Factor->A() * $sum * 60; }
/** * Calculate * * Calculation is done for HR in [bpm] and time is transformed from [s] to [min]. */ protected function calculate() { $Factor = new Factor($this->Athlete->gender()); $max = $this->Athlete->knowsMaximalHeartRate() ? $this->Athlete->maximalHR() : self::DEFAULT_HR_MAX; $rest = $this->Athlete->knowsRestingHeartRate() ? $this->Athlete->restingHR() : self::DEFAULT_HR_REST; $sum = 0; $B = $Factor->B(); foreach ($this->Data as $bpm => $t) { $hr = max(0, ($bpm - $rest) / ($max - $rest)); $sum += $t / 60 * $hr * exp($B * $hr); } $this->value = $Factor->A() * $sum; }
public function testAllProperties() { $Gender = new Gender(); $Gender->set(Gender::MALE); $Athlete = new Athlete($Gender, 210, 45, 70, 25, 60); $this->assertTrue($Athlete->knowsGender()); $this->assertTrue($Athlete->knowsMaximalHeartRate()); $this->assertTrue($Athlete->knowsRestingHeartRate()); $this->assertTrue($Athlete->knowsAge()); $this->assertTrue($Athlete->knowsWeight()); $this->assertTrue($Athlete->knowsVDOT()); $this->assertEquals($Gender, $Athlete->gender()); $this->assertEquals(210, $Athlete->maximalHR()); $this->assertEquals(45, $Athlete->restingHR()); $this->assertEquals(70, $Athlete->weight()); $this->assertEquals(25, $Athlete->age()); $this->assertEquals(60, $Athlete->vdot()); }
/** * Value in [%HRrest] * @return int */ public function inHRrest() { return round(100 * ($this->value - $this->Athlete->restingHR()) / ($this->Athlete->maximalHR() - $this->Athlete->restingHR())); }