]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/Plugin/Temperature.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Plugin / Temperature.php
1 <?php
2 /**
3  * Phergie
4  *
5  * PHP version 5
6  *
7  * LICENSE
8  *
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
13  *
14  * @category  Phergie
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
20  */
21
22 /**
23  * Performs temperature calculations for other plugins.
24  *
25  * @category Phergie
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
30  */
31 class Phergie_Plugin_Temperature extends Phergie_Plugin_Abstract
32 {
33     /**
34      * Converts a temperature in Celsius to Fahrenheit.
35      *
36      * @param int $temp Temperature in Celsius
37      *
38      * @return int Temperature converted to Fahrenheit
39      */
40     public function convertCelsiusToFahrenheit($temp)
41     {
42         return round(((((int) $temp * 9) / 5) + 32));
43     }
44
45     /**
46      * Converts a temperature in Fahrenheit to Celsius.
47      *
48      * @param int $temp Temperature in Fahrenheit
49      *
50      * @return int Temperature converted to Celsius
51      */
52     public function convertFahrenheitToCelsius($temp)
53     {
54         return round(((((int) $temp - 32) * 5) / 9));
55     }
56
57     /**
58      * Calculates the heat index (i.e. "feels like" temperature) based on
59      * temperature and relative humidity.
60      *
61      * @param int $temperature Temperature in degrees Fahrenheit
62      * @param int $humidity Relative humidity (ex: 68)
63      * @return int Heat index in degrees Fahrenheit
64      */
65     public function getHeatIndex($temperature, $humidity)
66     {
67         $temperature2 = $temperature * $temperature;
68         $humidity2 = $humidity * $humidity;
69         return round(
70             -42.379 +
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)
79         );
80     }
81 }