A class that stores temperature information, and allows conversion between different units. More...
#include <Temperature.hh>
Public Member Functions | |
Temperature () | |
Default constructor. | |
Temperature (const double _temp) | |
Kelvin value constructor. | |
Temperature (const Temperature &_temp) | |
Copy constructor. | |
virtual | ~Temperature () |
Destructor. | |
double | Celsius () const |
Get the temperature in Celsius. | |
double | Fahrenheit () const |
Get the temperature in Fahrenheit. | |
double | Kelvin () const |
Get the temperature in Kelvin. | |
bool | operator!= (const double _temp) const |
Inequality to operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator!= (const Temperature &_temp) const |
Inequality to operator. | |
double | operator() () const |
Accessor operator. | |
Temperature | operator* (const double _temp) |
Multiplication operator. | |
Temperature | operator* (const Temperature &_temp) |
Multiplication operator. | |
const Temperature & | operator*= (const double _temp) |
Multiplication assignment operator. | |
const Temperature & | operator*= (const Temperature &_temp) |
Multiplication assignment operator. | |
Temperature | operator+ (const double _temp) |
Addition operator. | |
Temperature | operator+ (const Temperature &_temp) |
Addition operator. | |
const Temperature & | operator+= (const double _temp) |
Addition assignment operator. | |
const Temperature & | operator+= (const Temperature &_temp) |
Addition assignment operator. | |
Temperature | operator- (const double _temp) |
Subtraction operator. | |
Temperature | operator- (const Temperature &_temp) |
Subtraction operator. | |
const Temperature & | operator-= (const double _temp) |
Subtraction assignment operator. | |
const Temperature & | operator-= (const Temperature &_temp) |
Subtraction assignment operator. | |
Temperature | operator/ (const double _temp) |
Division operator. | |
Temperature | operator/ (const Temperature &_temp) |
Division operator. | |
const Temperature & | operator/= (const double _temp) |
Division assignment operator. | |
const Temperature & | operator/= (const Temperature &_temp) |
Division assignment operator. | |
bool | operator< (const double _temp) const |
Less than operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator< (const Temperature &_temp) const |
Less than to operator. | |
bool | operator<= (const double _temp) const |
Less than or equal operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator<= (const Temperature &_temp) const |
Less than or equal to operator. | |
Temperature & | operator= (const double _temp) |
Assignment operator. | |
Temperature & | operator= (const Temperature &_temp) |
Assignment operator. | |
bool | operator== (const double _temp) const |
Equal to operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator== (const Temperature &_temp) const |
Equal to operator. | |
bool | operator> (const double _temp) const |
Greater than operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator> (const Temperature &_temp) const |
Greater than operator. | |
bool | operator>= (const double _temp) const |
Greater than equal operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator>= (const Temperature &_temp) const |
Greater than or equal to operator. | |
void | SetCelsius (const double _temp) |
Set the temperature from a Celsius value. | |
void | SetFahrenheit (const double _temp) |
Set the temperature from a Fahrenheit value. | |
void | SetKelvin (const double _temp) |
Set the temperature from a Kelvin value. | |
Static Public Member Functions | |
static double | CelsiusToFahrenheit (const double _temp) |
Convert Celsius to Fahrenheit. | |
static double | CelsiusToKelvin (const double _temp) |
Convert Celsius to Kelvin. | |
static double | FahrenheitToCelsius (const double _temp) |
Convert Fahrenheit to Celsius. | |
static double | FahrenheitToKelvin (const double _temp) |
Convert Fahrenheit to Kelvin. | |
static double | KelvinToCelsius (const double _temp) |
Convert Kelvin to Celsius. | |
static double | KelvinToFahrenheit (const double _temp) |
Convert Kelvin to Fahrenheit. | |
A class that stores temperature information, and allows conversion between different units.
This class is mostly for convenience. It can be used to easily convert between temperature units and encapsulate temperature values.
The default unit is Kelvin. Most functions that accept a double value will assume the double is Kelvin. The exceptions are a few of the conversion functions, such as CelsiusToFahrenheit. Similarly, most doubles that are returned will be in Kelvin.
double celsius = ignition::math::Temperature::KelvinToCelsius(2.5);
ignition::math::Temperature temp(123.5); std::cout << "Temperature in Kelvin = " << temp << std::endl; std::cout << "Temperature in Celsius = " << temp.Celsius() << std::endl; temp += 100.0; std::cout << "Temperature + 100.0 = " << temp << "K" << std::endl; ignition::math::Temperature newTemp(temp); newTemp += temp + 23.5; std::cout << "Copied the temp object and added 23.5K. newTemp = " << newTemp.Fahrenheit() << "F" << std::endl;
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Temperature | ( | ) |
Default constructor.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Temperature | ( | const double | _temp | ) |
Kelvin value constructor.
This is a conversion constructor
[in] | _temp | Temperature in Kelvin |
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Temperature | ( | const Temperature & | _temp | ) |
Copy constructor.
[in] | _temp | Temperature object to copy. |
|
virtual |
Destructor.
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Celsius | ( | ) | const |
Get the temperature in Celsius.
|
static |
Convert Celsius to Fahrenheit.
[in] | _temp | Temperature in Celsius |
|
static |
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Fahrenheit | ( | ) | const |
Get the temperature in Fahrenheit.
|
static |
Convert Fahrenheit to Celsius.
[in] | _temp | Temperature in Fahrenheit |
|
static |
Convert Fahrenheit to Kelvin.
[in] | _temp | Temperature in Fahrenheit |
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::Kelvin | ( | ) | const |
Get the temperature in Kelvin.
|
static |
|
static |
Convert Kelvin to Fahrenheit.
[in] | _temp | Temperature in Kelvin |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator!= | ( | const double | _temp | ) | const |
Inequality to operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator!= | ( | const Temperature & | _temp | ) | const |
Inequality to operator.
[in] | _temp | The temperature to compare |
double ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator() | ( | ) | const |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator* | ( | const double | _temp | ) |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator* | ( | const Temperature & | _temp | ) |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator*= | ( | const double | _temp | ) |
Multiplication assignment operator.
[in] | _temp | Temperature in Kelvin |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator*= | ( | const Temperature & | _temp | ) |
Multiplication assignment operator.
[in] | _temp | Temperature object |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator+ | ( | const double | _temp | ) |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator+ | ( | const Temperature & | _temp | ) |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator+= | ( | const double | _temp | ) |
Addition assignment operator.
[in] | _temp | Temperature in Kelvin |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator+= | ( | const Temperature & | _temp | ) |
Addition assignment operator.
[in] | _temp | Temperature object |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator- | ( | const double | _temp | ) |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator- | ( | const Temperature & | _temp | ) |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator-= | ( | const double | _temp | ) |
Subtraction assignment operator.
[in] | _temp | Temperature in Kelvin |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator-= | ( | const Temperature & | _temp | ) |
Subtraction assignment operator.
[in] | _temp | Temperature object |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator/ | ( | const double | _temp | ) |
Temperature ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator/ | ( | const Temperature & | _temp | ) |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator/= | ( | const double | _temp | ) |
Division assignment operator.
[in] | _temp | Temperature in Kelvin |
const Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator/= | ( | const Temperature & | _temp | ) |
Division assignment operator.
[in] | _temp | Temperature object |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator< | ( | const double | _temp | ) | const |
Less than operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator< | ( | const Temperature & | _temp | ) | const |
Less than to operator.
[in] | _temp | The temperature to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator<= | ( | const double | _temp | ) | const |
Less than or equal operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator<= | ( | const Temperature & | _temp | ) | const |
Less than or equal to operator.
[in] | _temp | The temperature to compare |
Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator= | ( | const double | _temp | ) |
Temperature & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator= | ( | const Temperature & | _temp | ) |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator== | ( | const double | _temp | ) | const |
Equal to operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator== | ( | const Temperature & | _temp | ) | const |
Equal to operator.
[in] | _temp | The temperature to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator> | ( | const double | _temp | ) | const |
Greater than operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator> | ( | const Temperature & | _temp | ) | const |
Greater than operator.
[in] | _temp | The temperature to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator>= | ( | const double | _temp | ) | const |
Greater than equal operator, where the value of _temp is assumed to be in Kelvin.
[in] | _temp | The temperature (in Kelvin) to compare |
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::operator>= | ( | const Temperature & | _temp | ) | const |
Greater than or equal to operator.
[in] | _temp | The temperature to compare |
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::SetCelsius | ( | const double | _temp | ) |
Set the temperature from a Celsius value.
[in] | _temp | Temperature in Celsius |
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::SetFahrenheit | ( | const double | _temp | ) |
Set the temperature from a Fahrenheit value.
[in] | _temp | Temperature in Fahrenheit |
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Temperature::SetKelvin | ( | const double | _temp | ) |
Set the temperature from a Kelvin value.
[in] | _temp | Temperature in Kelvin |