22 #ifndef FIFE_VIDEO_POINT_H 23 #define FIFE_VIDEO_POINT_H 112 return x == p.
x &&
y == p.
y;
118 return !(
x == p.
x &&
y == p.
y);
132 T invLength =
static_cast<T
>(1.0/
length());
149 T theta = (angle *
static_cast<T
>(
Mathd::pi()))/180;
150 T costheta =
static_cast<T
>(
Mathd::Cos(theta));
151 T sintheta =
static_cast<T
>(
Mathd::Sin(theta));
156 x = costheta * nx - sintheta * ny;
157 y = sintheta * nx + costheta * ny;
164 T theta = (angle *
static_cast<T
>(
Mathd::pi()))/180;
165 T costheta =
static_cast<T
>(
Mathd::Cos(theta));
166 T sintheta =
static_cast<T
>(
Mathd::Sin(theta));
171 x = costheta * nx - sintheta * ny;
172 y = sintheta * nx + costheta * ny;
177 void set(T _x, T _y) {
183 assert(ind > -1 && ind < 2);
191 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p) {
192 return os <<
"(" << p.x <<
":" << p.y <<
")";
285 sq =
x*
x +
y*
y + z*z;
292 T invLength =
static_cast<T
>(1.0/
length());
309 void set(T _x, T _y, T _z) {
316 assert(ind > -1 && ind < 3);
324 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p) {
325 return os <<
"(" << p.x <<
":" << p.y <<
":" << p.z <<
")";
336 Point tmp(static_cast<int32_t>(round(pt.
x)), static_cast<int32_t>(round(pt.
y)));
343 Point3D tmp(static_cast<int32_t>(round(pt.
x)), static_cast<int32_t>(round(pt.
y)), static_cast<int32_t>(round(pt.
z)));
350 DoublePoint tmp(static_cast<double>(pt.
x), static_cast<double>(pt.
y));
357 DoublePoint3D tmp(static_cast<double>(pt.
x), static_cast<double>(pt.
y), static_cast<double>(pt.
z));
T length() const
Return length.
void rotate(const PointType2D< T > &origin, T angle)
Rotates the point around an origin.
PointType3D< T > operator-(const PointType3D< T > &p) const
Vector substraction.
PointType2D(T _x=0, T _y=0)
Constructor.
PointType2D< T > operator*(const T &i) const
Scalar multiplication with an integer value.
PointType3D< T > operator*(const T &i) const
Scalar multiplication with an integer value.
bool operator==(const PointType3D< T > &p) const
Equality comparision.
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.
std::vector< Point > PointVector
PointType3D< T > operator+(const PointType3D< T > &p) const
Vector addition.
PointType3D< int32_t > Point3D
PointType2D< double > DoublePoint
std::vector< DoublePoint3D > DoublePoint3DVector
PointType2D< T > operator+(const PointType2D< T > &p) const
Vector addition.
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.
std::vector< Point3D > Point3DVector
static num_type zeroTolerance()
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.
bool operator!=(const PointType2D< T > &p) const
Equality comparision.
Point doublePt2intPt(DoublePoint pt)
Convert from 2D double point to 2D int32_t point.
bool operator!=(const PointType3D< T > &p) const
Equality comparision.
PointType3D< T > operator/(const T &i) const
Scalar division with an integer value.
std::vector< DoublePoint > DoublePointVector
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.
PointType2D< T > operator/(const T &i) const
Scalar division with an integer value.
T length() const
Return length.
void normalize()
Normalizes the point.
PointType2D< T > operator-(const PointType2D< T > &p) const
Vector substraction.