angle.h

Go to the documentation of this file.
00001 #ifndef ANGLE_CLASS
00002 #define ANGLE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : angle                                                             *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1992-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
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 } // namespace.
00097 
00098 #endif
00099 

Generated on Wed Nov 19 04:28:49 2008 for HOOPLE Libraries by  doxygen 1.5.1