12 #ifndef ECL_GEOMETRY_ANGLE_HPP_ 13 #define ECL_GEOMETRY_ANGLE_HPP_ 20 #include <ecl/config/macros.hpp> 21 #include <ecl/linear_algebra.hpp> 22 #include <ecl/type_traits/fundamental_types.hpp> 23 #include <ecl/mpl/enable_if.hpp> 24 #include <ecl/math/constants.hpp> 42 static const T rads_to_degs = 180.0/
pi;
43 return radians*rads_to_degs;
55 static const T degs_to_rads =
pi/180.0;
56 return degrees*degs_to_rads;
112 template <
class T,
typename Enable =
void>
135 template <
typename T>
136 class ECL_PUBLIC Angle<T, typename enable_if<is_float<T> >::type> {
141 typedef ecl::linear_algebra::Matrix<T,2,2> RotationMatrix;
150 Angle(
const T &angle = 0.0) : value(angle) {
wrap_angle(value); }
155 Angle(
const RotationMatrix &rotation) {
156 value = std::atan2(rotation(1,0),rotation(0,0));
168 const Angle<T>& operator=(
const T &angle);
180 Angle<T> operator+(
const T &angle)
const;
197 void operator+=(
const T &angle);
205 void operator+=(
const Angle<T> &angle);
214 Angle<T> operator-(
const T &angle)
const;
231 void operator-=(
const T &angle);
239 void operator-=(
const Angle<T> &angle);
248 Angle<T> operator*(
const T &scalar)
const;
256 void operator*=(
const T &scalar);
270 operator const T&()
const {
return value; }
287 RotationMatrix rotationMatrix()
const {
288 T c = std::cos(value);
289 T s = std::sin(value);
290 return (RotationMatrix() << c, -s, s, c).finished();
306 static Angle<T> Degrees(
const T &angle);
320 static Angle<T> Radians(
const T &angle);
334 template <
typename T>
339 template <
typename T>
350 template <
typename T>
355 template <
typename T>
360 template <
typename T>
366 template <
typename T>
368 value += angle.value;
372 template <
typename T>
377 template <
typename T>
382 template <
typename T>
388 template <
typename T>
390 value -= angle.value;
394 template <
typename T>
399 template <
typename T>
409 template <
typename T>
414 template <
typename T>
ecl_geometry_PUBLIC T radians_to_degrees(const T &radians, typename enable_if< ecl::is_float< T > >::type *dummy=0)
Converts radians to degrees and returns the result.
#define ecl_geometry_PUBLIC
Default action for detection of a fundamental float type (false).
ecl_geometry_PUBLIC T degrees_to_radians(const T °rees, typename enable_if< ecl::is_float< T > >::type *dummy=0)
Converts degrees to radians and returns the result.
ecl_geometry_PUBLIC const float & wrap_angle(float &angle)
Wrap the angle on -pi,pi (float types).
Parent template definition for angles.
Enables the SFINAE concept.