27# pragma warning( push )
28# pragma warning(disable:4250)
32#include <Inventor/STL/iostream>
33#include <Inventor/STL/limits>
59 return MbVec3<_T>((std::numeric_limits<_T>::max)());
65 vec[0] = vec[1] = vec[2] = 0;
70 vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2];
76 vec[0] = x; vec[1] =
y; vec[2] = z;
79 template <
typename _Type >
82 vec[0] = (_T) x; vec[1] = (_T)
y; vec[2] = (_T) z;
88 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
94 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
100 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
106 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
112 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
118 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
124 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
129 explicit MbVec3(
unsigned long v)
131 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
138 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
144 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
150 vec[0] = (_T)v; vec[1] = (_T)v; vec[2] = (_T)v;
154 template<
typename _MbVec3T>
167 return MbVec3<_T>(vec[1] * v.vec[2] - vec[2] * v.vec[1],
168 vec[2] * v.vec[0] - vec[0] * v.vec[2],
169 vec[0] * v.vec[1] - vec[1] * v.vec[0]);
177 return (vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]);
190 x = vec[0];
y = vec[1]; z = vec[2];
198 return _T(
sqrt(
double(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2])));
211 vec[0] = -vec[0]; vec[1] = -vec[1]; vec[2] = -vec[2];
219 return MbVec3<_T>(vec[0] * v.vec[0], vec[1] * v.vec[1],vec[2] * v.vec[2]) ;
227 return MbVec3<_T>(vec[0] / v.vec[0], vec[1] / v.vec[1],vec[2] / v.vec[2]) ;
235 vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2];
return *
this;
243 vec[0] = x; vec[1] =
y; vec[2] = z;
return *
this;
261 vec[0] = vec[1] = vec[2] = d;
323 return MbVec3(v1.vec[0] * v2.vec[0], v1.vec[1] * v2.vec[1], v1.vec[2] * v2.vec[2]);
331 return MbVec3<_T>(v.vec[0] * d, v.vec[1] * d, v.vec[2] * d);
345 return MbVec3<_T>(v.vec[0] / d, v.vec[1] / d, v.vec[2] / d);
353 return MbVec3(v1.vec[0] / v2.vec[0], v1.vec[1] / v2.vec[1], v1.vec[2] / v2.vec[2]);
361 return MbVec3(v1.vec[0] + v2.vec[0], v1.vec[1] + v2.vec[1], v1.vec[2] + v2.vec[2]);
369 return MbVec3(v.vec[0] + d, v.vec[1] + d, v.vec[2] + d);
377 return MbVec3(v.vec[0] + d, v.vec[1] + d, v.vec[2] + d);
385 return MbVec3(v1.vec[0] - v2.vec[0], v1.vec[1] - v2.vec[1], v1.vec[2] - v2.vec[2]);
393 return MbVec3(v.vec[0] - d, v.vec[1] - d, v.vec[2] - d);
409 return (v1.vec[0] == v2.vec[0] && v1.vec[1] == v2.vec[1] && v1.vec[2] == v2.vec[2]);
459 return diff.
dot(diff) <= tolerance;
468 return this->
equals(v,std::numeric_limits<_T>::epsilon());
486 return areCollinear(v1,v2,std::numeric_limits<_T>::epsilon());
494 return os <<
"(" << v.vec[0] <<
"," << v.vec[1] <<
"," << v.vec[2] <<
")";
501template <
typename _T>
535# pragma warning( pop )
void setValue(valueRef newValue)
Sets this field to newValue.
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Class defining a vector ...
MbVec3< _T > & setValue(_T x, _T y, _T z)
Sets the vector components.
bool equals(const MbVec3 &v) const
Equality comparison within the machine epsilon given by the numeric_limits<_T> Square of the length o...
friend bool operator>(const MbVec3 &v1, const MbVec3 &v2)
Length comparison operator.
bool equals(const MbVec3 &v, _T tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
friend bool operator==(const MbVec3 &v1, const MbVec3 &v2)
Equality comparison operator.
MbVec3(const _MbVec3T &v)
Constructor.
MbVec3(_Type x, _Type y, _Type z)
friend bool operator<=(const MbVec3 &v1, const MbVec3 &v2)
Length comparison operator.
void negate()
Negates each component of vector in place.
MbVec3 & operator=(_T d)
Component-wise setting.
MbVec3 & operator-=(const MbVec3 &v)
Component-wise vector subtraction operator.
_T length() const
Returns geometric length of vector.
friend MbVec3 operator*(const MbVec3 &v1, const MbVec3 &v2)
Component-wise vector multiplication operator.
void getValue(_T &x, _T &y, _T &z) const
Returns vector components.
const _T * getValue() const
Returns pointer to vector components.
MbVec3 div(const MbVec3< _T > &v) const
Component-wise vector division.
friend std::ostream & operator<<(std::ostream &os, const MbVec3 &v)
Writes the vector to the specified output stream.
MbVec3(long v)
Constructor.
MbVec3 cross(const MbVec3< _T > &v) const
Returns right-handed cross product of vector and another vector.
MbVec3< _T > & setValue(const _T v[3])
Sets the vector components.
MbVec3 mult(const MbVec3< _T > &v) const
Component-wise vector multiplication.
MbVec3(double v)
Constructor.
MbVec3(char v)
Constructor.
static MbVec3 numeric_limit_max()
Returns the maximum value for a vector.
_T dot(const MbVec3< _T > &v) const
Returns dot (inner) product of vector and another vector.
MbVec3 & operator/=(_T d)
Component-wise scalar division operator.
friend bool areCollinear(const MbVec3< _T > &v1, const MbVec3< _T > &v2, _T tol)
Returns true if vectors are collinear within the given tolerance.
MbVec3 operator-() const
Nondestructive unary negation - returns a new vector.
friend bool operator!=(const MbVec3 &v1, const MbVec3 &v2)
Inequality comparison operator.
friend MbVec3 operator+(const MbVec3 &v1, const MbVec3 &v2)
Component-wise binary vector addition operator.
MbVec3 & operator+=(const MbVec3 &v)
Component-wise vector addition operator.
friend MbVec3 sqrt(const MbVec3 &v)
Component-wise vector square root operator.
_T & operator[](int i)
Accesses indexed component of vector.
MbVec3()
Constructor (vector is initialized to zero values)
_T normalize()
Changes vector to be unit length, returning the length before normalization.
friend MbVec3 operator/(const MbVec3 &v, _T d)
Component-wise binary scalar division operator.
MbVec3(unsigned short v)
Constructor.
MbVec3(int v)
Constructor.
MbVec3(const _T v[3])
Constructor.
friend bool operator>=(const MbVec3 &v1, const MbVec3 &v2)
Length comparison operator.
friend bool operator<(const MbVec3 &v1, const MbVec3 &v2)
Length comparison operator.
MbVec3(long double v)
Constructor.
MbVec3(short v)
Constructor.
MbVec3 & operator*=(_T d)
Component-wise scalar multiplication operator.
MbVec3(unsigned char v)
Constructor.
MbVec3(_T x, _T y, _T z)
Constructor.
friend bool areCollinear(const MbVec3< _T > &v1, const MbVec3< _T > &v2)
Returns true if vectors are collinear within the machine epsilon given by the numeric_limits<_T>
MbVec3(size_t v)
Constructor.
MbVec3(float v)
Constructor.
MbVec3< double > MbVec3d
Vector of 3 double coordinates.
MbVec3< float > MbVec3f
Vector of 3 float coordinates.
MbVec3< size_t > MbVec3ui
Vector of 3 unsigned int.
bool isCoinc(const T &x, const T &y, T tol=(T) OIV_DEF_MATH_HELPER_EPS)
Coincidence test using given tolerance.