A class that stores temperature information, and allows conversion between different units. More...
#include <Temperature.hh>
Public Member Functions | |
Temperature () | |
Default constructor. | |
Temperature (double _temp) | |
Kelvin value constructor. This is a conversion constructor, and assumes the passed in value is in Kelvin. | |
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 Temperature &_temp) const |
Inequality to operator. | |
bool | operator!= (double _temp) const |
Inequality to operator, where the value of _temp is assumed to be in Kelvin. | |
double | operator() () const |
Accessor operator. | |
Temperature | operator* (const Temperature &_temp) const |
Multiplication operator. | |
Temperature | operator* (double _temp) const |
Multiplication operator. | |
const Temperature & | operator*= (const Temperature &_temp) |
Multiplication assignment operator. | |
const Temperature & | operator*= (double _temp) |
Multiplication assignment operator. | |
Temperature | operator+ (const Temperature &_temp) const |
Addition operator. | |
Temperature | operator+ (double _temp) const |
Addition operator. | |
const Temperature & | operator+= (const Temperature &_temp) |
Addition assignment operator. | |
const Temperature & | operator+= (double _temp) |
Addition assignment operator. | |
Temperature | operator- (const Temperature &_temp) const |
Subtraction operator. | |
Temperature | operator- (double _temp) const |
Subtraction operator. | |
const Temperature & | operator-= (const Temperature &_temp) |
Subtraction assignment operator. | |
const Temperature & | operator-= (double _temp) |
Subtraction assignment operator. | |
Temperature | operator/ (const Temperature &_temp) const |
Division operator. | |
Temperature | operator/ (double _temp) const |
Division operator. | |
const Temperature & | operator/= (const Temperature &_temp) |
Division assignment operator. | |
const Temperature & | operator/= (double _temp) |
Division assignment operator. | |
bool | operator< (const Temperature &_temp) const |
Less than to operator. | |
bool | operator< (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 or equal to operator. | |
bool | operator<= (double _temp) const |
Less than or equal operator, where the value of _temp is assumed to be in Kelvin. | |
Temperature & | operator= (double _temp) |
Assignment operator. | |
bool | operator== (const Temperature &_temp) const |
Equal to operator. | |
bool | operator== (double _temp) const |
Equal to operator, where the value of _temp is assumed to be in Kelvin. | |
bool | operator> (const Temperature &_temp) const |
Greater than operator. | |
bool | operator> (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 or equal to operator. | |
bool | operator>= (double _temp) const |
Greater than equal operator, where the value of _temp is assumed to be in Kelvin. | |
void | SetCelsius (double _temp) |
Set the temperature from a Celsius value. | |
void | SetFahrenheit (double _temp) |
Set the temperature from a Fahrenheit value. | |
void | SetKelvin (double _temp) |
Set the temperature from a Kelvin value. | |
Static Public Member Functions | |
static double | CelsiusToFahrenheit (double _temp) |
Convert Celsius to Fahrenheit. | |
static double | CelsiusToKelvin (double _temp) |
Convert Celsius to Kelvin. | |
static double | FahrenheitToCelsius (double _temp) |
Convert Fahrenheit to Celsius. | |
static double | FahrenheitToKelvin (double _temp) |
Convert Fahrenheit to Kelvin. | |
static double | KelvinToCelsius (double _temp) |
Convert Kelvin to Celsius. | |
static double | KelvinToFahrenheit (double _temp) |
Convert Kelvin to Fahrenheit. | |
Detailed Description
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.
Examples
- C++ #include <stdio.h>#include <gz/math/Temperature.hh>{printf("2.5Kelvin to Celsius is %f\n", celsius);gz::math::Temperature temp(123.5);printf("Constructed a Temperature object with %f Kelvin\n", temp());printf("Same temperature in Celsius %f\n", temp.Celsius());temp += 100.0;printf("Temperature + 100.0 is %fK\n", temp());printf("Copied the temp object and added 23.5K. The new tempurature is %fF\n",newTemp.Fahrenheit());return 0;}
- Ruby # Modify the RUBYLIB environment variable to include the Gazebo Math# library install path. For example, if you install to /user:## $ export RUBYLIB=/usr/lib/ruby:$RUBYLIB#require 'gz/math'celsius = Gz::Math::Temperature::KelvinToCelsius(2.5);printf("2.5Kelvin to Celsius is %f\n", celsius)temp = Gz::Math::Temperature.new(123.5)printf("Constructed a Temperature object with %f Kelvin\n",temp.Kelvin())temp += 100.0newTemp.Fahrenheit());
Constructor & Destructor Documentation
◆ Temperature() [1/2]
Temperature | ( | ) |
Default constructor.
◆ Temperature() [2/2]
Temperature | ( | double | _temp | ) |
Kelvin value constructor. This is a conversion constructor, and assumes the passed in value is in Kelvin.
- Parameters
-
[in] _temp Temperature in Kelvin.
Member Function Documentation
◆ Celsius()
double Celsius | ( | ) | const |
Get the temperature in Celsius.
- Returns
- Temperature in Celsius.
◆ CelsiusToFahrenheit()
Convert Celsius to Fahrenheit.
- Parameters
-
[in] _temp Temperature in Celsius.
- Returns
- Temperature in Fahrenheit.
◆ CelsiusToKelvin()
◆ Fahrenheit()
double Fahrenheit | ( | ) | const |
Get the temperature in Fahrenheit.
- Returns
- Temperature in Fahrenheit.
◆ FahrenheitToCelsius()
Convert Fahrenheit to Celsius.
- Parameters
-
[in] _temp Temperature in Fahrenheit
- Returns
- Temperature in Celsius
◆ FahrenheitToKelvin()
Convert Fahrenheit to Kelvin.
- Parameters
-
[in] _temp Temperature in Fahrenheit
- Returns
- Temperature in Kelvin
◆ Kelvin()
double Kelvin | ( | ) | const |
Get the temperature in Kelvin.
- Returns
- Temperature in Kelvin.
◆ KelvinToCelsius()
Convert Kelvin to Celsius.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Temperature in Celsius.
◆ KelvinToFahrenheit()
Convert Kelvin to Fahrenheit.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Temperature in Fahrenheit.
◆ operator!=() [1/2]
bool operator!= | ( | const Temperature & | _temp | ) | const |
Inequality to operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- False if the temperatures are the same, true otherwise.
◆ operator!=() [2/2]
Inequality to operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- False if the temperatures are the same, true otherwise.
◆ operator()()
◆ operator*() [1/2]
Temperature operator* | ( | const Temperature & | _temp | ) | const |
◆ operator*() [2/2]
Temperature operator* | ( | double | _temp | ) | const |
◆ operator*=() [1/2]
const Temperature & operator*= | ( | const Temperature & | _temp | ) |
Multiplication assignment operator.
- Parameters
-
[in] _temp Temperature object.
- Returns
- Reference to this instance.
◆ operator*=() [2/2]
const Temperature & operator*= | ( | double | _temp | ) |
Multiplication assignment operator.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Reference to this instance.
◆ operator+() [1/2]
Temperature operator+ | ( | const Temperature & | _temp | ) | const |
◆ operator+() [2/2]
Temperature operator+ | ( | double | _temp | ) | const |
◆ operator+=() [1/2]
const Temperature & operator+= | ( | const Temperature & | _temp | ) |
Addition assignment operator.
- Parameters
-
[in] _temp Temperature object.
- Returns
- Reference to this instance.
◆ operator+=() [2/2]
const Temperature & operator+= | ( | double | _temp | ) |
Addition assignment operator.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Reference to this instance.
◆ operator-() [1/2]
Temperature operator- | ( | const Temperature & | _temp | ) | const |
◆ operator-() [2/2]
Temperature operator- | ( | double | _temp | ) | const |
◆ operator-=() [1/2]
const Temperature & operator-= | ( | const Temperature & | _temp | ) |
Subtraction assignment operator.
- Parameters
-
[in] _temp Temperature object.
- Returns
- Reference to this instance.
◆ operator-=() [2/2]
const Temperature & operator-= | ( | double | _temp | ) |
Subtraction assignment operator.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Reference to this instance.
◆ operator/() [1/2]
Temperature operator/ | ( | const Temperature & | _temp | ) | const |
◆ operator/() [2/2]
Temperature operator/ | ( | double | _temp | ) | const |
◆ operator/=() [1/2]
const Temperature & operator/= | ( | const Temperature & | _temp | ) |
Division assignment operator.
- Parameters
-
[in] _temp Temperature object.
- Returns
- Reference to this instance.
◆ operator/=() [2/2]
const Temperature & operator/= | ( | double | _temp | ) |
Division assignment operator.
- Parameters
-
[in] _temp Temperature in Kelvin.
- Returns
- Reference to this instance.
◆ operator<() [1/2]
bool operator< | ( | const Temperature & | _temp | ) | const |
Less than to operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- True if this is less than _temp.
◆ operator<() [2/2]
Less than operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- True if this is less than _temp.
◆ operator<=() [1/2]
bool operator<= | ( | const Temperature & | _temp | ) | const |
Less than or equal to operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- True if this is less than or equal _temp.
◆ operator<=() [2/2]
Less than or equal operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- True if this is less than or equal to _temp.
◆ operator=()
Temperature & operator= | ( | double | _temp | ) |
◆ operator==() [1/2]
bool operator== | ( | const Temperature & | _temp | ) | const |
Equal to operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- True if the temperatures are the same, false otherwise.
◆ operator==() [2/2]
Equal to operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- True if the temperatures are the same, false otherwise.
◆ operator>() [1/2]
bool operator> | ( | const Temperature & | _temp | ) | const |
Greater than operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- True if this is greater than _temp.
◆ operator>() [2/2]
Greater than operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- True if this is greater than _temp.
◆ operator>=() [1/2]
bool operator>= | ( | const Temperature & | _temp | ) | const |
Greater than or equal to operator.
- Parameters
-
[in] _temp The temperature to compare.
- Returns
- True if this is greater than or equal to _temp.
◆ operator>=() [2/2]
Greater than equal operator, where the value of _temp is assumed to be in Kelvin.
- Parameters
-
[in] _temp The temperature (in Kelvin) to compare.
- Returns
- True if this is greater than or equal to _temp.
◆ SetCelsius()
Set the temperature from a Celsius value.
- Parameters
-
[in] _temp Temperature in Celsius.
◆ SetFahrenheit()
Set the temperature from a Fahrenheit value.
- Parameters
-
[in] _temp Temperature in Fahrenheit.
◆ SetKelvin()
Set the temperature from a Kelvin value.
- Parameters
-
[in] _temp Temperature in Kelvin.
The documentation for this class was generated from the following file: