33 KoPoint() { m_x = 0; m_y = 0; }
34 KoPoint( const double &x, const double &y) : m_x(x), m_y(y) {}
35 explicit KoPoint( const TQPoint & p) : m_x(p.x()), m_y(p.y()) {}
38 bool operator==( const KoPoint &rhs) const { return TQABS(m_x-rhs.x()) < 1E-10 && TQABS(m_y-rhs.y()) < 1E-10; }
39 bool operator!=( const KoPoint &rhs) const { return TQABS(m_x-rhs.x()) > 1E-10 || TQABS(m_y-rhs.y()) > 1E-10; }
41 bool isNull() const { return m_x == 0 && m_y == 0; }
43 double x() const { return m_x; }
44 double y() const { return m_y; }
45 void setX( const double &x) { m_x = x; }
46 void setY( const double &y) { m_y = y; }
48 double &rx() { return m_x; }
49 double &ry() { return m_y; }
51 KoPoint &operator=( const KoPoint &rhs) { m_x = rhs.x(); m_y = rhs.y(); return * this; }
52 KoPoint &operator+=( const KoPoint &rhs ) { m_x += rhs.x(); m_y += rhs.y(); return * this; }
53 KoPoint &operator-=( const KoPoint &rhs ) { m_x -= rhs.x(); m_y -= rhs.y(); return * this; }
54 KoPoint &operator*=( const double &c ) { m_x *= c; m_y *= c; return * this; }
56 friend inline KoPoint operator+( const KoPoint &, const KoPoint & );
57 friend inline KoPoint operator-( const KoPoint &, const KoPoint & );
58 friend inline KoPoint operator*( const KoPoint &, const double & );
59 friend inline KoPoint operator*( const double &, const KoPoint & );
60 friend inline double operator*( const KoPoint &a, const KoPoint &b );
63 void setCoords( const double &x, const double &y) { m_x = x; m_y = y; }
64 KoPoint transform ( const TQWMatrix &m) const
67 m.map(m_x, m_y, &x, &y);
71 bool isNear( const KoPoint &p, double range) const
73 return (p.x() >= m_x - range && p.x() <= m_x + range && p.y() >= m_y - range && p.y() <= m_y + range);
76 static double getAngle( const KoPoint& p1, const KoPoint& p2 ) {
77 double a = atan2( p2.x() - p1.x(), p2.y() - p1.y() ) + M_PI;
78 return ( ( - ( a * 360 ) / ( 2 * M_PI ) - 90 ) - 180 );
81 double manhattanLength() const
83 return TQABS( m_x ) + TQABS( m_y );
89 return TQPoint( tqRound( m_x ), tqRound( m_y ) );
97{ return KoPoint( p1.m_x+p2.m_x, p1.m_y+p2.m_y ); }
100{ return KoPoint( p1.m_x-p2.m_x, p1.m_y-p2.m_y ); }
103{ return KoPoint( p.m_x*c, p.m_y*c ); }
106{ return KoPoint( p.m_x*c, p.m_y*c ); }
109{ return a.m_x * b.m_x + a.m_y * b.m_y; }
118#define DEBUGDOUBLE(d) TQString::number( (d), 'g', 20 )
120inline kdbgstream operator<<( kdbgstream str, const KoPoint & r ) {
122 str << "(" << r.x() << ", " << r.y() << ")";
126inline kndbgstream operator<<( kndbgstream str, const KoPoint & ) { return str; }
A point whose coordinates are floating-point values ( "double"s ).
TQPoint toTQPoint() const Convert to a TQPoint - with precision loss!
|