point.h

Go to the documentation of this file.
00001 #ifndef POINT_CLASS
00002 #define POINT_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : point                                                             *
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 "angle.h"
00019 
00020 #include <basis/object_base.h>
00021 
00023 
00024 namespace geometric {
00025 
00027 
00028 template <class numeric_type>
00029 class point : public packable, public virtual object_base
00030 {
00031 public:
00032   point(numeric_type x = 0, numeric_type y = 0);
00033   point(numeric_type r, double_angle theta);
00034 
00035   IMPLEMENT_CLASS_NAME("point");
00036 
00037   void set(numeric_type x, numeric_type y);
00038   void set(numeric_type r, double_angle theta);
00039 
00040   numeric_type x() const { return _x; }
00041   numeric_type y() const { return _y; }
00042 
00043   numeric_type r() const;
00044   double_angle theta() const;
00045 
00046   point rotate(const double_angle &theta) const;
00048 
00053   numeric_type distance(const point &p2) const;
00055 
00056   point operator - () const { return point<numeric_type>(-_x, -_y); }
00058 
00059   numeric_type magnitude() const;
00061 
00062   point operator + (const point &arg2) const;
00063   point operator - (const point &arg2) const;
00064   point &operator += (const point &arg2);
00065   point &operator -= (const point &arg2);
00066   bool operator == (const point &arg2) const;
00067   bool operator != (const point &arg2) const;
00068 
00069   istring text_form() const;
00071 
00072   bool from_text(const istring &text);
00074 
00075   virtual void pack(byte_array &packed_form) const;
00076   virtual bool unpack(byte_array &packed_form);
00077 
00078 private:
00079   numeric_type _x;
00080   numeric_type _y;
00081 };
00082 
00083 } // namespace.
00084 
00085 #endif
00086 

Generated on Fri Nov 28 04:29:15 2008 for HOOPLE Libraries by  doxygen 1.5.1