chai3d::cVector3d Struct Reference

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...

## Detailed Description

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.

## Constructor & Destructor Documentation

 chai3d::cVector3d::cVector3d ( )
inline

Constructor of cVector3d.

 chai3d::cVector3d::cVector3d ( const double a_x, const double a_y, const double a_z )
inline

This constructor initializes a vector by passing three doubles by argument.

Parameters
 a_x X value. a_y Y value. a_z Z value.
 chai3d::cVector3d::cVector3d ( const cVector3d & a_vector )
inline

This constructor initializes a vector by passing a vector by argument.

Parameters
 a_vector Vector.
 chai3d::cVector3d::cVector3d ( const char * a_string )
inline

This constructor initializes a vector by passing an ANSI string by argument.

Parameters
 a_string Vector in string format.
 chai3d::cVector3d::cVector3d ( const std::string & a_string )
inline

This constructor initializes a vector by passing a string by argument.

Parameters
 a_string Vector in string format.

## Member Function Documentation

 double chai3d::cVector3d::x ( ) const
inline
 double chai3d::cVector3d::y ( ) const
inline
 double chai3d::cVector3d::z ( ) const
inline
 void chai3d::cVector3d::x ( const double a_value )
inline
 void chai3d::cVector3d::y ( const double a_value )
inline
 void chai3d::cVector3d::z ( const double a_value )
inline
 void chai3d::cVector3d::zero ( )
inline
 double chai3d::cVector3d::get ( const unsigned int & a_component ) const
inline

This method returns the i th component of the vector.

Parameters
 a_component Component index number (0,1, or 2).
Returns
Selected vector component.
 void chai3d::cVector3d::set ( const double & a_x, const double & a_y, const double & a_z )
inline

This method initializes this vector with arguments `a_x`, `a_y`, and `a_z`.

Parameters
 a_x Component x of vector. a_y Component y of vector. a_z Component z of vector.
 bool chai3d::cVector3d::set ( const char * a_initStr )
inline

This method initializes this vector from an input string of the form (x,y,z) . The following string formats are accepted:

• (4.3,23,54)
• 4.3 54 2.1
• 4.5,7.8,9.1
The methods expects three numbers, optionally preceded by '(' and whitespace, and separated by commas or whitespace.
Parameters
 a_initStr Vector in string format.
Returns
true if the conversion was successful, false otherwise.
 bool chai3d::cVector3d::set ( const std::string & a_initStr )
inline

This method initializes this vector from an input string of the form (x,y,z) . The following string formats are accepted:

• (4.3,23,54)
• 4.3 54 2.1
• 4.5,7.8,9.1
The methods expects three numbers, optionally preceded by '(' and whitespace, and separated by commas or whitespace.
Parameters
 a_initStr Vector in string format.
Returns
true if the conversion was successful, false otherwise.
 void chai3d::cVector3d::copyto ( cVector3d & a_destination ) const
inline

This method copies components (x, y, z), of this vector to a vector passed as argument.

a_destination = this
Parameters
 a_destination Destination vector where data is copied.
 void chai3d::cVector3d::copyfrom ( const cVector3d & a_source )
inline

This method copies components (x, y, z) of a vector passed by argument to this one.

this = a_source
Parameters
 a_source Source vector from where data is copied.
 void chai3d::cVector3d::add ( const cVector3d & a_vector )
inline

This method computes the addition of this vector with a vector passed by argument.
The result is stored in this vector.

this = this + a_vector
Parameters
 a_vector Vector to be added to current one.
 void chai3d::cVector3d::add ( const double & a_x, const double & a_y, const double & a_z )
inline

This method computes the addition of this vector with a vector passed by argument.
The result is stored in this vector.

this = this + cVector3d(a_x, a_y, a_z)
Parameters
 a_x Component x of vector. a_y Component y of vector. a_z Component z of vector.
 void chai3d::cVector3d::addr ( const cVector3d & a_vector, cVector3d & a_result ) const
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_result = this + a_vector
Parameters
 a_vector Vector to be added to current one. a_result Result of operation.
 void chai3d::cVector3d::addr ( const double & a_x, const double & a_y, const double & a_z, cVector3d & a_result ) const
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_result = this + cVector3d(a_x, a_y, a_z)
Parameters
 a_x Component x of vector. a_y Component y of vector. a_z Component z of vector. a_result Result of operation.
 void chai3d::cVector3d::sub ( const cVector3d & a_vector )
inline

This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in this vector.

this = this - a_vector
Parameters
 a_vector Vector to be subtracted from current one.
 void chai3d::cVector3d::sub ( const double & a_x, const double & a_y, const double & a_z )
inline

This method computes the subtraction of this vector with a vector passed by argument.
The result is stored in this vector.

this = this - cVector3d(a_x, a_y, a_z)
Parameters
 a_x x component. a_y y component. a_z z component.
 void chai3d::cVector3d::subr ( const cVector3d & a_vector, cVector3d & a_result ) const
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_result = this - a_vector
Parameters
 a_vector Vector to be subtracted from current one. a_result Result of operation.
 void chai3d::cVector3d::subr ( const double & a_x, const double & a_y, const double & a_z, cVector3d & a_result ) const
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_result = this - cVector3d(a_x, a_y, a_z)
Parameters
 a_x x component. a_y y component. a_z z component. a_result Result of operation.
 void chai3d::cVector3d::mul ( const double & a_scalar )
inline

This method computes the multiplication of this vector by a scalar `a_scalar` passed by argument.
The result is stored in this vector.

this = a_scalar * this
Parameters
 a_scalar Scalar value.
 void chai3d::cVector3d::mul ( const double & a_scalar0, const double & a_scalar1, const double & a_scalar2 )
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.

this(0) = a_scalar0 * this(0)
this(1) = a_scalar1 * this(1)
this(2) = a_scalar2 * this(2)
Parameters
 a_scalar0 Scalar value for component 0. a_scalar1 Scalar value for component 1. a_scalar2 Scalar value for component 2.
 void chai3d::cVector3d::mulr ( const double & a_scalar, cVector3d & a_result ) const
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_result = a_scalar * this
Parameters
 a_scalar Scalar value. a_result Result of operation.
 void chai3d::cVector3d::mulr ( const double & a_scalar0, const double & a_scalar1, const double & a_scalar2, cVector3d & a_result ) const
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_result(0) = a_scalar0 * this(0)
a_result(1) = a_scalar1 * this(1)
a_result(2) = a_scalar2 * this(2)
Parameters
 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.
 void chai3d::cVector3d::mulElement ( const cVector3d & a_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 this vector.

Parameters
 a_vector Input vector.
 void chai3d::cVector3d::mulElementr ( const cVector3d & a_vector, cVector3d & a_result ) const
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.

Parameters
 a_vector Input vector. a_result Result of operation.
 void chai3d::cVector3d::div ( const double & a_scalar )
inline

This method computes the division of this vector by a scalar `a_scalar` passed by argument.
The result is stored in this vector.

this = this / a_scalar
Parameters
 a_scalar Scalar value.
 void chai3d::cVector3d::divr ( const double & a_scalar, cVector3d & a_result ) const
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_result = this / a_scalar
Parameters
 a_scalar Scalar value. a_result Result of operation.
 void chai3d::cVector3d::negate ( )
inline

This method computes the negated vector of this vector.
The result is stored in this vector.

this = -this
 void chai3d::cVector3d::negater ( cVector3d & a_result ) const
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 = -this
Parameters
 a_result Result of operation.
 void chai3d::cVector3d::cross ( const cVector3d & a_vector )
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.

Parameters
 a_vector Input vector.
 void chai3d::cVector3d::crossr ( const cVector3d & a_vector, cVector3d & a_result ) const
inline

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.

Parameters
 a_vector Input vector. a_result Resulting cross product.
 double chai3d::cVector3d::dot ( const cVector3d & a_vector ) const
inline

This method computes and returns the dot product between this vector and an vector `a_vector` passed by argument.

Parameters
 a_vector Input vector.
Returns
Dot product between both vectors.
 double chai3d::cVector3d::length ( ) const
inline

This method computes and returns the Euclidean norm of this vector.

Returns
Euclidean norm of this vector.
 double chai3d::cVector3d::lengthsq ( ) const
inline

This method computes and returns the squared value of the Euclidean norm of this vector.

Returns
Squared value of the Euclidean norm of this vector.
 void chai3d::cVector3d::normalize ( )
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.

 void chai3d::cVector3d::normalizer ( cVector3d & a_result ) const
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.

Parameters
 a_result Normalized vector.
 void chai3d::cVector3d::clamp ( const double & a_maxLength )
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.

Parameters
 a_maxLength Maximum length value.
 double chai3d::cVector3d::distance ( const cVector3d & a_vector ) const
inline

This method computes and returns the distance between this point and an point `a_vector` passed by argument.

Parameters
 a_vector Input point.
Returns
Distance between both points.
 double chai3d::cVector3d::distancesq ( const cVector3d & a_vector ) const
inline

This method computes and returns the squared value distance between this point and an point `a_vector` passed by argument.

Parameters
 a_vector Input point.
Returns
Squared value distance between both points.
 bool chai3d::cVector3d::equals ( const cVector3d & a_vector, const double a_epsilon = `0.0` ) const
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.

Parameters
 a_vector Input vector. a_epsilon Tolerance error.
Returns
true if both vectors are equal, false otherwise.
 std::string chai3d::cVector3d::str ( const unsigned int a_precision = `2` ) const
inline

This method convert this vector into a string. The number of digits after the decimal point are set by argument `a_precision`.

Parameters
 a_precision Number of digits.
Returns
Converted vector in string format.
 void chai3d::cVector3d::operator/= ( const double & a_val )
inline
 void chai3d::cVector3d::operator*= ( const double & a_val )
inline
 void chai3d::cVector3d::operator+= ( const cVector3d & a_input )
inline
 void chai3d::cVector3d::operator-= ( const cVector3d & a_input )
inline
 double& chai3d::cVector3d::operator() ( const int a_index )
inline
 const double& chai3d::cVector3d::operator() ( const int a_index ) const
inline

The documentation for this struct was generated from the following file:
{"ft_lang_label":"__label__en","ft_lang_prob":0.695696,"math_prob":0.92818326,"size":14173,"snap":"2019-13-2019-22","text_gpt3_token_len":3393,"char_repetition_ratio":0.2474416,"word_repetition_ratio":0.6385431,"special_character_ratio":0.24292669,"punctuation_ratio":0.16291913,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99626565,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-05-21T11:30:22Z\",\"WARC-Record-ID\":\"<urn:uuid:f4055f4e-f950-4fbf-ac6b-f86e03a57d9b>\",\"Content-Length\":\"104574\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:419b6e02-643c-46e2-93e6-e735bd055bf7>\",\"WARC-Concurrent-To\":\"<urn:uuid:79cfe906-1477-4d71-918a-d0abf8d13b44>\",\"WARC-IP-Address\":\"128.65.195.158\",\"WARC-Target-URI\":\"https://chai3d.org/download/doc/html/structchai3d_1_1c_vector3d.html\",\"WARC-Payload-Digest\":\"sha1:KJFEEPFNKZRJPN5ONQOEQVMU4GFIKKFL\",\"WARC-Block-Digest\":\"sha1:FWNJ45LBVL25UQIQ4BH6C65D3QQJ5E5S\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-22/CC-MAIN-2019-22_segments_1558232256314.52_warc_CC-MAIN-20190521102417-20190521124417-00529.warc.gz\"}"}