![]() |
RobWorkProject
23.9.11-
|
A 3D vector \( \mathbf{v}\in \mathbb{R}^3 \). More...
#include <Vector3D.hpp>
Public Types | |
| typedef Eigen::Matrix< T, 3, 1 > | EigenVector3D |
| Eigen type equivalent to Vector3D. | |
| typedef T | value_type |
| Value type. | |
Public Member Functions | |
| Vector3D () | |
| Creates a 3D vector initialized with 0's. | |
| Vector3D (T x, T y, T z) | |
| Creates a 3D vector. More... | |
| Vector3D (const Vector3D< T > ©_vec) | |
| Copy constructor. More... | |
| template<class R > | |
| Vector3D (const Eigen::MatrixBase< R > &r) | |
| Creates a 3D vector from vector_expression. More... | |
| Vector3D (const std::vector< T > &vec) | |
| construct vector from std::vector More... | |
| size_t | size () const |
| The dimension of the vector (i.e. 3). This method is provided to help support generic algorithms using size() and operator[]. More... | |
| template<class R > | |
| Vector3D< T > | elemDivide (const Eigen::MatrixBase< R > &rhs) const |
| element wise division. More... | |
| template<class R > | |
| Vector3D< T > | elemMultiply (const Eigen::MatrixBase< R > &rhs) const |
| Elementweise multiplication. More... | |
| template<class R > | |
| Vector3D< T > | operator- (const Eigen::MatrixBase< R > &rhs) const |
| Vector subtraction. | |
| template<class R > | |
| Vector3D< T > | operator+ (const Eigen::MatrixBase< R > &rhs) const |
| Vector addition. | |
| Vector3D< T > | elemDivide (const Vector3D< T > &rhs) const |
| element wise division. More... | |
| Vector3D< T > | elemMultiply (const Vector3D< T > &rhs) const |
| Elementweise multiplication. More... | |
| Vector3D< T > | operator- (const Vector3D< T > &b) const |
| Vector subtraction. | |
| Vector3D< T > | operator+ (const Vector3D< T > &b) const |
| Vector addition. | |
| Vector3D< T > | operator- () const |
| Unary minus. More... | |
| Vector3D< T > | operator/ (T s) const |
| Scalar division. More... | |
| Vector3D< T > | operator* (T rhs) const |
| Scalar multiplication. More... | |
| template<class R > | |
| Vector3D< T > | operator* (const Eigen::MatrixBase< R > &rhs) const |
| Scalar multiplication. More... | |
| Vector3D< T > | elemSubtract (const T rhs) const |
| Scalar subtraction. | |
| Vector3D< T > | elemAdd (const T rhs) const |
| Scalar addition. | |
| T | norm2 () const |
| Returns the Euclidean norm (2-norm) of the vector. More... | |
| T | norm1 () const |
| Returns the Manhatten norm (1-norm) of the vector. More... | |
| T | normInf () const |
| Returns the infinte norm ( \(\inf\)-norm) of the vector. More... | |
| Vector3D< T > | cross (const Vector3D &vec) const |
| Calculate cross product. More... | |
| T | dot (const Vector3D &vec) const |
| calculate the dot product More... | |
| Vector3D< T > | normalize () |
| normalize vector to get length 1 More... | |
| EigenVector3D & | e () |
| Returns Reference to Eigen Vector. More... | |
| const EigenVector3D | e () const |
| Returns Reference to Eigen Vector. More... | |
| const T & | operator() (size_t i) const |
| Returns reference to vector element. More... | |
| T & | operator() (size_t i) |
| Returns reference to vector element. More... | |
| const T & | operator[] (size_t i) const |
| Returns reference to vector element. More... | |
| T & | operator[] (size_t i) |
| Returns reference to vector element. More... | |
| Vector3D< T > & | operator*= (T s) |
| Scalar multiplication. | |
| Vector3D< T > & | operator/= (T s) |
| Scalar division. | |
| Vector3D< T > & | operator+= (const Vector3D< T > &v) |
| Vector addition. | |
| Vector3D< T > & | operator-= (const Vector3D< T > &v) |
| Vector subtraction. | |
| template<class R > | |
| Vector3D< T > & | operator= (const Eigen::MatrixBase< R > &r) |
| copy a vector from eigen type More... | |
| template<class R > | |
| Vector3D< T > & | operator+= (const Eigen::MatrixBase< R > &r) |
| Vector addition. | |
| template<class R > | |
| Vector3D< T > & | operator-= (const Eigen::MatrixBase< R > &r) |
| Vector subtraction. | |
| bool | operator== (const Vector3D< T > &b) const |
| Compare with b for equality. More... | |
| bool | operator!= (const Vector3D< T > &b) const |
| Compare with b for inequality. More... | |
| template<class R > | |
| bool | operator== (const Eigen::MatrixBase< R > &rhs) const |
| Compare with rhs for equality. More... | |
| template<class R > | |
| bool | operator!= (const Eigen::MatrixBase< R > &rhs) const |
| Compare with rhs for inequality. More... | |
| operator EigenVector3D () const | |
| implicit conversion to EigenVector | |
| operator EigenVector3D & () | |
| implicit conversion to EigenVector | |
Static Public Member Functions | |
| static Vector3D< T > | zero () |
| Get zero vector. More... | |
| static Vector3D< T > | x () |
| Get x vector (1,0,0) More... | |
| static Vector3D< T > | y () |
| Get y vector (0,1,0) More... | |
| static Vector3D< T > | z () |
| Get z vector (0,0,1) More... | |
Friends | |
| template<class R > | |
| Vector3D< T > | operator- (const Eigen::MatrixBase< R > &lhs, const Vector3D< T > &rhs) |
| Vector subtraction. | |
| template<class R > | |
| Vector3D< T > | operator+ (const Eigen::MatrixBase< R > &lhs, const Vector3D< T > &rhs) |
| Vector subtraction. | |
| Vector3D< T > | operator/ (T lhs, const Vector3D< T > &rhs) |
| Scalar division. More... | |
| Vector3D< T > | operator* (T lhs, const Vector3D< T > &rhs) |
| Scalar multiplication. More... | |
| template<class R > | |
| Vector3D< T > | operator* (const Eigen::MatrixBase< R > &lhs, const Vector3D< T > &rhs) |
| Scalar multiplication. More... | |
| std::ostream & | operator<< (std::ostream &out, const Vector3D< T > &v) |
| Streaming operator. More... | |
| template<class R > | |
| bool | operator== (const Eigen::MatrixBase< R > &lhs, const Vector3D< T > &rhs) |
| Compare with rhs for equality. More... | |
| template<class R > | |
| bool | operator!= (const Eigen::MatrixBase< R > &lhs, const Vector3D< T > &rhs) |
| Compare with rhs for inequality. More... | |
Related Functions | |
(Note that these are not member functions.) | |
| template<class T > | |
| const Vector3D< T > | cross (const Vector3D< T > &v1, const Vector3D< T > &v2) |
| Calculates the 3D vector cross product \( \mathbf{v1} \times \mathbf{v2} \). More... | |
| template<class T > | |
| void | cross (const Vector3D< T > &v1, const Vector3D< T > &v2, Vector3D< T > &dst) |
| Calculates the 3D vector cross product \( \mathbf{v1} \times \mathbf{v2} \). More... | |
| template<class T > | |
| T | dot (const Vector3D< T > &v1, const Vector3D< T > &v2) |
| Calculates the dot product \( \mathbf{v1} . \mathbf{v2} \). More... | |
| template<class T > | |
| const Vector3D< T > | normalize (const Vector3D< T > &v) |
| Returns the normalized vector \(\mathbf{n}=\frac{\mathbf{v}}{\|\mathbf{v}\|} \). In case \( \|mathbf{v}\| = 0\) the zero vector is returned. More... | |
| template<class T > | |
| double | angle (const Vector3D< T > &v1, const Vector3D< T > &v2, const Vector3D< T > &n) |
| Calculates the angle from \( \mathbf{v1}\) to \( \mathbf{v2} \) around the axis defined by \( \mathbf{v1} \times \mathbf{v2} \) with n determining the sign. More... | |
| template<class T > | |
| double | angle (const Vector3D< T > &v1, const Vector3D< T > &v2) |
| Calculates the angle from \( \mathbf{v1}\) to \( \mathbf{v2} \) around the axis defined by \( \mathbf{v1} \times \mathbf{v2} \). More... | |
| template<class Q , class T > | |
| const Vector3D< Q > | cast (const Vector3D< T > &v) |
| Casts Vector3D<T> to Vector3D<Q> More... | |
| template<> | |
| void | write (const rw::math::Vector3D< double > &sobject, rw::common::OutputArchive &oarchive, const std::string &id) |
| template<> | |
| void | write (const rw::math::Vector3D< float > &sobject, rw::common::OutputArchive &oarchive, const std::string &id) |
| template<> | |
| void | read (rw::math::Vector3D< double > &sobject, rw::common::InputArchive &iarchive, const std::string &id) |
| template<> | |
| void | read (rw::math::Vector3D< float > &sobject, rw::common::InputArchive &iarchive, const std::string &id) |
| template<class Archive , class T > | |
| void | serialize (Archive &archive, rw::math::Vector3D< T > &vector, const unsigned int version) |
| Boost serialization. More... | |
A 3D vector \( \mathbf{v}\in \mathbb{R}^3 \).
\( \robabx{i}{j}{\mathbf{v}} = \left[ \begin{array}{c} v_x \\ v_y \\ v_z \end{array} \right] \)
Usage example:
|
inline |
Creates a 3D vector.
| x | [in] \( x \) |
| y | [in] \( y \) |
| z | [in] \( z \) |
Copy constructor.
| copy_vec | [in] vector to copy |
|
inlineexplicit |
Creates a 3D vector from vector_expression.
| r | [in] an Eigen Vector |
|
inline |
construct vector from std::vector
| vec | [in] the vector to construct from |
Calculate cross product.
| vec | [in] the vector to cross with |
|
inline |
calculate the dot product
| vec | [in] the vecor to be dotted |
|
inline |
Returns Reference to Eigen Vector.
|
inline |
Returns Reference to Eigen Vector.
|
inline |
element wise division.
| rhs | [in] the vector being devided with |
element wise division.
| rhs | [in] the vector being devided with |
|
inline |
Elementweise multiplication.
| rhs | [in] vector |
Elementweise multiplication.
| rhs | [in] vector |
|
inline |
Returns the Manhatten norm (1-norm) of the vector.
|
inline |
Returns the Euclidean norm (2-norm) of the vector.
|
inline |
Returns the infinte norm ( \(\inf\)-norm) of the vector.
|
inline |
Compare with rhs for inequality.
| rhs | [in] other vector. |
|
inline |
Compare with b for inequality.
| b | [in] other vector. |
|
inline |
Returns reference to vector element.
| i | [in] index in the vector \(i\in \{0,1,2\} \) |
|
inline |
Returns reference to vector element.
| i | [in] index in the vector \(i\in \{0,1,2\} \) |
|
inline |
Scalar multiplication.
| rhs | [in] the Eigen vector^T or matrix to multiply with |
|
inline |
Scalar multiplication.
| rhs | [in] the scalar to multiply with |
|
inline |
Unary minus.
negative version
|
inline |
Scalar division.
| s | [in] the scalar to devide with |
|
inline |
copy a vector from eigen type
| r | [in] an Eigen Vector |
|
inline |
Compare with rhs for equality.
| rhs | [in] other vector. |
|
inline |
Compare with b for equality.
| b | [in] other vector. |
|
inline |
Returns reference to vector element.
| i | [in] index in the vector \(i\in \{0,1,2\} \) |
|
inline |
Returns reference to vector element.
| i | [in] index in the vector \(i\in \{0,1,2\} \) |
|
inline |
The dimension of the vector (i.e. 3). This method is provided to help support generic algorithms using size() and operator[].
|
inlinestatic |
Get x vector (1,0,0)
|
inlinestatic |
Get y vector (0,1,0)
|
inlinestatic |
Get z vector (0,0,1)
|
inlinestatic |
Get zero vector.
Calculates the angle from \( \mathbf{v1}\) to \( \mathbf{v2} \) around the axis defined by \( \mathbf{v1} \times \mathbf{v2} \).
| v1 | [in] \( \mathbf{v1} \) |
| v2 | [in] \( \mathbf{v2} \) |
|
related |
Calculates the angle from \( \mathbf{v1}\) to \( \mathbf{v2} \) around the axis defined by \( \mathbf{v1} \times \mathbf{v2} \) with n determining the sign.
| v1 | [in] \( \mathbf{v1} \) |
| v2 | [in] \( \mathbf{v2} \) |
| n | [in] \( \mathbf{n} \) |
Calculates the 3D vector cross product \( \mathbf{v1} \times \mathbf{v2} \).
| v1 | [in] \( \mathbf{v1} \) |
| v2 | [in] \( \mathbf{v2} \) |
The 3D vector cross product is defined as: \( \mathbf{v1} \times \mathbf{v2} = \left[\begin{array}{c} v1_y * v2_z - v1_z * v2_y \\ v1_z * v2_x - v1_x * v2_z \\ v1_x * v2_y - v1_y * v2_x \end{array}\right] \)
Calculates the 3D vector cross product \( \mathbf{v1} \times \mathbf{v2} \).
| v1 | [in] \( \mathbf{v1} \) |
| v2 | [in] \( \mathbf{v2} \) |
| dst | [out] the 3D vector cross product \( \mathbf{v1} \times \mathbf{v2} \) |
The 3D vector cross product is defined as: \( \mathbf{v1} \times \mathbf{v2} = \left[\begin{array}{c} v1_y * v2_z - v1_z * v2_y \\ v1_z * v2_x - v1_x * v2_z \\ v1_x * v2_y - v1_y * v2_x \end{array}\right] \)
Calculates the dot product \( \mathbf{v1} . \mathbf{v2} \).
| v1 | [in] \( \mathbf{v1} \) |
| v2 | [in] \( \mathbf{v2} \) |
Returns the normalized vector \(\mathbf{n}=\frac{\mathbf{v}}{\|\mathbf{v}\|} \). In case \( \|mathbf{v}\| = 0\) the zero vector is returned.
| v | [in] \( \mathbf{v} \) which should be normalized |
|
friend |
Compare with rhs for inequality.
| lhs | [in] first vector. |
| rhs | [in] other vector. |
Scalar multiplication.
| lhs | [in] the Eigen vector^T or matrix to multiply with |
| rhs | [in] the Vector to be multiplied |
Scalar multiplication.
| lhs | [in] the scalar to multiply with |
| rhs | [in] the Vector to be multiplied |
Scalar division.
| lhs | [in] the scalar to devide with |
| rhs | [out] the vector beind devided |
|
friend |
Streaming operator.
| out | [in/out] the stream to continue |
| v | [in] the vector to stream |
|
friend |
Compare with rhs for equality.
| lhs | [in] first vector. |
| rhs | [in] other vector. |
|
related |
Enable read-serialization of class T by overloading this method. Data is read from iarchive and filled into sobject.
| sobject | [out] the object in which the data should be streamed into |
| iarchive | [in] the InputArchive from which to read data. |
| id | [in] The id of the serialized sobject. |
|
related |
Enable read-serialization of class T by overloading this method. Data is read from iarchive and filled into sobject.
| sobject | [out] the object in which the data should be streamed into |
| iarchive | [in] the InputArchive from which to read data. |
| id | [in] The id of the serialized sobject. |
|
related |
Boost serialization.
| archive | [in] the boost archive to read from or write to. |
| vector | [in/out] the vector to read/write. |
| version | [in] class version (currently version 0). |
|
related |
Enable write-serialization of class T by overloading this method. Data is written to oarchive from the sobject.
| sobject | [in] the object from which the data should be streamed. |
| oarchive | [out] the OutputArchive in which data should be written. |
| id | [in] The id of the serialized sobject. |
|
related |
Enable write-serialization of class T by overloading this method. Data is written to oarchive from the sobject.
| sobject | [in] the object from which the data should be streamed. |
| oarchive | [out] the OutputArchive in which data should be written. |
| id | [in] The id of the serialized sobject. |