Gazebo Math

API Reference

7.4.0

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

#include <Temperature.hh>

Public Member Functions

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

Static Public Member Functions

static double CelsiusToFahrenheit (double _temp)
 Convert Celsius to Fahrenheit. More...
 
static double CelsiusToKelvin (double _temp)
 Convert Celsius to Kelvin. More...
 
static double FahrenheitToCelsius (double _temp)
 Convert Fahrenheit to Celsius. More...
 
static double FahrenheitToKelvin (double _temp)
 Convert Fahrenheit to Kelvin. More...
 
static double KelvinToCelsius (double _temp)
 Convert Kelvin to Celsius. More...
 
static double KelvinToFahrenheit (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.

Examples

  • C++
    #include <stdio.h>
    int main(int argc, char **argv)
    {
    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());
    gz::math::Temperature newTemp(temp);
    newTemp += temp + 23.5;
    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())
    printf("Same temperature in Celsius %f\n", temp.Celsius())
    temp += 100.0
    printf("Temperature + 100.0 is %fK", temp.Kelvin())
    newTemp = Gz::Math::Temperature.new(temp.Kelvin())
    newTemp += temp + 23.5;
    printf("Copied temp and added 23.5K. The new tempurature is %fF\n",
    newTemp.Fahrenheit());

Constructor & Destructor Documentation

◆ Temperature() [1/2]

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]_tempTemperature in Kelvin.

Member Function Documentation

◆ Celsius()

double Celsius ( ) const

Get the temperature in Celsius.

Returns
Temperature in Celsius.

◆ CelsiusToFahrenheit()

static double CelsiusToFahrenheit ( double  _temp)
static

Convert Celsius to Fahrenheit.

Parameters
[in]_tempTemperature in Celsius.
Returns
Temperature in Fahrenheit.

◆ CelsiusToKelvin()

static double CelsiusToKelvin ( 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 ( double  _temp)
static

Convert Fahrenheit to Celsius.

Parameters
[in]_tempTemperature in Fahrenheit
Returns
Temperature in Celsius

◆ FahrenheitToKelvin()

static double FahrenheitToKelvin ( 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 ( double  _temp)
static

Convert Kelvin to Celsius.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Temperature in Celsius.

◆ KelvinToFahrenheit()

static double KelvinToFahrenheit ( double  _temp)
static

Convert Kelvin to Fahrenheit.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Temperature in Fahrenheit.

◆ operator!=() [1/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!=() [2/2]

bool operator!= ( 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()()

double operator() ( ) const

Accessor operator.

Returns
Temperature in Kelvin.
See also
Kelvin().

◆ operator*() [1/2]

Temperature operator* ( const Temperature _temp) const

Multiplication operator.

Parameters
[in]_tempTemperature object.
Returns
Resulting temperature.

◆ operator*() [2/2]

Temperature operator* ( double  _temp) const

Multiplication operator.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Resulting temperature.

◆ operator*=() [1/2]

const Temperature& operator*= ( const Temperature _temp)

Multiplication assignment operator.

Parameters
[in]_tempTemperature object.
Returns
Reference to this instance.

◆ operator*=() [2/2]

const Temperature& operator*= ( double  _temp)

Multiplication assignment operator.

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

◆ operator+() [1/2]

Temperature operator+ ( const Temperature _temp) const

Addition operator.

Parameters
[in]_tempTemperature object.
Returns
Resulting temperature.

◆ operator+() [2/2]

Temperature operator+ ( double  _temp) const

Addition operator.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Resulting temperature.

◆ operator+=() [1/2]

const Temperature& operator+= ( const Temperature _temp)

Addition assignment operator.

Parameters
[in]_tempTemperature object.
Returns
Reference to this instance.

◆ operator+=() [2/2]

const Temperature& operator+= ( double  _temp)

Addition assignment operator.

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

◆ operator-() [1/2]

Temperature operator- ( const Temperature _temp) const

Subtraction operator.

Parameters
[in]_tempTemperature object.
Returns
Resulting temperature.

◆ operator-() [2/2]

Temperature operator- ( double  _temp) const

Subtraction operator.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Resulting temperature.

◆ operator-=() [1/2]

const Temperature& operator-= ( const Temperature _temp)

Subtraction assignment operator.

Parameters
[in]_tempTemperature object.
Returns
Reference to this instance.

◆ operator-=() [2/2]

const Temperature& operator-= ( double  _temp)

Subtraction assignment operator.

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

◆ operator/() [1/2]

Temperature operator/ ( const Temperature _temp) const

Division operator.

Parameters
[in]_tempTemperature object.
Returns
Resulting temperature.

◆ operator/() [2/2]

Temperature operator/ ( double  _temp) const

Division operator.

Parameters
[in]_tempTemperature in Kelvin.
Returns
Resulting temperature.

◆ operator/=() [1/2]

const Temperature& operator/= ( const Temperature _temp)

Division assignment operator.

Parameters
[in]_tempTemperature object.
Returns
Reference to this instance.

◆ operator/=() [2/2]

const Temperature& operator/= ( double  _temp)

Division assignment operator.

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

◆ operator<() [1/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<() [2/2]

bool operator< ( 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<=() [1/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<=() [2/2]

bool operator<= ( 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=()

Temperature& operator= ( double  _temp)

Assignment operator.

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

◆ operator==() [1/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==() [2/2]

bool operator== ( 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>() [1/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>() [2/2]

bool operator> ( 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>=() [1/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.

◆ operator>=() [2/2]

bool operator>= ( 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.

◆ SetCelsius()

void SetCelsius ( double  _temp)

Set the temperature from a Celsius value.

Parameters
[in]_tempTemperature in Celsius.

◆ SetFahrenheit()

void SetFahrenheit ( double  _temp)

Set the temperature from a Fahrenheit value.

Parameters
[in]_tempTemperature in Fahrenheit.

◆ SetKelvin()

void SetKelvin ( 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: