** $Id$
**
** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** Copyright (c) 2007 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
# define HALF_PI (PI/2)
#endif
+#define ANGLE_EPSILON (1.0e-6)
+
/* === T Y P E D E F S ===================================================== */
/* === C L A S S E S & S T R U C T S ======================================= */
on the unit circle. */
bool
operator==(const angle &rhs)const
- { return std::abs(dist(rhs).v)<epsilon; }
+ { return std::abs(dist(rhs).v)<ANGLE_EPSILON; }
/*! Returns false if the angles
are refer to the same point
on the unit circle. */
bool
operator!=(const angle &rhs)const
- { return std::abs(dist(rhs).v)>epsilon; }
+ { return std::abs(dist(rhs).v)>ANGLE_EPSILON; }
+
+ //! Absolute Angle Function
+ /*! This function will return the
+ absolute value of the angle. */
+ angle
+ abs()const
+ {
+ angle ret;
+ ret.v=std::abs(v);
+ return ret;
+ }
//! Angle Difference Function
/*! This function will return the
return ret;
}
- bool operator!()const { return std::abs(mod().v) < epsilon; }
+ bool operator!()const { return std::abs(mod().v) < ANGLE_EPSILON; }
private:
static value_type rot_floor(value_type x)
{ return static_cast<value_type>(std::floor(x/(PI*2))*PI*2); }
- static const value_type epsilon = 1.0e-6;
-
public:
/*
** Conversion Classes
rad(const angle &a):angle(a) { }
rad mod()const { return angle::mod(); }
rad dist(const angle &rhs)const { return angle::dist(rhs); }
+ value_type get()const { return v; }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
- value_type get()const { return v; }
}; // END of class angle::radians
-inline angle::rad::operator angle::value_type()const { return get(); }
+// inline angle::rad::operator angle::value_type()const { return get(); }
// ========================================================================
/*! \class angle::deg _angle.h ETL/angle
deg dist(const angle &rhs)const { return angle::dist(rhs); }
value_type get()const { return v*360/(PI*2); }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
}; // END of class angle::degrees
-inline angle::deg::operator angle::value_type()const { return get(); }
+// inline angle::deg::operator angle::value_type()const { return get(); }
// ========================================================================
/*! \class angle::rot _angle.h ETL/angle
rot dist(const angle &rhs)const { return angle::dist(rhs); }
value_type get()const { return v/(PI*2); }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
}; // END of class angle::rotations
-inline angle::rot::operator angle::value_type()const { return get(); }
+// inline angle::rot::operator angle::value_type()const { return get(); }
// ========================================================================
/*! \class angle::sin _angle.h ETL/angle
sin dist(const angle &rhs)const { return angle::dist(rhs); }
value_type get()const { return static_cast<value_type>(std::sin(v)); }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
}; // END of class angle::sin
-inline angle::sin::operator angle::value_type()const { return get(); }
+// inline angle::sin::operator angle::value_type()const { return get(); }
// ========================================================================
/*! \class angle::cos _angle.h ETL/angle
cos(const angle &a):angle(a) { }
cos mod()const { return angle::mod(); }
cos dist(const angle &rhs)const { return angle::dist(rhs); }
+ value_type get()const { return (value_type)std::cos(v); }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
- value_type get()const { return (value_type)std::cos(v); }
}; // END of class angle::cos
-inline angle::cos::operator angle::value_type()const { return get(); }
+// inline angle::cos::operator angle::value_type()const { return get(); }
// ========================================================================
/*! \class angle::tan _angle.h ETL/angle
tan(const angle &a):angle(a) { }
tan mod()const { return angle::mod(); }
tan dist(const angle &rhs)const { return angle::dist(rhs); }
+ value_type get()const { return (value_type)std::tan(v); }
#ifndef ETL_NO_DEPRECATED
- operator value_type()const ETL_DEPRECATED_FUNCTION;
+ // operator value_type()const ETL_DEPRECATED_FUNCTION;
#endif
- value_type get()const { return (value_type)std::tan(v); }
}; // END of class angle::tan
-inline angle::tan::operator angle::value_type()const { return get(); }
+// inline angle::tan::operator angle::value_type()const { return get(); }
_ETL_END_NAMESPACE