36 template<
typename T,
int Size>
67 for (
int i = 0; i < Size; ++i)
69 result += this->
Data[i] * this->
Data[i];
80 return sqrt(static_cast<double>(this->
SquaredNorm()));
90 const double norm(this->
Norm());
91 const double inv(1.0 / norm);
92 for (
int i = 0; i < Size; ++i)
94 this->
Data[i] = static_cast<T>(this->
Data[i] * inv);
120 for (
int i = 0; i < Size; ++i)
122 result += this->
Data[i] * other[i];
132 template<
typename TR>
136 for (
int i = 0; i < Size; ++i)
138 result[i] = static_cast<TR>(this->
Data[i]);
173 void Set(
const T& x,
const T& y)
240 void Set(
const T& x,
const T& y,
const T& z)
299 (this->
Data[0] == v.
Data[0] && this->Data[1] == v.
Data[1] && this->Data[2] < v.
Data[2]);
334 void Set(
const T& x,
const T& y,
const T& z,
const T& w)
388 #define vtkVectorNormalized(vectorType, type, size) \ 389 vectorType Normalized() const \ 391 return vectorType(vtkVector<type, size>::Normalized().GetData()); \ 394 #define vtkVectorDerivedMacro(vectorType, type, size) \ 395 vtkVectorNormalized(vectorType, type, size) \ 396 explicit vectorType(type s) : Superclass(s) {} \ 397 explicit vectorType(const type *i) : Superclass(i) {} \ 398 explicit vectorType(const vtkTuple<type, size> &o) : Superclass(o.GetData()) {} \ 399 vectorType(const vtkVector<type, size> &o) : Superclass(o.GetData()) {} \ 433 #define vtkVector3Cross(vectorType, type) \ 434 vectorType Cross(const vectorType& other) const \ 436 return vectorType(vtkVector3<type>::Cross(other).GetData()); \ 479 #endif // vtkVector_h vtkVector3< T > Cross(const vtkVector3< T > &other) const
Return the cross product of this X other.
T Data[Size]
The only thing stored in memory!
#define vtkVector3Cross(vectorType, type)
void SetZ(const T &z)
Set the z component of the vector, i.e.
vtkVector2(const T &scalar)
void SetY(const T &y)
Set the y component of the vector, i.e.
double Normalize()
Normalize the vector in place.
vtkVector4(const T &scalar)
#define vtkVectorDerivedMacro(vectorType, type, size)
vtkVector3< float > Superclass
templated base type for storage of vectors.
vtkVector3< int > Superclass
vtkVector< T, Size > Normalized() const
Return the normalized form of this vector.
vtkVector2i(int x, int y)
double Norm() const
Get the norm of the vector, i.e.
vtkVector2(const T *init)
void Set(const T &x, const T &y)
Set the x and y components of the vector.
void SetX(const T &x)
Set the x component of the vector, i.e.
const T & GetW() const
Get the w component of the vector, i.e.
vtkVector4d(double x, double y, double z, double w)
vtkVector3d(double x, double y, double z)
vtkVector2< int > Superclass
vtkVector3(const T &scalar)
const T & GetX() const
Get the x component of the vector, i.e.
vtkVector3< double > Superclass
vtkVector2f(float x, float y)
vtkVector2< double > Superclass
vtkVector(const T &scalar)
Initialize all of the vector's elements with the supplied scalar.
vtkVector2d(double x, double y)
void SetW(const T &w)
Set the w component of the vector, i.e.
templated base type for containers of constant size.
vtkVector4(const T &x, const T &y, const T &z, const T &w)
vtkVector3i(int x, int y, int z)
vtkVector2(const T &x, const T &y)
void SetX(const T &x)
Set the x component of the vector, i.e.
bool operator<(const vtkVector3< T > &v) const
Lexicographical comparison of two vector.
void Set(const T &x, const T &y, const T &z, const T &w)
Set the x, y, z and w components of a 3D vector in homogeneous coordinates.
void Set(const T &x, const T &y, const T &z)
Set the x, y and z components of the vector.
void SetY(const T &y)
Set the y component of the vector, i.e.
vtkVector(const T *init)
Initialize the vector's elements with the elements of the supplied array.
vtkVector2< float > Superclass
bool operator<(const vtkVector2< T > &v) const
Lexicographical comparison of two vector.
Some derived classes for the different vectors commonly used.
const T & GetY() const
Get the y component of the vector, i.e.
const T & GetX() const
Get the x component of the vector, i.e.
vtkVector< TR, Size > Cast() const
Cast the vector to the specified type, returning the result.
vtkVectorDerivedMacro(vtkVector3i, int, 3) vtkVector3Cross(vtkVector3i
const T & GetY() const
Get the y component of the vector, i.e.
T SquaredNorm() const
Get the squared norm of the vector.
vtkVector3(const T &x, const T &y, const T &z)
void SetX(const T &x)
Set the x component of the vector, i.e.
void SetZ(const T &z)
Set the z component of the vector, i.e.
vtkVector3(const T *init)
const T & GetX() const
Get the x component of the vector, i.e.
T Dot(const vtkVector< T, Size > &other) const
The dot product of this and the supplied vector.
void SetY(const T &y)
Set the y component of the vector, i.e.
const T & GetZ() const
Get the z component of the vector, i.e.
vtkVector4(const T *init)
const T & GetY() const
Get the y component of the vector, i.e.
const T & GetZ() const
Get the z component of the vector, i.e.
vtkVector3f(float x, float y, float z)