This class implements a 3D vector. More...
#include <CVector3d.h>
Public Member Functions | |
cVector3d () | |
cVector3d (const double a_x, const double a_y, const double a_z) | |
Constructor of cVector3d. More... | |
cVector3d (const cVector3d &a_vector) | |
Constructor of cVector3d. More... | |
cVector3d (const char *a_string) | |
Constructor of cVector3d. More... | |
cVector3d (const std::string &a_string) | |
Constructor of cVector3d. More... | |
double | x () const |
This method returns vector component x. More... | |
double | y () const |
This method returns vector component y. More... | |
double | z () const |
This method returns vector component z. More... | |
void | x (const double a_value) |
This method sets vector component x. More... | |
void | y (const double a_value) |
This method sets vector component y. More... | |
void | z (const double a_value) |
This method sets vector component z. More... | |
void | zero () |
This method clears all vector components with zeros. More... | |
double | get (const unsigned int &a_component) const |
This method returns the i th component of the vector. More... | |
void | set (const double &a_x, const double &a_y, const double &a_z) |
This method initializes this vector with components x, y, and z passed as arguments. More... | |
bool | set (const char *a_initStr) |
This method initializes this vector from an input ANSI spring. More... | |
bool | set (const std::string &a_initStr) |
This method initializes this vector from and input string. More... | |
void | copyto (cVector3d &a_destination) const |
This method copies the content of this vector to another. More... | |
void | copyfrom (const cVector3d &a_source) |
This method copies the content of a vector to this one. More... | |
void | add (const cVector3d &a_vector) |
This method computes the addition of this vector with another. More... | |
void | add (const double &a_x, const double &a_y, const double &a_z) |
This method computes the addition of this vector with another. More... | |
void | addr (const cVector3d &a_vector, cVector3d &a_result) const |
This method computes the addition of this vector with another. More... | |
void | addr (const double &a_x, const double &a_y, const double &a_z, cVector3d &a_result) const |
This method computes the addition of this vector with another. More... | |
void | sub (const cVector3d &a_vector) |
This method computes the subtraction of this vector with another. More... | |
void | sub (const double &a_x, const double &a_y, const double &a_z) |
This method computes the subtraction of this vector with another. More... | |
void | subr (const cVector3d &a_vector, cVector3d &a_result) const |
This method computes the subtraction of this vector with another. More... | |
void | subr (const double &a_x, const double &a_y, const double &a_z, cVector3d &a_result) const |
This method computes the subtraction of this vector with another. More... | |
void | mul (const double &a_scalar) |
This method computes the multiplication of this vector with a scalar. More... | |
void | mul (const double &a_scalar0, const double &a_scalar1, const double &a_scalar2) |
This method computes the multiplication of each component of this vector by a set of scalars. More... | |
void | mulr (const double &a_scalar, cVector3d &a_result) const |
This method computes the multiplication of this vector with a scalar. More... | |
void | mulr (const double &a_scalar0, const double &a_scalar1, const double &a_scalar2, cVector3d &a_result) const |
This method computes the multiplication of each component of this vector by a set of scalars. More... | |
void | mulElement (const cVector3d &a_vector) |
This method computes the element-by-element product between this vector and another. More... | |
void | mulElementr (const cVector3d &a_vector, cVector3d &a_result) const |
This method computes the element-by-element product between this vector and another. More... | |
void | div (const double &a_scalar) |
This method computes the division of this vector with a scalar. More... | |
void | divr (const double &a_scalar, cVector3d &a_result) const |
This method computes the division of this vector with a scalar. More... | |
void | negate () |
This method computes the negated vector. More... | |
void | negater (cVector3d &a_result) const |
This method computes the negated vector. More... | |
void | cross (const cVector3d &a_vector) |
This method computes the cross product. More... | |
void | crossr (const cVector3d &a_vector, cVector3d &a_result) const |
This method computes the cross product. More... | |
double | dot (const cVector3d &a_vector) const |
This method computes the dot product between this vector and another. More... | |
double | length () const |
This method computes the Euclidean norm of this vector. More... | |
double | lengthsq () const |
This method computes the squared value of the Euclidean norm of this vector. More... | |
void | normalize () |
This method normalizes this vector to length 1. More... | |
void | normalizer (cVector3d &a_result) const |
This method normalizes this vector to length 1. More... | |
void | clamp (const double &a_maxLength) |
This method clamps this vector to a maximum desired length. More... | |
double | distance (const cVector3d &a_vector) const |
This method computes the distance between two points. More... | |
double | distancesq (const cVector3d &a_vector) const |
This method computes the squared value distance between two points. More... | |
bool | equals (const cVector3d &a_vector, const double a_epsilon=0.0) const |
This method performs an equality test between two vectors. More... | |
std::string | str (const unsigned int a_precision=2) const |
This method convert this vector into a string. More... | |
void | operator/= (const double &a_val) |
An overloaded /= operator for vector/scalar division. More... | |
void | operator*= (const double &a_val) |
An overloaded *= operator for vector/scalar multiplication. More... | |
void | operator+= (const cVector3d &a_input) |
An overloaded += operator for vector/vector addition. More... | |
void | operator-= (const cVector3d &a_input) |
An overloaded -= operator for vector/vector subtraction. More... | |
double & | operator() (const int a_index) |
An overloaded () operator. More... | |
const double & | operator() (const int a_index) const |
An overloaded () operator. More... | |
This class implement a 3D vector that provides storage for a 3 dimensional double precision floating point vector as well as basic floating point arithmetic operations.
|
inline |
Constructor of cVector3d.
|
inline |
This constructor initializes a vector by passing three doubles by argument.
a_x | X value. |
a_y | Y value. |
a_z | Z value. |
|
inline |
This constructor initializes a vector by passing a vector by argument.
a_vector | Vector. |
|
inline |
This constructor initializes a vector by passing an ANSI string by argument.
a_string | Vector in string format. |
|
inline |
This constructor initializes a vector by passing a string by argument.
a_string | Vector in string format. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
This method returns the i th component of the vector.
a_component | Component index number (0,1, or 2). |
|
inline |
This method initializes this vector with arguments a_x
, a_y
, and a_z
.
a_x | Component x of vector. |
a_y | Component y of vector. |
a_z | Component z of vector. |
|
inline |
This method initializes this vector from an input string of the form (x,y,z) . The following string formats are accepted:
a_initStr | Vector in string format. |
|
inline |
This method initializes this vector from an input string of the form (x,y,z) . The following string formats are accepted:
a_initStr | Vector in string format. |
|
inline |
This method copies components (x, y, z), of this vector to a vector passed as argument.
a_destination | Destination vector where data is copied. |
|
inline |
This method copies components (x, y, z) of a vector passed by argument to this one.
a_source | Source vector from where data is copied. |
|
inline |
This method computes the addition of this vector with a vector passed by argument.
The result is stored in this vector.
a_vector | Vector to be added to current one. |
|
inline |
This method computes the addition of this vector with a vector passed by argument.
The result is stored in this vector.
a_x | Component x of vector. |
a_y | Component y of vector. |
a_z | Component z of vector. |
This method computes the addition of this vector with a vector passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_vector | Vector to be added to current one. |
a_result | Result of operation. |
|
inline |
This method computes the addition of this vector with a vector passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_x | Component x of vector. |
a_y | Component y of vector. |
a_z | Component z of vector. |
a_result | Result of operation. |
|
inline |
This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in this vector.
a_vector | Vector to be subtracted from current one. |
|
inline |
This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in this vector.
a_x | x component. |
a_y | y component. |
a_z | z component. |
This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_vector | Vector to be subtracted from current one. |
a_result | Result of operation. |
|
inline |
This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_x | x component. |
a_y | y component. |
a_z | z component. |
a_result | Result of operation. |
|
inline |
This method computes the multiplication of this vector by a scalar a_scalar
passed by argument.
The result is stored in this vector.
a_scalar | Scalar value. |
|
inline |
This method computes the multiplication of each component of this vector by a set of scalars a_scalar0
, a_scalar1
, and a_scalar2
passed by argument.
The result is stored in this vector.
a_scalar0 | Scalar value for component 0. |
a_scalar1 | Scalar value for component 1. |
a_scalar2 | Scalar value for component 2. |
|
inline |
This method computes the multiplication of this vector by a scalar a_scalar
passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_scalar | Scalar value. |
a_result | Result of operation. |
|
inline |
This method computes the multiplication of each component of this vector by a set of scalars a_scalar0
, a_scalar1
, and a_scalar2
passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_scalar0 | Scalar value for component 0. |
a_scalar1 | Scalar value for component 1. |
a_scalar2 | Scalar value for component 2. |
a_result | Result of operation. |
|
inline |
This method computes the element-by-element product between this vector and a vector a_vector
passed by argument.
The result is stored in this vector.
a_vector | Input vector. |
|
inline |
This method computes the element-by-element product between this vector and a vector a_vector
passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_vector | Input vector. |
a_result | Result of operation. |
|
inline |
This method computes the division of this vector by a scalar a_scalar
passed by argument.
The result is stored in this vector.
a_scalar | Scalar value. |
|
inline |
This method computes the division of this vector by a scalar a_scalar
passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_scalar | Scalar value. |
a_result | Result of operation. |
|
inline |
This method computes the negated vector of this vector.
The result is stored in this vector.
|
inline |
This method computes the negated vector of this vector.
The result is stored in the result vector a_result
that is passed by argument.
a_result | Result of operation. |
|
inline |
This method computes the cross product between this vector and an vector a_vector
passed by argument.
The result is stored in the current vector.
a_vector | Input vector. |
This method computes the cross product between this vector and an vector a_vector
passed by argument.
The result is stored in the result vector a_result
that is passed by argument.
a_vector | Input vector. |
a_result | Resulting cross product. |
|
inline |
This method computes and returns the dot product between this vector and an vector a_vector
passed by argument.
a_vector | Input vector. |
|
inline |
This method computes and returns the Euclidean norm of this vector.
|
inline |
This method computes and returns the squared value of the Euclidean norm of this vector.
|
inline |
This method normalizes this vector to length 1.
WARNING:
The vector should not be equal to (0,0,0), otherwise a division by zero error will occur.
The result of this operation is stored in this vector.
|
inline |
This method normalizes this vector to length 1.
WARNING:
The vector should not be equal to (0,0,0), otherwise a division by zero error will occur.
The result is stored in the result vector a_result
that is passed by argument.
a_result | Normalized vector. |
|
inline |
This method clamps this vector to a maximum desired length. Vectors that are shorter argument than
a_maxLength are not affected.
The result of this operation is stored in this vector.
a_maxLength | Maximum length value. |
|
inline |
This method computes and returns the distance between this point and an point a_vector
passed by argument.
a_vector | Input point. |
|
inline |
This method computes and returns the squared value distance between this point and an point a_vector
passed by argument.
a_vector | Input point. |
|
inline |
This method tests whether the current vector and external vector a_vector
passed as argument are both equal. Two vectors are considered equal if each of their components are distant within an distance epsilon defined by the second argument a_epsilon
. By default, epsilon is set to zero.
a_vector | Input vector. |
a_epsilon | Tolerance error. |
|
inline |
This method convert this vector into a string. The number of digits after the decimal point are set by argument a_precision
.
a_precision | Number of digits. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |