boost::geometry::math Namespace Reference

## Functions

template<typename T >
T | abs (T const &value)
| Short utility to workaround gcc/clang problem that abs is converting to integer and that older versions of MSVC does not support abs of long long...
template<typename DegreeOrRadian , typename T >
T | as_radian (T const &value)
template<typename T >
T | d2r ()
template<typename T1 , typename T2 >
bool | equals (T1 const &a, T2 const &b)
| returns true if both arguments are equal.
template<typename T1 , typename T2 >
bool | equals_with_epsilon (T1 const &a, T2 const &b)
template<typename DegreeOrRadian , typename T >
T | from_radian (T const &value)
template<typename T >
T | half_pi ()
template<typename T >
T | hav (T const &theta)
| Calculates the haversine of an angle.
template<typename T1 , typename T2 >
bool | larger (T1 const &a, T2 const &b)
template<typename T1 , typename T2 >
bool | larger_or_equals (T1 const &a, T2 const &b)
template<typename Units , typename CoordinateType >
CoordinateType | longitude_distance_signed (CoordinateType const &longitude1, CoordinateType const &longitude2)
| Short utility to calculate difference between two longitudes normalized in range (-180, 180].
template<typename Units , typename CoordinateType >
CoordinateType | longitude_distance_unsigned (CoordinateType const &longitude1, CoordinateType const &longitude2)
| Short utility to calculate difference between two longitudes normalized in range [0, 360).
template<typename T >
detail::modulo< T >::return_type | mod (T const &value1, T const &value2)
| Short utility to return the modulo of two values.
template<typename Units , typename CoordinateType >
void | normalize_longitude (CoordinateType &longitude)
| Short utility to normalize the longitude on a spheroid. Note that in general both coordinates should be normalized at once. This utility is suitable e.g. for normalization of the difference of longitudes.
template<typename Units , typename CoordinateType >
void | normalize_spheroidal_box_coordinates (CoordinateType &longitude1, CoordinateType &latitude1, CoordinateType &longitude2, CoordinateType &latitude2)
| Short utility to normalize the coordinates of a box on a spheroid.
template<typename Units , typename CoordinateType >
void | normalize_spheroidal_box_coordinates (CoordinateType &longitude1, CoordinateType &latitude1, CoordinateType &longitude2, CoordinateType &latitude2, bool band)
| Short utility to normalize the coordinates of a box on a spheroid.
template<typename Units , typename CoordinateType >
void | normalize_spheroidal_coordinates (CoordinateType &longitude, CoordinateType &latitude)
| Short utility to normalize the coordinates on a spheroid.
template<typename T >
T | pi ()
template<typename T >
T | r2d ()
template<typename T >
T | relaxed_epsilon (T const &factor)
template<typename Result , typename T >
Result | rounding_cast (T const &v)
| Short utility to cast a value possibly rounding it to the nearest integral value.
template<typename T >
T | scaled_epsilon (T const &value)
template<typename T >
int | sign (T const &value)
| Short utility to calculate the sign of a number: -1 (negative), 0 (zero), 1 (positive)
template<typename T1 , typename T2 >
bool | smaller (T1 const &a, T2 const &b)
template<typename T1 , typename T2 >
bool | smaller_or_equals (T1 const &a, T2 const &b)
template<typename T >
T | sqr (T const &value)
| Short utility to return the square.
template<typename T >
detail::square_root< T > ::return_type | sqrt (T const &value)
| Short utility to return the square root.
template<typename T >
T | two_pi ()

## Function Documentation

template<typename T >

T boost::geometry::math::pi | ( |  | ) |

template<typename T >

T boost::geometry::math::two_pi | ( |  | ) |

template<typename T >

T boost::geometry::math::half_pi | ( |  | ) |

template<typename T >

T boost::geometry::math::relaxed_epsilon | ( | T const & | factor | ) |

template<typename T >

T boost::geometry::math::scaled_epsilon | ( | T const & | value | ) |

template<typename T1 , typename T2 >

bool boost::geometry::math::equals | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

returns true if both arguments are equal.

Parameters:

  a | first argument
  b | second argument

Returns:
  true if a == b

Note:
  If both a and b are of an integral type, comparison is done by ==. If one of the types is floating point, comparison is done by abs and comparing with epsilon. If one of the types is non-fundamental, it might be a high-precision number and comparison is done using the == operator of that class.

template<typename T1 , typename T2 >

bool boost::geometry::math::equals_with_epsilon | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

template<typename T1 , typename T2 >

bool boost::geometry::math::smaller | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

template<typename T1 , typename T2 >

bool boost::geometry::math::larger | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

template<typename T1 , typename T2 >

bool boost::geometry::math::smaller_or_equals | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

template<typename T1 , typename T2 >

bool boost::geometry::math::larger_or_equals | ( | T1 const & | a,
|  | T2 const & | b
| ) |  |

template<typename T >

T boost::geometry::math::d2r | ( |  | ) |

template<typename T >

T boost::geometry::math::r2d | ( |  | ) |

template<typename DegreeOrRadian , typename T >

T boost::geometry::math::as_radian | ( | T const & | value | ) |

template<typename DegreeOrRadian , typename T >

T boost::geometry::math::from_radian | ( | T const & | value | ) |

template<typename T >

T boost::geometry::math::hav | ( | T const & | theta | ) |

Calculates the haversine of an angle.

Note:
  See http://en.wikipedia.org/wiki/Haversine_formula haversin(alpha) = sin2(alpha/2)

template<typename T >

T boost::geometry::math::sqr | ( | T const & | value | ) |

Short utility to return the square.

Parameters:

  value | Value to calculate the square from

Returns:
  The squared value

template<typename T >

detail::square_root<T>::return_type boost::geometry::math::sqrt | ( | T const & | value | ) |

Short utility to return the square root.

Parameters:

  value | Value to calculate the square root from

Returns:
  The square root value

template<typename T >

detail::modulo<T>::return_type boost::geometry::math::mod | ( | T const & | value1,
|  | T const & | value2
| ) |  |

Short utility to return the modulo of two values.

Parameters:

  value1 | First value
  value2 | Second value

Returns:
  The result of the modulo operation on the (ordered) pair (value1, value2)

template<typename T >

T boost::geometry::math::abs | ( | T const & | value | ) |

Short utility to workaround gcc/clang problem that abs is converting to integer and that older versions of MSVC does not support abs of long long...

template<typename T >

int boost::geometry::math::sign | ( | T const & | value | ) |

Short utility to calculate the sign of a number: -1 (negative), 0 (zero), 1 (positive)

template<typename Result , typename T >

Result boost::geometry::math::rounding_cast | ( | T const & | v | ) |

Short utility to cast a value possibly rounding it to the nearest integral value.

Note:
  If the source T is NOT an integral type and Result is an integral type the value is rounded towards the closest integral value. Otherwise it's casted without rounding.

template<typename Units , typename CoordinateType >

void boost::geometry::math::normalize_spheroidal_box_coordinates | ( | CoordinateType & | longitude1,
|  | CoordinateType & | latitude1,
|  | CoordinateType & | longitude2,
|  | CoordinateType & | latitude2
| ) |  |

Short utility to normalize the coordinates of a box on a spheroid.

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude1 | Minimum longitude of the box
  latitude1 | Minimum latitude of the box
  longitude2 | Maximum longitude of the box
  latitude2 | Maximum latitude of the box

template<typename Units , typename CoordinateType >

void boost::geometry::math::normalize_spheroidal_box_coordinates | ( | CoordinateType & | longitude1,
|  | CoordinateType & | latitude1,
|  | CoordinateType & | longitude2,
|  | CoordinateType & | latitude2,
|  | bool | band
| ) |  |

Short utility to normalize the coordinates of a box on a spheroid.

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude1 | Minimum longitude of the box
  latitude1 | Minimum latitude of the box
  longitude2 | Maximum longitude of the box
  latitude2 | Maximum latitude of the box
  band | Indicates whether the box should be treated as a band or not and avoid the computation done in the other version of the function

template<typename Units , typename CoordinateType >

void boost::geometry::math::normalize_spheroidal_coordinates | ( | CoordinateType & | longitude,
|  | CoordinateType & | latitude
| ) |  |

Short utility to normalize the coordinates on a spheroid.

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude | Longitude
  latitude | Latitude

template<typename Units , typename CoordinateType >

void boost::geometry::math::normalize_longitude | ( | CoordinateType & | longitude | ) |

Short utility to normalize the longitude on a spheroid. Note that in general both coordinates should be normalized at once. This utility is suitable e.g. for normalization of the difference of longitudes.

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude | Longitude

template<typename Units , typename CoordinateType >

CoordinateType boost::geometry::math::longitude_distance_signed | ( | CoordinateType const & | longitude1,
|  | CoordinateType const & | longitude2
| ) |  |

Short utility to calculate difference between two longitudes normalized in range (-180, 180].

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude1 | Longitude 1
  longitude2 | Longitude 2

template<typename Units , typename CoordinateType >

CoordinateType boost::geometry::math::longitude_distance_unsigned | ( | CoordinateType const & | longitude1,
|  | CoordinateType const & | longitude2
| ) |  |

Short utility to calculate difference between two longitudes normalized in range [0, 360).

Template Parameters:

  Units | The units of the coordindate system in the spheroid
  CoordinateType | The type of the coordinates

Parameters:

  longitude1 | Longitude 1
  longitude2 | Longitude 2

April 2, 2011 | Copyright © 2007-2011 Barend Gehrels, Amsterdam, the Netherlands Copyright © 2008-2011 Bruno Lalande, Paris, France Copyright © 2009-2010 Mateusz Loskot, London, UK