#include <CVector3d.h>
Public Member Functions | |
cVector3d () | |
cVector3d (const char *a_initstr) | |
Constructor by passing a string to initialize vector. | |
cVector3d (const string &a_initstr) | |
Constructor by passing a string to initialize vector. | |
cVector3d (const double a_x, const double a_y, const double a_z) | |
Constructor by passing a doubles to initialize vector. | |
cVector3d (const cVector3d &a_source) | |
Constructor by passing a vector to initialize vector. | |
cVector3d (const double *a_in) | |
Constructor by passing an array of doubles to initialize vector. | |
cVector3d (const float *a_in) | |
Constructor by passing an array of floats to initialize vector. | |
double & | operator[] (unsigned int index) |
operator [] | |
double | operator[] (unsigned int index) const |
operator [] | |
void | zero () |
double | get (const unsigned int &a_component) const |
void | operator/= (const double &a_val) |
void | operator*= (const double &a_val) |
void | operator+= (const cVector3d &a_input) |
void | operator-= (const cVector3d &a_input) |
void | set (const double &a_x, const double &a_y, const double &a_z) |
bool | set (const char *a_initStr) |
bool | set (const string &a_initStr) |
void | copyto (cVector3d &a_destination) const |
void | copyfrom (const cVector3d &a_source) |
void | add (const cVector3d &a_vector) |
void | add (const double &a_x, const double &a_y, const double &a_z) |
void | addr (const cVector3d &a_vector, cVector3d &a_result) const |
void | addr (const double &a_x, const double &a_y, const double &a_z, cVector3d &a_result) const |
void | sub (const cVector3d &a_vector) |
void | sub (const double &a_x, const double &a_y, const double &a_z) |
void | subr (const cVector3d &a_vector, cVector3d &a_result) const |
void | subr (const double &a_x, const double &a_y, const double &a_z, cVector3d &a_result) const |
void | mul (const double &a_scalar) |
void | mulr (const double &a_scalar, cVector3d &a_result) const |
void | div (const double &a_scalar) |
void | divr (const double &a_scalar, cVector3d &a_result) const |
void | negate () |
void | negater (cVector3d &a_result) const |
void | cross (const cVector3d &a_vector) |
cVector3d | crossAndReturn (const cVector3d &a_vector) const |
void | crossr (const cVector3d &a_vector, cVector3d &a_result) const |
double | dot (const cVector3d &a_vector) const |
void | elementMul (const cVector3d &a_vector) |
void | elementMulr (const cVector3d &a_vector, cVector3d &a_result) const |
double | length () const |
double | lengthsq (void) const |
void | normalize () |
void | normalizer (cVector3d &a_result) const |
double | distance (const cVector3d &a_vector) const |
double | distancesq (const cVector3d &a_vector) const |
bool | equals (const cVector3d &a_vector, const double epsilon=0.0) const |
void | str (string &a_string, const unsigned int a_precision=2) const |
string | str (const unsigned int a_precision=2) const |
void | print (const unsigned int a_precision=2) const |
void | decompose (const cVector3d &a_input, cVector3d &a_parallel, cVector3d &a_perpendicular) |
void | slerp (double a_level, cVector3d const &a_vector1, cVector3d a_vector2) |
Public Attributes | |
double | x |
Component X of vector. | |
double | y |
Component Y of vector. | |
double | z |
Component Z of vector. |
cVector3d::cVector3d | ( | ) | [inline] |
void cVector3d::add | ( | const double & | a_x, | |
const double & | a_y, | |||
const double & | a_z | |||
) | [inline] |
Addition between current vector and external vector passed as parameter.
Result is stored in current vector.
a_x | X component. | |
a_y | Y component. | |
a_z | Z component. |
void cVector3d::add | ( | const cVector3d & | a_vector | ) | [inline] |
Addition between current vector and external vector passed as parameter.
Result is stored in current vector.
a_vector | This vector is added to the current one. |
void cVector3d::addr | ( | const double & | a_x, | |
const double & | a_y, | |||
const double & | a_z, | |||
cVector3d & | a_result | |||
) | const [inline] |
Addition between current vector and vector passed by parameter.
Result is stored in result vector.
a_x | X component. | |
a_y | Y component. | |
a_z | Z component. | |
a_result | Vector where result is stored. |
Addition between current vector and external vector passed as parameter.
Result is stored in external result vector.
a_vector | Vector which is added to current one. | |
a_result | Vector where result is stored. |
void cVector3d::copyfrom | ( | const cVector3d & | a_source | ) | [inline] |
Copy external vector as parameter to current vector.
a_source | Source vector. |
void cVector3d::copyto | ( | cVector3d & | a_destination | ) | const [inline] |
Copy current vector to external vector as parameter.
a_destination | Destination vector. |
void cVector3d::cross | ( | const cVector3d & | a_vector | ) | [inline] |
Compute the cross product between current vector and an external vector.
Result is stored in current vector.
a_vector | Vector with which cross product is computed with. |
Compute the cross product between current vector and an external vector passed as parameter.
Result is returned. Performance-wise, cross() and crossr() are usually preferred, since this version creates a new stack variable.
a_vector | Vector with which cross product is computed. |
Compute the cross product between current vector and an external vector passed as parameter.
Result is stored in a_result vector.
a_vector | Vector with which cross product is computed. | |
a_result | Vector where result is stored. |
void cVector3d::decompose | ( | const cVector3d & | a_input, | |
cVector3d & | a_parallel, | |||
cVector3d & | a_perpendicular | |||
) | [inline] |
Decompose me into components parallel and perpendicular to the input vector.
a_input | Reference vector. | |
a_parallel | Parallel component | |
a_perpendicular | Perpendicular component |
double cVector3d::distance | ( | const cVector3d & | a_vector | ) | const [inline] |
Compute the distance between current point and an external point passed as parameter.
a_vector | Point to which the distance is measured |
double cVector3d::distancesq | ( | const cVector3d & | a_vector | ) | const [inline] |
Compute the square distance between the current point and an external point.
a_vector | Point to which squared distance is measured |
void cVector3d::div | ( | const double & | a_scalar | ) | [inline] |
Divide current vector by a scalar. No check for divide-by-zero is performed.
Result is stored in current vector.
a_scalar | Scalar value. |
void cVector3d::divr | ( | const double & | a_scalar, | |
cVector3d & | a_result | |||
) | const [inline] |
Divide current vector by a scalar.
Result is stored in result vector.
a_scalar | Scalar value. | |
a_result | Result vector. |
double cVector3d::dot | ( | const cVector3d & | a_vector | ) | const [inline] |
Compute the dot product between current vector and an external vector passed as parameter.
a_vector | Vector with which dot product is computed. |
void cVector3d::elementMul | ( | const cVector3d & | a_vector | ) | [inline] |
Compute the element-by-element product between current vector and an external vector and store in the current vector.
a_vector | Vector with which product is computed. |
Compute the element-by-element product between current vector and an external vector and store in the supplied output vector.
a_vector | Vector with which product is computed. | |
a_result | Resulting vector. |
bool cVector3d::equals | ( | const cVector3d & | a_vector, | |
const double | epsilon = 0.0 | |||
) | const [inline] |
Test whether the current vector and an external vector are equal.
a_vector | Vector with which equality is checked. | |
epsilon | Two vectors will be considered equal if each component is within epsilon units. Defaults to zero. |
double cVector3d::get | ( | const unsigned int & | a_component | ) | const [inline] |
Return the i th component of the vector. component = 0 return x, component = 1 returns y, component = 2 returns z.
a_component | component number |
double cVector3d::length | ( | ) | const [inline] |
Compute the length of current vector.
double cVector3d::lengthsq | ( | void | ) | const [inline] |
Compute the square length of current vector.
void cVector3d::mul | ( | const double & | a_scalar | ) | [inline] |
Multiply current vector by a scalar.
Result is stored in current vector.
a_scalar | Scalar value. |
void cVector3d::mulr | ( | const double & | a_scalar, | |
cVector3d & | a_result | |||
) | const [inline] |
Multiply current vector by a scalar.
Result is stored in result vector.
a_scalar | Scalar value. | |
a_result | Result vector. |
void cVector3d::negate | ( | ) | [inline] |
Negate current vector.
Result is stored in current vector.
void cVector3d::negater | ( | cVector3d & | a_result | ) | const [inline] |
Negate current vector.
Result is stored in result vector.
a_result | Result vector. |
void cVector3d::normalize | ( | ) | [inline] |
Normalize current vector to become a vector of length one.
Warning:
Vector should not be equal to (0,0,0) or a division by zero error will occur.
Result is stored in current vector.
void cVector3d::normalizer | ( | cVector3d & | a_result | ) | const [inline] |
Normalize current vector to become a vector of length one.
WARNING: Vector should not be equal to (0,0,0) or a division by zero error will occur.
Result is stored in result vector.
a_result | Vector where result is stored. |
void cVector3d::operator*= | ( | const double & | a_val | ) | [inline] |
An overloaded *= operator for vector/scalar multiplication
void cVector3d::operator+= | ( | const cVector3d & | a_input | ) | [inline] |
An overloaded += operator for vector/vector addition
void cVector3d::operator-= | ( | const cVector3d & | a_input | ) | [inline] |
An overloaded -= operator for vector/vector subtraction
void cVector3d::operator/= | ( | const double & | a_val | ) | [inline] |
An overloaded /= operator for vector/scalar division
double& cVector3d::operator[] | ( | unsigned int | index | ) | [inline] |
operator []
Cast to a double*
This replaces the previous [] operators (without breaking existing code).
void cVector3d::print | ( | const unsigned int | a_precision = 2 |
) | const [inline] |
Print the current vector using the CHAI_DEBUG_PRINT macro.
a_precision | Number of digits. |
bool cVector3d::set | ( | const string & | a_initStr | ) | [inline] |
Initialize a vector from a string of the form (x,y,z) (the same form produced by str() )
a_initStr | The string to convert |
bool cVector3d::set | ( | const char * | a_initStr | ) | [inline] |
Initialize a vector from a string of the form (x,y,z), the same form produced by str(). Will actually accept any of the following forms:
(4.3,23,54)
4.3 54 2.1
4.5,7.8,9.1
...i.e., it expects three numbers, optionally preceded by '(' and whitespace, and separated by commas or whitespace.
a_initStr | The string to convert |
void cVector3d::set | ( | const double & | a_x, | |
const double & | a_y, | |||
const double & | a_z | |||
) | [inline] |
Initialize 3 dimensional vector with parameters x, y, and z.
a_x | X component. | |
a_y | Y component. | |
a_z | Z component. |
Spherically linearly interpolate between two vectors and store in this vector. Vectors should have the same length
a_level | Fraction of distance to a_vector2 (0 is fully at a_vector1, 1.0 is fully at a_vector2) | |
a_vector1 | First vector to interpolate from | |
a_vector2 | Second vector to interpolate from |
string cVector3d::str | ( | const unsigned int | a_precision = 2 |
) | const [inline] |
Convert current vector into a string, which is returned on the stack.
a_precision | Number of digits. |
void cVector3d::str | ( | string & | a_string, | |
const unsigned int | a_precision = 2 | |||
) | const [inline] |
Convert current vector into a string.
a_string | String where conversion is stored | |
a_precision | Number of digits. |
void cVector3d::sub | ( | const double & | a_x, | |
const double & | a_y, | |||
const double & | a_z | |||
) | [inline] |
Subtract an external vector passed as parameter from current vector.
Result is stored in current vector.
a_x | X component. | |
a_y | Y component. | |
a_z | Z component. |
void cVector3d::sub | ( | const cVector3d & | a_vector | ) | [inline] |
Subtraction between current vector and an external vector passed as parameter.
Result is stored in current vector.
a_vector | Vector which is subtracted from current one. |
void cVector3d::subr | ( | const double & | a_x, | |
const double & | a_y, | |||
const double & | a_z, | |||
cVector3d & | a_result | |||
) | const [inline] |
Subtract current vector from vector passed by parameter.
Result is stored in result vector.
a_x | X component. | |
a_y | Y component. | |
a_z | Z component. | |
a_result | Vector where result is stored. |
Subtraction between current vector and external vector passed as parameter.
Result is stored in external a_result vector.
a_vector | Vector which is subtracted from current one. | |
a_result | Vector where result is stored. |
void cVector3d::zero | ( | ) | [inline] |
Clear vector with zeros.