_Point2.h

Go to the documentation of this file.
00001 #ifndef __VECMATH_POINT2_HPP
00002 #define __VECMATH_POINT2_HPP
00003 
00004 #ifndef __VECMATH_TUPLE2_HPP
00005 #include <vecmath/_Tuple2.h>
00006 #endif
00007 
00008 //#define DEBUGPOINT2(d) d
00009 #define DEBUGPOINT2(d)
00010 
00011 template <class Type>
00012     class VECMATH_EXPORT _Point2 : public _Tuple2<Type> {
00013 public:
00014 
00015     _Point2<Type>() : _Tuple2<Type>() {}
00016 
00017     explicit _Point2<Type>(Type x, Type y = 0) : _Tuple2<Type>(x, y) {
00018         DEBUGPOINT2(cout << "_Point2 explicit constructor x,y " << *this << endl);
00019     }
00020 
00021     _Point2<Type>(const _Tuple2<double>& v) : _Tuple2<Type>(v) {
00022         DEBUGPOINT2(cout << "_Point2 constructor &double " << *this << endl);
00023     }
00024 
00025     _Point2<Type>(const _Tuple2<float>& v) : _Tuple2<Type>(v) {
00026         DEBUGPOINT2(cout << "_Point2 constructor &float " << *this << endl);
00027     }
00028 
00029     _Point2<Type>(const Type t[2]) : _Tuple2<Type>(t) {
00030         DEBUGPOINT2(cout << "_Point2 constructor t[2] " << *this << endl);
00031     }
00032 
00033     Type distanceSquared(const _Point2<Type>& p) const {
00034         return Math::sqr(_Point2<Type>::x - p.x) + Math::sqr(_Point2<Type>::y - p.y);
00035     }
00036 
00037     Type distance(const _Point2<Type>& p) const {
00038         return sqrt(distanceSquared(p));
00039     }
00040 
00041     Type distanceL1(const _Point2<Type>& p) const {
00042         return fabs(_Point2<Type>::x - p.x) + fabs(_Point2<Type>::y - p.y);
00043     }
00044 
00045     Type distanceLinf(const _Point2<Type>& p) const {
00046         return (Type) Math::max(fabs(_Point2<Type>::x - p.x), fabs(_Point2<Type>::y - p.y));
00047     }
00048 };
00049 
00050 #endif

Generated on Thu Sep 29 13:39:44 2005 for vecmath by  doxygen 1.4.4