31 #ifndef PT_GFX_POINT_H
32 #define PT_GFX_POINT_H
34 #include <Pt/Gfx/Api.h>
60 : _x(pt._x), _y(pt._y)
122 template<
typename T2>
125 if (*
this == otherPoint)
130 return (T)(
hypot(this->
x() - otherPoint.
x(), this->
y() - otherPoint.
y()));
135 _x = pt._x; _y = pt._y;
140 {
return (_x == pt._x && _y == pt._y); }
143 {
return (_x != pt._x || _y != pt._y); }
147 if ( _x < pt._x || _y < pt._y)
150 return ( (*
this) != pt );
155 if ( _x > pt._x || _y > pt._y )
158 return ( pt != (*
this) );
161 inline const BasicPoint operator+=(
const BasicPoint<T>& pt)
168 inline BasicPoint operator+(
const BasicPoint<T>& pt)
const
170 return BasicPoint( (_x+pt.x()), (_y+pt.y()) );
173 inline const BasicPoint operator-=(
const BasicPoint<T>& pt)
180 inline BasicPoint operator-(
const BasicPoint<T>& pt)
const
182 return BasicPoint( (_x-pt.x()), (_y-pt.y()) );
185 inline BasicPoint operator*(
const double factor)
const
187 return BasicPoint( (T)(_x * factor), (T)(_y * factor) );
195 typedef BasicPoint<Pt::ssize_t> Point;
196 typedef BasicPoint<double> PointF;
198 inline Point round(
const PointF& r)
200 return Point(
lround(r.x()),
double hypot(double x, double y)
Return the euclidean distance of the given values.
Definition: Math.h:275
Point with X ynd X coordinates.
Definition: Point.h:45
T x() const
Return the X component of the BasicPoint.
Definition: Point.h:79
BasicPoint(T x, T y)
Construct a BasicPoint of (x,y)
Definition: Point.h:54
T calcDistance(const BasicPoint< T2 > &otherPoint) const
Calculate distance between this BasicPoint and the given BasicPoint.
Definition: Point.h:123
const BasicPoint & addY(T y)
Increment the Y component of the BasicPoint by the given value.
Definition: Point.h:100
T y() const
Return the Y component of the BasicPoint.
Definition: Point.h:83
void setX(T x_)
Set the X component of the BasicPoint.
Definition: Point.h:71
Pt::int32_t lround(float x)
Rounds to nearest integer value.
Definition: Math.h:289
void setY(T y_)
Set the Y component of the BasicPoint.
Definition: Point.h:75
const BasicPoint & subY(T y)
Decrement the Y component of the BasicPoint by the given value.
Definition: Point.h:107
const BasicPoint & subX(T x)
Decrement the X component of the BasicPoint by the given value.
Definition: Point.h:94
BasicPoint(const BasicPoint &pt)
Construct a BasicPoint from another BasicPoint.
Definition: Point.h:59
const BasicPoint & move(T dx, T dy)
Move the BasicPoint as far as th given the X and Y distances.
Definition: Point.h:114
BasicPoint()
Construct a BasicPoint of (0,0)
Definition: Point.h:49
void set(T x_, T y_)
Set the X and Y components of the BasicPoint.
Definition: Point.h:64
const BasicPoint & addX(T x)
Increment the X component of the BasicPoint by the given value.
Definition: Point.h:87