22 #ifndef FIFE_VIDEO_POINT_H
23 #define FIFE_VIDEO_POINT_H
37 #include "util/base/fife_stdint.h"
38 #include "util/math/fife_math.h"
111 return x == p.x && y == p.y;
117 return !(x == p.x && y == p.y);
125 return static_cast<T
>(Mathd::Sqrt(sq));
131 T invLength =
static_cast<T
>(1.0/
length());
134 if (invLength > static_cast<T>(Mathd::zeroTolerance())) {
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;
181 inline T& operator[] (int32_t ind) {
182 assert(ind > -1 && ind < 2);
190 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p) {
191 return os <<
"(" << p.x <<
":" << p.y <<
")";
194 typedef PointType2D<int32_t> Point;
195 typedef PointType2D<double> DoublePoint;
215 explicit PointType3D(T _x = 0, T _y = 0, T _z = 0): x(_x), y(_y), z(_z) {
268 return x == p.x && y == p.y && z == p.z;
274 return !(x == p.x && y == p.y && z == p.z);
281 sq = x*x + y*y + z*z;
282 return static_cast<T
>(Mathd::Sqrt(sq));
288 T invLength =
static_cast<T
>(1.0/
length());
291 if (invLength > static_cast<T>(Mathd::zeroTolerance())) {
305 void set(T _x, T _y, T _z) {
311 inline T& operator[] (int32_t ind) {
312 assert(ind > -1 && ind < 3);
320 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p) {
321 return os <<
"(" << p.x <<
":" << p.y <<
":" << p.z <<
")";
324 typedef PointType3D<int32_t> Point3D;
325 typedef PointType3D<double> DoublePoint3D;
330 Point tmp(static_cast<int32_t>(round(pt.x)), static_cast<int32_t>(round(pt.y)));
337 Point3D tmp(static_cast<int32_t>(round(pt.x)), static_cast<int32_t>(round(pt.y)), static_cast<int32_t>(round(pt.z)));
344 DoublePoint tmp(static_cast<double>(pt.x), static_cast<double>(pt.y));
351 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)
PointType2D(T _x=0, T _y=0)
PointType3D< T > operator-(const PointType3D< T > &p) const
PointType3D< T > & operator-=(const PointType3D< T > &p)
PointType3D(const PointType3D< T > &rhs)
bool operator!=(const PointType2D< T > &p) const
PointType2D(const PointType2D< T > &rhs)
PointType2D< T > & operator+=(const PointType2D< T > &p)
PointType3D< T > & operator+=(const PointType3D< T > &p)
bool operator==(const PointType3D< T > &p) const
bool operator!=(const PointType3D< T > &p) const
PointType2D< T > & operator-=(const PointType2D< T > &p)
PointType3D(T _x=0, T _y=0, T _z=0)
Point doublePt2intPt(DoublePoint pt)
PointType2D< T > operator*(const T &i) const
bool operator==(const PointType2D< T > &p) const
PointType3D< T > operator+(const PointType3D< T > &p) const
PointType3D< T > operator/(const T &i) const
DoublePoint intPt2doublePt(Point pt)
void set(T _x, T _y, T _z)
PointType2D< T > operator-(const PointType2D< T > &p) const
PointType2D< T > operator+(const PointType2D< T > &p) const
PointType3D< T > operator*(const T &i) const
PointType2D< T > operator/(const T &i) const
credit to phoku for his NodeDisplay example which the visitor code is adapted from ( he coded the qua...