Gazebo Math

API Reference

6.15.1

A class that stores temperature information, and allows conversion between different units. More...

#include <Temperature.hh>

Public Member Functions

 Temperature ()
 Default constructor. More...
 
 Temperature (const double _temp)
 Kelvin value constructor. This is a conversion constructor. More...
 
 Temperature (const Temperature &_temp)
 Copy constructor. More...
 
virtual ~Temperature ()
 Destructor. More...
 
double Celsius () const
 Get the temperature in Celsius. More...
 
double Fahrenheit () const
 Get the temperature in Fahrenheit. More...
 
double Kelvin () const
 Get the temperature in Kelvin. More...
 
bool operator!= (const double _temp) const
 Inequality to operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator!= (const Temperature &_temp) const
 Inequality to operator. More...
 
double operator() () const
 Accessor operator. More...
 
Temperature operator* (const double _temp)
 Multiplication operator. More...
 
Temperature operator* (const double _temp) const
 Multiplication operator. More...
 
Temperature operator* (const Temperature &_temp)
 Multiplication operator. More...
 
Temperature operator* (const Temperature &_temp) const
 Multiplication operator. More...
 
const Temperatureoperator*= (const double _temp)
 Multiplication assignment operator. More...
 
const Temperatureoperator*= (const Temperature &_temp)
 Multiplication assignment operator. More...
 
Temperature operator+ (const double _temp)
 Addition operator. More...
 
Temperature operator+ (const double _temp) const
 Addition operator. More...
 
Temperature operator+ (const Temperature &_temp)
 Addition operator. More...
 
Temperature operator+ (const Temperature &_temp) const
 Addition operator. More...
 
const Temperatureoperator+= (const double _temp)
 Addition assignment operator. More...
 
const Temperatureoperator+= (const Temperature &_temp)
 Addition assignment operator. More...
 
Temperature operator- (const double _temp)
 Subtraction operator. More...
 
Temperature operator- (const double _temp) const
 Subtraction operator. More...
 
Temperature operator- (const Temperature &_temp)
 Subtraction operator. More...
 
Temperature operator- (const Temperature &_temp) const
 Subtraction operator. More...
 
const Temperatureoperator-= (const double _temp)
 Subtraction assignment operator. More...
 
const Temperatureoperator-= (const Temperature &_temp)
 Subtraction assignment operator. More...
 
Temperature operator/ (const double _temp)
 Division operator. More...
 
Temperature operator/ (const double _temp) const
 Division operator. More...
 
Temperature operator/ (const Temperature &_temp)
 Division operator. More...
 
Temperature operator/ (const Temperature &_temp) const
 Division operator. More...
 
const Temperatureoperator/= (const double _temp)
 Division assignment operator. More...
 
const Temperatureoperator/= (const Temperature &_temp)
 Division assignment operator. More...
 
bool operator< (const double _temp) const
 Less than operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator< (const Temperature &_temp) const
 Less than to operator. More...
 
bool operator<= (const double _temp) const
 Less than or equal operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator<= (const Temperature &_temp) const
 Less than or equal to operator. More...
 
Temperatureoperator= (const double _temp)
 Assignment operator. More...
 
Temperatureoperator= (const Temperature &_temp)
 Assignment operator. More...
 
bool operator== (const double _temp) const
 Equal to operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator== (const Temperature &_temp) const
 Equal to operator. More...
 
bool operator> (const double _temp) const
 Greater than operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator> (const Temperature &_temp) const
 Greater than operator. More...
 
bool operator>= (const double _temp) const
 Greater than equal operator, where the value of _temp is assumed to be in Kelvin. More...
 
bool operator>= (const Temperature &_temp) const
 Greater than or equal to operator. More...
 
void SetCelsius (const double _temp)
 Set the temperature from a Celsius value. More...
 
void SetFahrenheit (const double _temp)
 Set the temperature from a Fahrenheit value. More...
 
void SetKelvin (const double _temp)
 Set the temperature from a Kelvin value. More...
 

Static Public Member Functions

static double CelsiusToFahrenheit (const double _temp)
 Convert Celsius to Fahrenheit. More...
 
static double CelsiusToKelvin (const double _temp)
 Convert Celsius to Kelvin. More...
 
static double FahrenheitToCelsius (const double _temp)
 Convert Fahrenheit to Celsius. More...
 
static double FahrenheitToKelvin (const double _temp)
 Convert Fahrenheit to Kelvin. More...
 
static double KelvinToCelsius (const double _temp)
 Convert Kelvin to Celsius. More...
 
static double KelvinToFahrenheit (const double _temp)
 Convert Kelvin to Fahrenheit. More...
 

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.

Example usage

Convert from Kelvin to Celsius

double celsius = Temperature::KelvinToCelsius(2.5);

Create and use a Temperature object

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;

Temperature newTemp(temp);
newTemp += temp + 23.5;
std::cout << "Copied the temp object and added 23.5K. newTemp = "
          << newTemp.Fahrenheit() << "F" << std::endl;

Constructor & Destructor Documentation

◆ Temperature() [1/3]

Default constructor.

◆ Temperature() [2/3]

Temperature ( const double  _temp)

Kelvin value constructor. This is a conversion constructor.

Parameters
[in]_tempTemperature in Kelvin

◆ Temperature() [3/3]

Temperature ( const Temperature _temp)

Copy constructor.

Parameters
[in]_tempTemperature object to copy.

◆ ~Temperature()

virtual ~Temperature ( )
virtual

Destructor.

Member Function Documentation

◆ Celsius()

double Celsius ( ) const

Get the temperature in Celsius.

Returns
Temperature in Celsius

◆ CelsiusToFahrenheit()

static double CelsiusToFahrenheit ( const double  _temp)
static

Convert Celsius to Fahrenheit.

Parameters
[in]_tempTemperature in Celsius
Returns
Temperature in Fahrenheit

◆ CelsiusToKelvin()

static double CelsiusToKelvin ( const double  _temp)
static

Convert Celsius to Kelvin.

Parameters
[in]_tempTemperature in Celsius
Returns
Temperature in Kelvin

◆ Fahrenheit()

double Fahrenheit ( ) const

Get the temperature in Fahrenheit.

Returns
Temperature in Fahrenheit

◆ FahrenheitToCelsius()

static double FahrenheitToCelsius ( const double  _temp)
static

Convert Fahrenheit to Celsius.

Parameters
[in]_tempTemperature in Fahrenheit
Returns
Temperature in Celsius

◆ FahrenheitToKelvin()

static double FahrenheitToKelvin ( const double  _temp)
static

Convert Fahrenheit to Kelvin.

Parameters
[in]_tempTemperature in Fahrenheit
Returns
Temperature in Kelvin

◆ Kelvin()

double Kelvin ( ) const

Get the temperature in Kelvin.

Returns
Temperature in Kelvin

◆ KelvinToCelsius()

static double KelvinToCelsius ( const double  _temp)
static

Convert Kelvin to Celsius.

Parameters
[in]_tempTemperature in Kelvin
Returns
Temperature in Celsius

◆ KelvinToFahrenheit()

static double KelvinToFahrenheit ( const double  _temp)
static

Convert Kelvin to Fahrenheit.

Parameters
[in]_tempTemperature in Kelvin
Returns
Temperature in Fahrenheit

◆ operator!=() [1/2]

bool operator!= ( const double  _temp) const

Inequality to operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
false if the temperatures are the same, true otherwise

◆ operator!=() [2/2]

bool operator!= ( const Temperature _temp) const

Inequality to operator.

Parameters
[in]_tempThe temperature to compare
Returns
false if the temperatures are the same, true otherwise

◆ operator()()

double operator() ( ) const

Accessor operator.

Returns
Temperature in Kelvin
See also
Kelvin()

◆ operator*() [1/4]

Temperature operator* ( const double  _temp)

Multiplication operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator*() [2/4]

Temperature operator* ( const double  _temp) const

Multiplication operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator*() [3/4]

Temperature operator* ( const Temperature _temp)

Multiplication operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator*() [4/4]

Temperature operator* ( const Temperature _temp) const

Multiplication operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator*=() [1/2]

const Temperature& operator*= ( const double  _temp)

Multiplication assignment operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Reference to this instance

◆ operator*=() [2/2]

const Temperature& operator*= ( const Temperature _temp)

Multiplication assignment operator.

Parameters
[in]_tempTemperature object
Returns
Reference to this instance

◆ operator+() [1/4]

Temperature operator+ ( const double  _temp)

Addition operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator+() [2/4]

Temperature operator+ ( const double  _temp) const

Addition operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator+() [3/4]

Temperature operator+ ( const Temperature _temp)

Addition operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator+() [4/4]

Temperature operator+ ( const Temperature _temp) const

Addition operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator+=() [1/2]

const Temperature& operator+= ( const double  _temp)

Addition assignment operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Reference to this instance

◆ operator+=() [2/2]

const Temperature& operator+= ( const Temperature _temp)

Addition assignment operator.

Parameters
[in]_tempTemperature object
Returns
Reference to this instance

◆ operator-() [1/4]

Temperature operator- ( const double  _temp)

Subtraction operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator-() [2/4]

Temperature operator- ( const double  _temp) const

Subtraction operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator-() [3/4]

Temperature operator- ( const Temperature _temp)

Subtraction operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator-() [4/4]

Temperature operator- ( const Temperature _temp) const

Subtraction operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator-=() [1/2]

const Temperature& operator-= ( const double  _temp)

Subtraction assignment operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Reference to this instance

◆ operator-=() [2/2]

const Temperature& operator-= ( const Temperature _temp)

Subtraction assignment operator.

Parameters
[in]_tempTemperature object
Returns
Reference to this instance

◆ operator/() [1/4]

Temperature operator/ ( const double  _temp)

Division operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator/() [2/4]

Temperature operator/ ( const double  _temp) const

Division operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Resulting temperature

◆ operator/() [3/4]

Temperature operator/ ( const Temperature _temp)

Division operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator/() [4/4]

Temperature operator/ ( const Temperature _temp) const

Division operator.

Parameters
[in]_tempTemperature object
Returns
Resulting temperature

◆ operator/=() [1/2]

const Temperature& operator/= ( const double  _temp)

Division assignment operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Reference to this instance

◆ operator/=() [2/2]

const Temperature& operator/= ( const Temperature _temp)

Division assignment operator.

Parameters
[in]_tempTemperature object
Returns
Reference to this instance

◆ operator<() [1/2]

bool operator< ( const double  _temp) const

Less than operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
True if this is less than _temp.

◆ operator<() [2/2]

bool operator< ( const Temperature _temp) const

Less than to operator.

Parameters
[in]_tempThe temperature to compare
Returns
True if this is less than _temp.

◆ operator<=() [1/2]

bool operator<= ( const double  _temp) const

Less than or equal operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
True if this is less than or equal to _temp.

◆ operator<=() [2/2]

bool operator<= ( const Temperature _temp) const

Less than or equal to operator.

Parameters
[in]_tempThe temperature to compare
Returns
True if this is less than or equal _temp.

◆ operator=() [1/2]

Temperature& operator= ( const double  _temp)

Assignment operator.

Parameters
[in]_tempTemperature in Kelvin
Returns
Reference to this instance

◆ operator=() [2/2]

Temperature& operator= ( const Temperature _temp)

Assignment operator.

Parameters
[in]_tempTemperature object
Returns
Reference to this instance

◆ operator==() [1/2]

bool operator== ( const double  _temp) const

Equal to operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
true if the temperatures are the same, false otherwise

◆ operator==() [2/2]

bool operator== ( const Temperature _temp) const

Equal to operator.

Parameters
[in]_tempThe temperature to compare
Returns
true if the temperatures are the same, false otherwise

◆ operator>() [1/2]

bool operator> ( const double  _temp) const

Greater than operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
True if this is greater than _temp.

◆ operator>() [2/2]

bool operator> ( const Temperature _temp) const

Greater than operator.

Parameters
[in]_tempThe temperature to compare
Returns
True if this is greater than _temp.

◆ operator>=() [1/2]

bool operator>= ( const double  _temp) const

Greater than equal operator, where the value of _temp is assumed to be in Kelvin.

Parameters
[in]_tempThe temperature (in Kelvin) to compare
Returns
True if this is greater than or equal to _temp.

◆ operator>=() [2/2]

bool operator>= ( const Temperature _temp) const

Greater than or equal to operator.

Parameters
[in]_tempThe temperature to compare
Returns
True if this is greater than or equal to _temp.

◆ SetCelsius()

void SetCelsius ( const double  _temp)

Set the temperature from a Celsius value.

Parameters
[in]_tempTemperature in Celsius

◆ SetFahrenheit()

void SetFahrenheit ( const double  _temp)

Set the temperature from a Fahrenheit value.

Parameters
[in]_tempTemperature in Fahrenheit

◆ SetKelvin()

void SetKelvin ( const double  _temp)

Set the temperature from a Kelvin value.

Parameters
[in]_tempTemperature in Kelvin

The documentation for this class was generated from the following file: