Algebra3D
Algebra for 3D transformations
|
A class to store vectors of 3 elements. More...
#include <Vector3.h>
Public Member Functions | |
Vector3 () | |
Vector3 (const fpType *const data) | |
Vector3 (fpType x, fpType y, fpType z) | |
Vector3 (const Vector3< fpType > &vec) | |
Vector3 (const Vector3< fpType > &axis, fpType angle) | |
Vector3 (const Quaternion< fpType > &quat) | |
Vector3 (const Matrix3< fpType > &mat) | |
virtual | ~Vector3 () |
virtual void | set (const fpType *data) |
virtual void | get (fpType *storage) const |
virtual fpType | dot (const Vector3< fpType > &vec) const |
virtual Vector3< fpType > | cross (const Vector3< fpType > &vec) const |
virtual Matrix3< fpType > | outer (const Vector3< fpType > &vec) const |
virtual Matrix3< fpType > | crossMatrix () const |
virtual fpType | getNorm () const |
virtual void | normalize () |
bool | isZero () const |
Vector3< fpType > | getUnit () const |
fpType | getAngle () const |
Vector3< fpType > | getSqrtRotation () const |
virtual void | operator= (const Vector3< fpType > &vec) |
virtual const fpType & | operator[] (int ind) const |
virtual fpType & | operator[] (int ind) |
virtual bool | compare (const Vector3< fpType > &vec, const fpType &precision=PRECISION) const |
virtual bool | operator== (const Vector3< fpType > &vec) const |
virtual bool | operator!= (const Vector3< fpType > &vec) const |
virtual void | operator+= (const Vector3< fpType > &vec) |
virtual Vector3< fpType > | operator+ (const Vector3< fpType > &vec) const |
virtual Vector3< fpType > | operator- () const |
virtual void | operator-= (const Vector3< fpType > &vec) |
virtual Vector3< fpType > | operator- (const Vector3< fpType > &vec) const |
void | operator*= (const Matrix3< fpType > &mat) |
virtual Vector3< fpType > | operator* (const Matrix3< fpType > &mat) const |
virtual Vector3< fpType > | operator* (const Vector3< fpType > &vec) const |
virtual void | operator*= (const fpType &s) |
virtual Vector3< fpType > | operator* (const fpType &s) const |
virtual void | operator/= (const fpType &s) |
virtual Vector3< fpType > | operator/ (const fpType &s) const |
Public Attributes | |
fpType & | x |
fpType & | y |
fpType & | z |
Protected Attributes | |
fpType | data [3] |
Friends | |
template<class fpT > | |
std::istream & | operator>> (std::istream &stream, Vector3< fpT > &vec) |
A class to store vectors of 3 elements.
algebra3d::Vector3< fpType >::Vector3 | ( | ) |
Creates an instance of a 0 vector.
algebra3d::Vector3< fpType >::Vector3 | ( | const fpType *const | data | ) |
Creates an instance using the provided data.
[in] | data | Reference to the data to initialize the vector with. |
algebra3d::Vector3< fpType >::Vector3 | ( | fpType | x, |
fpType | y, | ||
fpType | z | ||
) |
Initializes the vector with the provided values.
[in] | x | First coordinate. |
[in] | y | Second coordinate. |
[in] | z | Third coordinate. |
algebra3d::Vector3< fpType >::Vector3 | ( | const Vector3< fpType > & | vec | ) |
Copies elements of the provided vector into this one.
[in] | vec | The vector to copy. |
algebra3d::Vector3< fpType >::Vector3 | ( | const Vector3< fpType > & | axis, |
fpType | angle | ||
) |
Creates a Cayley vector for the provided rotation given by axis and angle.
[in] | axis | The rotation axis (not necessary a unit vector). |
[in] | angle | The angle of rotation. |
algebra3d::Vector3< fpType >::Vector3 | ( | const Quaternion< fpType > & | quat | ) |
Creates a Cayley vector for the provided rotation given by a quaternion.
[in] | quat | The quaternion representing the rotation. |
algebra3d::Vector3< fpType >::Vector3 | ( | const Matrix3< fpType > & | mat | ) |
Creates a Cayley vector for the provided rotation given by a matrix.
[in] | mat | The matrix of the rotation. |
|
virtual |
Does nothing. Virtual classes require virtual destructors.
|
virtual |
Checks if all elements of the provided vector are the same as in this one up to the provided precision. The comparison is simply checking if the difference between numbers is smaller or equal the precision.
[in] | vec | The vector to compare this with. |
[in] | precision | The precision to use; by default the global PRECISION is used. |
true
if all entries are equal up to the precision, false
otherwise.
|
virtual |
Returns the cross product of this vector with the provided one.
[in] | vec | The other vector of the cross product. |
|
virtual |
Returns the cross product matrix of this vector, i.e. a cross product operator for the vector.
|
virtual |
Returns the dot product of this vector and the provided one.
[in] | vec | The vector to multiply this by. |
|
virtual |
Copies the vector data to the provided array. First 3 positions from the given pointer are written).
[out] | storage | The array to copy the data to. |
fpType algebra3d::Vector3< fpType >::getAngle | ( | ) | const |
Returns the angle of rotation represented by this Cayley vector.
|
virtual |
Returns the L2 norm of the vector (sqrt(*this * *this)
).
sqrt(*this * *this)
). Vector3<fpType> algebra3d::Vector3< fpType >::getSqrtRotation | ( | ) | const |
Returns the Cayley vector representation of half of the rotation represented by this instance.
Vector3<fpType> algebra3d::Vector3< fpType >::getUnit | ( | ) | const |
Returns a unit vector in the direction of this one. For infinite and zero vectors their copies are returned.
bool algebra3d::Vector3< fpType >::isZero | ( | ) | const |
Returns true
if all components are 0 (up to the precision), false
otherwise.
true
if all components are 0 (up to the precision), false
otherwise.
|
virtual |
Normalizes the vector to unit length. Divides the vector by sqrt(*this * *this)
.
|
virtual |
Comparing operator. Checks if any element of this vector differs from respective element of the parameter.
[in] | vec | The vector to compare this with. |
false
if all entries are equal, true
otherwise.
|
virtual |
Returns the product of this vector and the provided matrix (v * m - vector treated as 1x3).
[in] | mat | The matrix to multiply this vector by. |
|
virtual |
Returns the effect of rotating the provided vector according to this Cayley vector.
[in] | vec | The vector to transform according to this Cayley vector. |
|
virtual |
Scales a copy of this vector by the provided number and returns it.
[in] | s | The scaling factor. |
void algebra3d::Vector3< fpType >::operator*= | ( | const Matrix3< fpType > & | mat | ) |
Post-multiplies this vector by the provided matrix (v * m - vector treated as a 1x3).
[in] | mat | The matrix to multiply this vector by. |
|
virtual |
Scales a this vector by the provided number.
[in] | s | The scaling factor. |
|
virtual |
Returns the sum of this vector and the provided one.
[in] | vec | The other argument of the sum. |
|
virtual |
Adds the provided vector to this one.
[in] | vec | The vector to add. |
|
virtual |
Returns a copy of this vector multiplied by -1.
|
virtual |
Returns the result of subtracting the provided vector from this one.
[in] | vec | The matrix to subtract. |
|
virtual |
Subtracts the provided vector from this one.
[in] | vec | The vector to subtract. |
|
virtual |
Scales a copy of this vector by the inverse of the provided number and returns it.
[in] | s | The inverse scaling factor. |
|
virtual |
Scales a this matrix by the inverse of the provided number.
[in] | s | The inverse scaling factor. |
|
virtual |
Copies elements of the provided vector into this one.
[in] | vec | The vector to copy. |
|
virtual |
Comparing operator. Checks if all elements of the provided vector are the same as this.
[in] | vec | The vector to compare this with. |
true
if all entries are equal, false
otherwise.
|
virtual |
Returns a reference to the element of the vector with the provided index. If the index is incorrect the closest correct one is used is returned. Version for constant instances.
[in] | ind | Index of the element to return. |
|
virtual |
Returns a reference to the element of the vector with the provided index. If the index is incorrect the closest correct one is used is returned.
[in] | ind | Index of the element to return. |
|
virtual |
Returns the outer product of this vector and the provided one.
[in] | vec | The vector to multiply this by. |
|
virtual |
Set the vector data to the values in the provided array. First 3 positions from the given pointer are read.
[in] | data | The array with values to set. |
|
protected |
The vector data.
fpType& algebra3d::Vector3< fpType >::x |
Reference to the first element of data.
fpType& algebra3d::Vector3< fpType >::y |
Reference to the second element of data.
fpType& algebra3d::Vector3< fpType >::z |
Reference to the third element of data.