/** * Calculate and set adjusted temperature * @param \Runalyze\Data\Weather\WindSpeed $windSpeed * @param \Runalyze\Activity\Temperature $temperature * @param \Runalyze\Activity\Pace $activitySpeed * @param null|\Runalyze\Activity\Pace $activitySpeed * @throws \InvalidArgumentException * @see https://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index */ public function setFrom(WindSpeed $windSpeed, ActivityTemperature $temperature, Pace $activitySpeed = null) { if ($windSpeed->isUnknown() || $temperature->isEmpty()) { throw new \InvalidArgumentException('Wind speed and temperature must be known. Null value(s) given.'); } $kmh = $windSpeed->inKilometerPerHour(); $calc = $temperature->celsius(); if (null !== $activitySpeed) { $kmh = $windSpeed->inKilometerPerHour() + $activitySpeed->asKmPerHour(); } if ($kmh >= 5) { $calc = 13.12 + 0.6215000000000001 * $temperature->celsius() - 11.37 * pow($kmh, 0.16) + 0.3965 * $temperature->celsius() * pow($kmh, 0.16); } $this->AdjustedTemperature = clone $temperature; $this->AdjustedTemperature->set($calc); }