22 #ifndef FIFE_VIDEO_POINT_H
23 #define FIFE_VIDEO_POINT_H
111 return x == p.
x &&
y == p.
y;
117 return !(
x == p.
x &&
y == p.
y);
131 T invLength =
static_cast<T
>(1.0/
length());
148 T theta = (angle *
static_cast<T
>(
Mathd::pi()))/180;
149 T costheta =
static_cast<T
>(
Mathd::Cos(theta));
150 T sintheta =
static_cast<T
>(
Mathd::Sin(theta));
155 x = costheta * nx - sintheta * ny;
156 y = sintheta * nx + costheta * ny;
163 T theta = (angle *
static_cast<T
>(
Mathd::pi()))/180;
164 T costheta =
static_cast<T
>(
Mathd::Cos(theta));
165 T sintheta =
static_cast<T
>(
Mathd::Sin(theta));
170 x = costheta * nx - sintheta * ny;
171 y = sintheta * nx + costheta * ny;
182 assert(ind > -1 && ind < 2);
190 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p) {
191 return os <<
"(" << p.x <<
":" << p.y <<
")";
289 T invLength =
static_cast<T
>(1.0/
length());
306 void set(T _x, T _y, T _z) {
313 assert(ind > -1 && ind < 3);
321 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p) {
322 return os <<
"(" << p.x <<
":" << p.y <<
":" << p.z <<
")";
331 Point tmp(static_cast<int32_t>(round(pt.
x)), static_cast<int32_t>(round(pt.
y)));
338 Point3D tmp(static_cast<int32_t>(round(pt.
x)), static_cast<int32_t>(round(pt.
y)), static_cast<int32_t>(round(pt.
z)));
345 DoublePoint tmp(static_cast<double>(pt.
x), static_cast<double>(pt.
y));
352 DoublePoint3D tmp(static_cast<double>(pt.
x), static_cast<double>(pt.
y), static_cast<double>(pt.
z));
void rotate(const PointType2D< T > &origin, T angle)
Rotates the point around an origin.
PointType2D(T _x=0, T _y=0)
Constructor.
PointType3D< T > operator-(const PointType3D< T > &p) const
Vector substraction.
void normalize()
Normalizes the point.
PointType3D< T > & operator-=(const PointType3D< T > &p)
Vector inplace substraction.
PointType3D< double > DoublePoint3D
PointType3D(const PointType3D< T > &rhs)
Copy Constructor.
bool operator!=(const PointType2D< T > &p) const
Equality comparision.
PointType3D< int32_t > Point3D
PointType2D< double > DoublePoint
PointType2D(const PointType2D< T > &rhs)
Copy Constructor.
PointType2D< T > & operator+=(const PointType2D< T > &p)
Vector inplace addition.
PointType3D< T > & operator+=(const PointType3D< T > &p)
Vector inplace addition.
static num_type zeroTolerance()
bool operator==(const PointType3D< T > &p) const
Equality comparision.
bool operator!=(const PointType3D< T > &p) const
Equality comparision.
PointType2D< int32_t > Point
static bool Equal(T _val1, T _val2)
PointType2D< T > & operator-=(const PointType2D< T > &p)
Vector inplace substraction.
PointType3D(T _x=0, T _y=0, T _z=0)
Constructor.
T length() const
Return length.
Point doublePt2intPt(DoublePoint pt)
Convert from 2D double point to 2D int32_t point.
PointType2D< T > operator*(const T &i) const
Scalar multiplication with an integer value.
bool operator==(const PointType2D< T > &p) const
Equality comparision.
PointType3D< T > operator+(const PointType3D< T > &p) const
Vector addition.
PointType3D< T > operator/(const T &i) const
Scalar division with an integer value.
void rotate(T angle)
Rotates the point around the origin.
T & operator[](int32_t ind)
DoublePoint intPt2doublePt(Point pt)
Convert from 2D int32_t point to 2D double point.
void set(T _x, T _y, T _z)
Sets the x, y and z coordinates of the 3D point.
T length() const
Return length.
void normalize()
Normalizes the point.
PointType2D< T > operator-(const PointType2D< T > &p) const
Vector substraction.
PointType2D< T > operator+(const PointType2D< T > &p) const
Vector addition.
PointType3D< T > operator*(const T &i) const
Scalar multiplication with an integer value.
void set(T _x, T _y)
Sets the x and y coordinate of the 2D point.
PointType2D< T > operator/(const T &i) const
Scalar division with an integer value.
T & operator[](int32_t ind)