9 * This source file is subject to the new BSD license that is bundled
10 * with this package in the file LICENSE.
11 * It is also available through the world-wide-web at this URL:
12 * http://phergie.org/license
15 * @package Phergie_Plugin_Temperature
16 * @author Phergie Development Team <team@phergie.org>
17 * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18 * @license http://phergie.org/license New BSD License
19 * @link http://pear.phergie.org/package/Phergie_Plugin_Temperature
23 * Performs temperature calculations for other plugins.
26 * @package Phergie_Plugin_Temperature
27 * @author Phergie Development Team <team@phergie.org>
28 * @license http://phergie.org/license New BSD License
29 * @link http://pear.phergie.org/package/Phergie_Plugin_Temperature
31 class Phergie_Plugin_Temperature extends Phergie_Plugin_Abstract
34 * Converts a temperature in Celsius to Fahrenheit.
36 * @param int $temp Temperature in Celsius
38 * @return int Temperature converted to Fahrenheit
40 public function convertCelsiusToFahrenheit($temp)
42 return round(((((int) $temp * 9) / 5) + 32));
46 * Converts a temperature in Fahrenheit to Celsius.
48 * @param int $temp Temperature in Fahrenheit
50 * @return int Temperature converted to Celsius
52 public function convertFahrenheitToCelsius($temp)
54 return round(((((int) $temp - 32) * 5) / 9));
58 * Calculates the heat index (i.e. "feels like" temperature) based on
59 * temperature and relative humidity.
61 * @param int $temperature Temperature in degrees Fahrenheit
62 * @param int $humidity Relative humidity (ex: 68)
63 * @return int Heat index in degrees Fahrenheit
65 public function getHeatIndex($temperature, $humidity)
67 $temperature2 = $temperature * $temperature;
68 $humidity2 = $humidity * $humidity;
71 (2.04901523 * $temperature) +
72 (10.14333127 * $humidity) -
73 (0.22475541 * $temperature * $humidity) -
74 (0.00683783 * $temperature2) -
75 (0.05481717 * $humidity2) +
76 (0.00122874 * $temperature2 * $humidity) +
77 (0.00085282 * $temperature * $humidity2) -
78 (0.00000199 * $temperature2 * $humidity2)