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 = 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;
174 inline T& operator[] (
int ind) {
175 assert(ind > -1 && ind < 2);
183 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p) {
184 return os <<
"(" << p.x <<
":" << p.y <<
")";
187 typedef PointType2D<int> Point;
188 typedef PointType2D<double> DoublePoint;
208 explicit PointType3D(T _x = 0, T _y = 0, T _z = 0): x(_x), y(_y), z(_z) {
261 return x == p.x && y == p.y && z == p.z;
267 return !(x == p.x && y == p.y && z == p.z);
274 sq = x*x + y*y + z*z;
275 return static_cast<T
>(sqrt(sq));
281 T invLength = 1.0/
length();
284 if (invLength > static_cast<T>(Mathd::zeroTolerance())) {
296 inline T& operator[] (
int ind) {
297 assert(ind > -1 && ind < 3);
305 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p) {
306 return os <<
"(" << p.x <<
":" << p.y <<
":" << p.z <<
")";
309 typedef PointType3D<int> Point3D;
310 typedef PointType3D<double> DoublePoint3D;
315 Point tmp(static_cast<int>(round(pt.x)), static_cast<int>(round(pt.y)));
322 Point3D tmp(static_cast<int>(round(pt.x)), static_cast<int>(round(pt.y)), static_cast<int>(round(pt.z)));
329 DoublePoint tmp(static_cast<double>(pt.x), static_cast<double>(pt.y));
336 DoublePoint3D tmp(static_cast<double>(pt.x), static_cast<double>(pt.y), static_cast<double>(pt.z));