00001 #ifndef ANGLE_CLASS
00002 #define ANGLE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <basis/packable.h>
00019
00020 namespace geometric {
00021
00023
00024 template <class contents>
00025 class angle : public packable
00026 {
00027 public:
00029 enum angular_units { DEGREES, RADIANS };
00030
00031 angle(contents inital_rotation = 0, angular_units unit = RADIANS);
00033
00034 void set(contents a, angular_units unit);
00036 contents get(angular_units unit) const;
00038
00039 angle operator - (void) const;
00041
00042 angle operator + (const angle &to_add) const;
00043 angle operator - (const angle &to_subtract) const;
00044 angle operator * (contents to_multiply) const;
00045 angle operator / (contents to_divide) const;
00046 angle &operator += (const angle &to_add);
00047 angle &operator -= (const angle &to_subtract);
00048 angle &operator *= (contents to_multiply);
00049 angle &operator /= (contents to_divide);
00050
00051 contents sine() const;
00053 contents cosine() const;
00055 contents tangent() const;
00057
00058 static angle arctangent(contents opposite, contents adjacent,
00059 outcome &retval);
00061
00063 static angle arccosine(contents adjacent, contents hypotenuse,
00064 outcome &retval);
00066 static angle arcsine(contents opposite, contents hypotenuse,
00067 outcome &retval);
00069
00070 virtual void pack(byte_array &packed_form) const;
00072 virtual bool unpack(byte_array &packed_form);
00074
00075 private:
00076 contents _theta;
00077
00078 contents to_internal(contents initial, angular_units unit) const;
00080 contents from_internal(contents initial, angular_units unit) const;
00082 };
00083
00085
00087
00088 class double_angle : public angle<double>
00089 {
00090 public:
00091 double_angle(double init = 0, angular_units unit = RADIANS)
00092 : angle<double>(init, unit) {}
00093 double_angle(const angle<double> &to_copy) : angle<double>(to_copy) {}
00094 };
00095
00096 }
00097
00098 #endif
00099