00001
00022 #ifndef KIG_MISC_COORDINATE_H
00023 #define KIG_MISC_COORDINATE_H
00024
00025 class TQPoint;
00026 class kdbgstream;
00027
00033 class Coordinate
00034 {
00035 public:
00036 static Coordinate fromTQPoint( const TQPoint& p );
00037
00041 Coordinate( double x, double y );
00045 Coordinate( const Coordinate& p );
00053 Coordinate();
00054 ~Coordinate() {}
00055
00067 static Coordinate invalidCoord();
00071 bool valid() const;
00072
00075 double distance ( const Coordinate& p ) const;
00080 double length () const;
00085 inline double squareLength() const;
00088 const Coordinate operator- () const;
00096 const Coordinate orthogonal() const;
00100 const Coordinate round() const;
00104 const Coordinate normalize( double length = 1 ) const;
00105 TQPoint toTQPoint() const;
00106
00107 Coordinate& operator= ( const Coordinate& c );
00110 Coordinate& operator+= ( const Coordinate& c );
00113 Coordinate& operator-= ( const Coordinate& c );
00116 Coordinate& operator*= ( double r );
00119 Coordinate& operator*= ( int r );
00122 Coordinate& operator/= ( double r );
00123 public:
00126 double x;
00129 double y;
00130
00131 friend kdbgstream& operator<<( kdbgstream& s, const Coordinate& t );
00134 friend const Coordinate operator+ ( const Coordinate& a, const Coordinate& b );
00137 friend const Coordinate operator- ( const Coordinate& a, const Coordinate& b );
00140 friend const Coordinate operator* ( const Coordinate& a, double r );
00143 friend const Coordinate operator/ ( const Coordinate& a, double r );
00146 friend double operator*( const Coordinate& a, const Coordinate& b );
00149 friend bool operator==( const Coordinate&, const Coordinate& );
00152 friend bool operator!=( const Coordinate&, const Coordinate& );
00153 };
00154
00155 const Coordinate operator/ ( const Coordinate& a, double r );
00156 kdbgstream& operator<<( kdbgstream& s, const Coordinate& t );
00157 const Coordinate operator+ ( const Coordinate& a, const Coordinate& b );
00158 const Coordinate operator- ( const Coordinate& a, const Coordinate& b );
00159 const Coordinate operator* ( const Coordinate& a, double r );
00160 const Coordinate operator* ( double r, const Coordinate& a );
00161 double operator*( const Coordinate& a, const Coordinate& b );
00162
00163 double Coordinate::squareLength() const
00164 {
00165 return x*x+y*y;
00166 }
00167
00168 #endif
00169
This file is part of the documentation for tdelibs .