18 namespace artec {
namespace sdk {
namespace base
23 #pragma warning(disable: 4201)
25 template <
typename T >
class Point3;
26 template <
typename T >
class Point4;
29 template <
typename Tf >
bool isZero(
const Tf & some)
31 return some <= std::numeric_limits< Tf >::epsilon() &&
32 some >= -std::numeric_limits< Tf >::epsilon();
39 template <
typename T >
75 {
Point2<T> ret = *
this;
return ret += val; }
77 {
Point2<T> ret = *
this;
return ret -= val; }
79 {
Point2<T> ret = *
this;
return ret *= val; }
81 {
Point2<T> ret = *
this;
return ret /= val; }
113 return (p1.
x*p2.
x + p1.
y*p2.
y);
117 operator T * () {
return data; }
118 operator const T * ()
const {
return data; }
171 return (p1 - p2).lengthSquared();
177 return (p1.
x*p2.
x + p1.
y*p2.
y);
181 template <
typename T,
typename T2 >
inline
183 template <
typename T,
typename T2 >
inline
185 template <
typename T,
typename T2 >
inline
194 template <
typename T>
203 explicit Point3(T tx, T ty, T tz) :
x(tx),
y(ty),
z(tz) {}
230 {
Point3<T> ret = *
this;
return ret += val; }
232 {
Point3<T> ret = *
this;
return ret -= val; }
234 {
Point3<T> ret = *
this;
return ret *= val; }
236 {
Point3<T> ret = *
this;
return ret /= val; }
277 return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z);
283 return Point3<T>(p1.y*p2.z - p1.z*p2.y, p1.z*p2.x - p1.x*p2.z, p1.x*p2.y - p1.y*p2.x);
287 operator T * () {
return data; }
288 operator const T * ()
const {
return data; }
312 return *
this /
static_cast<T
>(len);
342 return (p1 - p2).lengthSquared();
360 template <
typename T >
369 explicit Point4(T tx, T ty, T tz, T tw) :
x(tx),
y(ty),
z(tz),
w(tw) {}
396 {
Point4<T> ret = *
this;
return ret += val; }
398 {
Point4<T> ret = *
this;
return ret -= val; }
400 {
Point4<T> ret = *
this;
return ret *= val; }
402 {
Point4<T> ret = *
this;
return ret /= val; }
434 return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z + p1.w*p2.w);
438 operator T * () {
return data; }
439 operator const T * ()
const {
return data; }
494 return (p1 - p2).lengthSquared();
Point2< T > operator+(const T2 &val, const Point2< T > &p)
Arithmetical operators of the form: operator(scalar, TPoint2)
Point3< T > & operator/=(const T2 &val)
Point2 normalized() const
Point3 operator-(const Point3 &p2) const
bool isZero() const
"Zero" checking
Point2 operator-() const
Unary minus.
Point2< T > operator*(const T2 &val) const
Point4 & operator=(const Point3< T > &ot)
Point3(const Point4< T > &ot)
Point4 conversion.
bool operator>=(const Point4 &p2) const
Point3 & operator*=(const Point3 &ot)
bool operator==(const Point3 &p2) const
bool operator<(const Point3 &p2) const
Point3 operator*(const Point3 &p2) const
Point2(const Point3< T > &ot)
Point3 conversion.
Point4< T > operator+(const T2 &val) const
double lengthSquared() const
Square of distance of the point from the origin.
bool operator>(const Point4 &p2) const
bool operator<(const Point2 &p2) const
Point4 normalized() const
bool operator<(const Point4 &p2) const
Point3< Type2 > operator*(const GenericMatrix< 3, 3, Type > &matrix, const Point3< Type2 > &point)
bool operator>=(const Point3 &p2) const
void reset()
Reset values to default.
Point2()
Constructor. Empty for fast point array allocation.
Point3< T > operator+(const T2 &val) const
bool operator<=(const Point4 &p2) const
Point3< T > operator-(const T2 &val) const
T distanceSquare(const Point2< T > &p1, const Point2< T > &p2)
Distance measure (squared)
Point3 & operator=(const Point4< T > &ot)
Point3 & operator-=(const Point3 &ot)
Point4(T tx, T ty, T tz, T tw)
4-dimensional point class.
Point2< T > & operator+=(const T2 &val)
Point4 operator+(const Point4 &p2) const
Point2 & operator*=(const Point2 &ot)
double lengthSquared() const
Square of distance of the point from the origin.
Point3(const Point3 &ot)
Copying constructor.
bool operator!=(const Point4 &p2) const
Point2 operator+(const Point2 &p2) const
bool operator>(const Point2 &p2) const
void normalize()
Normalization to unit vector in the Euclidean norm.
Point2 & operator=(const Point3< T > &ot)
Point3(const Point3< T2 > &ot)
Type conversion.
Point4 & operator=(const Point2< T > &ot)
bool operator<=(const Point3 &p2) const
void normalize()
Normalization to unit vector in the euclidean norm.
bool operator>(const Point3 &p2) const
Point4 & operator/=(const Point4 &ot)
Point4< T > & operator-=(const T2 &val)
2-dimensional point class.
bool operator<=(const Point2 &p2) const
Point3 normalized() const
Point3< T > crossProduct(const Point3< T > &p1, const Point3< T > &p2)
Cross product of two points.
Point2 & operator=(const Point4< T > &ot)
Point3 operator-() const
Unary minus.
Point4< T > operator-(const T2 &val) const
Point4 operator*(const Point4 &p2) const
Point4 operator-() const
Unary minus.
Point4< T > & operator*=(const T2 &val)
Point2 operator/(const Point2 &p2) const
Point2< T > operator-(const T2 &val) const
3-dimensional point class.
Point4 & operator*=(const Point4 &ot)
Point2 & operator+=(const Point2 &ot)
Point2(const Point2 &ot)
Copying constructor.
Point3< T > & operator+=(const T2 &val)
Point4(const Point4< T2 > &ot)
Type conversion.
Point3< T > & operator*=(const T2 &val)
void normalize()
Normalizing to unit vector in the Euclidean norm.
static T dot(const Point4< T > &p1, const Point4< T > &p2)
Inner product operator.
Point2(const Point4< T > &ot)
Point4 conversion.
Point3 & operator/=(const Point3 &ot)
Point4< T > & operator+=(const T2 &val)
Point4()
Constructor. Empty for allocation of the fast points array.
Point3(const Point2< T > &ot)
Point2 conversion.
Point4 & operator=(const Point4 &ot)
Assignment operator.
double length() const
Distance of the point from the origin.
Point4< T > operator*(const T2 &val) const
bool operator==(const Point2 &p2) const
Point2< T > operator-(const T2 &val, const Point2< T > &p)
Point4 & operator+=(const Point4 &ot)
Point4 operator-(const Point4 &p2) const
static T dot(const Point2< T > &p1, const Point2< T > &p2)
Inner product operator.
bool operator==(const Point4 &p2) const
Point2< int > Point2I
Commonly used point shortcuts.
Point3< T > operator*(const T2 &val) const
Point4< T > & operator/=(const T2 &val)
static T dot(const Point3< T > &p1, const Point3< T > &p2)
Inner product operator.
Point3 operator/(const Point3 &p2) const
bool operator>=(const Point2 &p2) const
T dotProduct(const Point2< T > &p1, const Point2< T > &p2)
Cross product of two points.
Point4(const Point4 &ot)
Copying constructor.
void reset()
Reset values to default.
void reset()
Reset values to default.
Point2 & operator=(const Point2 &ot)
Assignment operator.
bool operator!=(const Point3 &p2) const
bool isZero() const
"Zero" checking
Point3< T > operator/(const T2 &val) const
Point3 & operator+=(const Point3 &ot)
Point4< T > operator/(const T2 &val) const
Point3 & operator=(const Point3 &ot)
Assignment operator.
static Point3< T > cross(const Point3< T > &p1, const Point3< T > &p2)
Cross product of two points.
bool isZero() const
"Zero" checking
bool isZero(const Tf &some)
Equality expression for the types which are not exact.
Point2 & operator-=(const Point2 &ot)
Point4 & operator-=(const Point4 &ot)
Point3 & operator=(const Point2< T > &ot)
Point3()
Constructor. Empty for fast point-array allocation.
Point4(const Point2< T > &ot)
Point2 conversion.
double lengthSquared() const
Square of length of point.
Point2< T > operator+(const T2 &val) const
Point4(const Point3< T > &ot)
Point3 conversion.
Point2(const Point2< T2 > &ot)
Type conversion.
Point2 operator*(const Point2 &p2) const
bool operator!=(const Point2 &p2) const
Point2< T > & operator-=(const T2 &val)
Point2 operator-(const Point2 &p2) const
Point2< T > & operator/=(const T2 &val)
Point2< T > operator/(const T2 &val) const
Point2< T > & operator*=(const T2 &val)
Point2 & operator/=(const Point2 &ot)
Point3 operator+(const Point3 &p2) const
double length() const
Length of point.
Point3< T > & operator-=(const T2 &val)
Point4 operator/(const Point4 &p2) const
double length() const
Distance of the point from the origin.