mt
 All Classes Files Functions Enumerations Groups Pages
Typedefs | Functions
scalar.h File Reference
#include <algorithm>
#include <cmath>
#include <mt/exception.h>

Go to the source code of this file.

Typedefs

typedef float mt::value_t
typedef value_t mt::Scalar

Functions

const Scalar mt::PI (std::atan2(Scalar(0.0), Scalar(-1.0)))
const Scalar mt::HALF_PI (PI/Scalar(2.0))
const Scalar mt::TWO_PI (PI *Scalar(2.0))
Scalar mt::degToRad (const Scalar &s)
 Applies the degrees to radians conversion factor.
Scalar mt::radToDeg (const Scalar &s)
 Applies the radians to degrees conversion factor.
Scalar mt::sq (const Scalar &s)
 Computes the square of the input value.
Scalar mt::sgn (const Scalar &s)
template<class T >
mt::normalize (const T &s, const T &lower, const T &upper, T &cycles)
template<class T >
mt::normalize (const T &s, const T &lower, const T &upper)
 Same as above, but without the cycles parameter.
template<class T >
mt::saturate (const T &s, const T &lower, const T &upper)
template<class T >
mt::round (const T &s, const T &tol=T(1.0))
template<class T >
mt::asinMt (const T &sin_ang, const T &ref_ang)
template<class T >
mt::acosMt (const T &cos_ang, const T &ref_ang)
template<class T >
mt::getValue (const T &s)
 Gets scalar value.

Detailed Description

This file contains a typedef for setting the scalar quantity representation to be used in the library. It is set by default to float, but other representations such as double and the BasicScalar<T> type provided in this library can be used as well. For example, for using doubles, the macro MT_USE_DOUBLES should be defined; for using BasicScalar<float>, the macro MT_USE_BASIC_SCALAR should be defined; and for using BasicScalar<float>, both MT_USE_DOUBLES and MT_USE_BASIC_SCALAR should be defined.

Additionally, a few convenience methods for operating on scalar quantities are provided.

By setting MT_USE_BASIC_SCALAR, numeric checks are enabled throughout the library that increase its robustness. As examples, when constructing a plane with three points, it is checked that they are not collinear, and when setting a unit quaternion from a rotation matrix, its determinant is checked to be unity.