+#include <stdio.h>
/* ========================================================================
** Extended Template and Library
** Angle Abstraction Class Implementation
protected:
typedef value_type unit;
- unit v; //! Stored in rotations
+ unit v; //! Stored in radians
public:
operator~()const
{
angle ret;
- ret.v=(value_type)std::floor(v+0.5f);
- return ret;
+ ret.v = v+PI;
+ return ret.mod();
}
/*! Returns true if the shortest
right-hand side is clockwise */
bool
operator<(const angle &rhs)const
- { return v<rhs.v; }
-// { return dist(rhs).v<(value_type)0.0; }
+ { return dist(rhs).v<(value_type)0.0; }
/*! Returns true if the shortest
angle between the left-hand and
right-hand side is counter-clockwise */
bool
operator>(const angle &rhs)const
- { return v>rhs.v; }
-// { return dist(rhs).v>(value_type)0.0; }
+ { return dist(rhs).v>(value_type)0.0; }
/*! Returns true if the shortest
angle between the left-hand and
point on the unit circle. */
bool
operator<=(const angle &rhs)const
- { return v<=rhs.v; }
-// { return dist(rhs).v<=(value_type)0.0; }
+ { return dist(rhs).v<=(value_type)0.0; }
/*! Returns true if the shortest
angle between the left-hand and
point on the unit circle. */
bool
operator>=(const angle &rhs)const
- { return v>=rhs.v; }
-// { return dist(rhs).v>=(value_type)0.0; }
+ { return dist(rhs).v>=(value_type)0.0; }
/*! Returns true if the angles
are refer to the same point
on the unit circle. */
bool
operator==(const angle &rhs)const
- { return v==rhs.v; }
-// { return dist(rhs).v==(value_type)0.0; }
+ { return std::abs(dist(rhs).v)<epsilon; }
/*! Returns false if the angles
are refer to the same point
on the unit circle. */
bool
operator!=(const angle &rhs)const
- { return v!=rhs.v; }
-// { return dist(rhs).v!=(value_type)0.0; }
+ { return std::abs(dist(rhs).v)>epsilon; }
//! Angle Difference Function
/*! This function will return the
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