115 cVector3d(
const double a_x,
const double a_y,
const double a_z)
137 (*this)(0) = a_vector(0);
138 (*this)(1) = a_vector(1);
139 (*this)(2) = a_vector(2);
157 cVector3d (
const Eigen::Vector3d &a_vector)
159 (*this)(0) = a_vector(0);
160 (*this)(1) = a_vector(1);
161 (*this)(2) = a_vector(2);
209 Eigen::Vector3d eigen()
211 return (Eigen::Vector3d((*
this)(0), (*
this)(1), (*
this)(2)));
217 inline double x()
const
223 inline double y()
const
229 inline double z()
const
235 inline void x(
const double a_value)
237 (*this)(0) = a_value;
241 inline void y(
const double a_value)
243 (*this)(1) = a_value;
247 inline void z(
const double a_value)
249 (*this)(2) = a_value;
274 inline double get(
const unsigned int& a_component)
const
276 return ((
const double*)(
this))[a_component];
295 inline void set(
const double& a_x,
const double& a_y,
const double& a_z)
324 inline bool set(
const char* a_initStr)
327 if (a_initStr == 0)
return (
false);
330 const char* curpos = a_initStr;
331 while( (*curpos !=
'\0') &&
332 (*curpos ==
' ' || *curpos ==
'\t' || *curpos ==
'('))
339 int result = sscanf(curpos,
"%lf%*[ ,\t\n\r]%lf%*[ ,\t\n\r]%lf", &ax, &ay, &az);
342 if (result != 3)
return (
false);
375 inline bool set(
const std::string& a_initStr)
377 return (
set(a_initStr.c_str()) );
399 a_destination(0) = (*this)(0);
400 a_destination(1) = (*this)(1);
401 a_destination(2) = (*this)(2);
423 (*this)(0) = a_source(0);
424 (*this)(1) = a_source(1);
425 (*this)(2) = a_source(2);
448 (*this)(0) = (*
this)(0) + a_vector(0);
449 (*this)(1) = (*
this)(1) + a_vector(1);
450 (*this)(2) = (*
this)(2) + a_vector(2);
473 inline void add(
const double& a_x,
477 (*this)(0) = (*
this)(0) + a_x;
478 (*this)(1) = (*
this)(1) + a_y;
479 (*this)(2) = (*
this)(2) + a_z;
505 a_result(0) = (*this)(0) + a_vector(0);
506 a_result(1) = (*this)(1) + a_vector(1);
507 a_result(2) = (*this)(2) + a_vector(2);
532 inline void addr(
const double& a_x,
537 a_result(0) = (*this)(0) + a_x;
538 a_result(1) = (*this)(1) + a_y;
539 a_result(2) = (*this)(2) + a_z;
562 (*this)(0) = (*
this)(0) - a_vector(0);
563 (*this)(1) = (*
this)(1) - a_vector(1);
564 (*this)(2) = (*
this)(2) - a_vector(2);
587 inline void sub(
const double& a_x,
591 (*this)(0) = (*
this)(0) - a_x;
592 (*this)(1) = (*
this)(1) - a_y;
593 (*this)(2) = (*
this)(2) - a_z;
619 a_result(0) = (*this)(0) - a_vector(0);
620 a_result(1) = (*this)(1) - a_vector(1);
621 a_result(2) = (*this)(2) - a_vector(2);
646 inline void subr(
const double& a_x,
651 a_result(0) = (*this)(0) - a_x;
652 a_result(1) = (*this)(1) - a_y;
653 a_result(2) = (*this)(2) - a_z;
674 inline void mul(
const double &a_scalar)
676 (*this)(0) = a_scalar * (*
this)(0);
677 (*this)(1) = a_scalar * (*
this)(1);
678 (*this)(2) = a_scalar * (*
this)(2);
704 inline void mul(
const double &a_scalar0,
705 const double &a_scalar1,
706 const double &a_scalar2)
708 (*this)(0) = a_scalar0 * (*
this)(0);
709 (*this)(1) = a_scalar1 * (*
this)(1);
710 (*this)(2) = a_scalar2 * (*
this)(2);
733 inline void mulr(
const double& a_scalar,
736 a_result(0) = a_scalar * (*this)(0);
737 a_result(1) = a_scalar * (*this)(1);
738 a_result(2) = a_scalar * (*this)(2);
765 inline void mulr(
const double &a_scalar0,
766 const double &a_scalar1,
767 const double &a_scalar2,
770 a_result(0) = a_scalar0 * (*this)(0);
771 a_result(1) = a_scalar1 * (*this)(1);
772 a_result(2) = a_scalar2 * (*this)(2);
793 (*this)(0)*=a_vector(0);
794 (*this)(1)*=a_vector(1);
795 (*this)(2)*=a_vector(2);
819 a_result(0) = (*this)(0)*a_vector(0);
820 a_result(1) = (*this)(1)*a_vector(1);
821 a_result(2) = (*this)(2)*a_vector(2);
842 inline void div(
const double& a_scalar)
844 double factor = 1.0 / a_scalar;
845 (*this)(0) = (*
this)(0) * factor;
846 (*this)(1) = (*
this)(1) * factor;
847 (*this)(2) = (*
this)(2) * factor;
870 inline void divr(
const double& a_scalar,
873 double factor = 1.0 / a_scalar;
874 a_result(0) = (*this)(0) * factor;
875 a_result(1) = (*this)(1) * factor;
876 a_result(2) = (*this)(2) * factor;
896 (*this)(0) = -(*
this)(0);
897 (*this)(1) = -(*
this)(1);
898 (*this)(2) = -(*
this)(2);
921 a_result(0) = -(*this)(0);
922 a_result(1) = -(*this)(1);
923 a_result(2) = -(*this)(2);
943 double a = ((*this)(1) * a_vector(2) ) - ((*
this)(2) * a_vector(1) );
944 double b = -((*this)(0) * a_vector(2) ) + ((*
this)(2) * a_vector(0) );
945 double c = ((*this)(0) * a_vector(1) ) - ((*
this)(1) * a_vector(0) );
972 a_result(0) = ((*this)(1) * a_vector(2) ) - ((*
this)(2) * a_vector(1) );
973 a_result(1) = -((*this)(0) * a_vector(2) ) + ((*
this)(2) * a_vector(0) );
974 a_result(2) = ((*this)(0) * a_vector(1) ) - ((*
this)(1) * a_vector(0) );
994 return(((*
this)(0) * a_vector(0) ) + ((*
this)(1) * a_vector(1) ) + ((*
this)(2) * a_vector(2) ));
1011 return(sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2))));
1029 return(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1051 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1052 if (len == 0.0) {
return; }
1053 double factor = 1.0 / len;
1056 (*this)(0) = (*
this)(0) * factor;
1057 (*this)(1) = (*
this)(1) * factor;
1058 (*this)(2) = (*
this)(2) * factor;
1083 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1084 double factor = 1.0 / len;
1087 a_result(0) = (*this)(0) * factor;
1088 a_result(1) = (*this)(1) * factor;
1089 a_result(2) = (*this)(2) * factor;
1107 inline void clamp(
const double& a_maxLength)
1109 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1110 if (a_maxLength == 0)
1116 else if (len > a_maxLength)
1118 double factor = a_maxLength / len;
1119 (*this)(0) = (*
this)(0) * factor;
1120 (*this)(1) = (*
this)(1) * factor;
1121 (*this)(2) = (*
this)(2) * factor;
1143 double dx = (*this)(0) - a_vector(0) ;
1144 double dy = (*this)(1) - a_vector(1) ;
1145 double dz = (*this)(2) - a_vector(2) ;
1148 return(sqrt(dx*dx + dy*dy + dz*dz));
1169 double dx = (*this)(0) - a_vector(0) ;
1170 double dy = (*this)(1) - a_vector(1) ;
1171 double dz = (*this)(2) - a_vector(2) ;
1174 return(dx*dx + dy*dy + dz*dz);
1196 const double a_epsilon = 0.0)
const
1199 if (a_epsilon == 0.0)
1201 if ( ((*
this)(0) == a_vector(0) ) && ((*
this)(1) == a_vector(1) ) && ((*
this)(2) == a_vector(2) ) )
1211 if ((fabs(a_vector(0) - (*
this)(0)) < a_epsilon) &&
1212 (fabs(a_vector(1) - (*
this)(1)) < a_epsilon) &&
1213 (fabs(a_vector(2) - (*
this)(2)) < a_epsilon))
1238 inline std::string
str(
const unsigned int a_precision = 2)
const
1241 result = (
cStr((*
this)(0), a_precision) +
", " +
1242 cStr((*
this)(1), a_precision) +
", " +
1243 cStr((*
this)(2), a_precision));
1257 double factor = 1.0 / a_val;
1258 (*this)(0) *= factor;
1259 (*this)(1) *= factor;
1260 (*this)(2) *= factor;
1267 (*this)(0) *= a_val;
1268 (*this)(1) *= a_val;
1269 (*this)(2) *= a_val;
1276 (*this)(0) += a_input(0);
1277 (*this)(1) += a_input(1);
1278 (*this)(2) += a_input(2);
1285 (*this)(0) -= a_input(0);
1286 (*this)(1) -= a_input(1);
1287 (*this)(2) -= a_input(2);
1294 return m_data[a_index];
1301 return m_data[a_index];
1324 return (
cVector3d(a_vector(0) * a_scale,
1325 a_vector(1) * a_scale,
1326 a_vector(2) * a_scale));
1333 return (
cVector3d(a_vector(0) * a_scale,
1334 a_vector(1) * a_scale,
1335 a_vector(2) * a_scale));
1342 return (
cVector3d(a_vector(0) / a_scale,
1343 a_vector(1) / a_scale,
1344 a_vector(2) / a_scale));
1351 return cVector3d(a_vector0(0) + a_vector1(0),
1352 a_vector0(1) + a_vector1(1),
1353 a_vector0(2) + a_vector1(2));
1360 return cVector3d(a_vector0(0) - a_vector1(0),
1361 a_vector0(1) - a_vector1(1),
1362 a_vector0(2) - a_vector1(2));
1378 return (a_vector0(0) * a_vector1(0) +
1379 a_vector0(1) * a_vector1(1) +
1380 a_vector0(2) * a_vector1(2));
1385 static inline std::ostream &operator << (std::ostream &a_os, cVector3d
const& a_vector)
1387 a_os << a_vector(0) <<
", " << a_vector(1) <<
", " << a_vector(2) ;
This class implements a 3D vector.
Definition: CVector3d.h:85
std::string str(const unsigned int a_precision=2) const
This method convert this vector into a string.
Definition: CVector3d.h:1238
void operator+=(const cVector3d &a_input)
An overloaded += operator for vector/vector addition.
Definition: CVector3d.h:1274
bool set(const std::string &a_initStr)
This method initializes this vector from and input string.
Definition: CVector3d.h:375
void operator*=(const double &a_val)
An overloaded *= operator for vector/scalar multiplication.
Definition: CVector3d.h:1265
double distance(const cVector3d &a_vector) const
This method computes the distance between two points.
Definition: CVector3d.h:1140
void normalize()
This method normalizes this vector to length 1.
Definition: CVector3d.h:1048
void zero()
This method clears all vector components with zeros.
Definition: CVector3d.h:253
bool equals(const cVector3d &a_vector, const double a_epsilon=0.0) const
This method performs an equality test between two vectors.
Definition: CVector3d.h:1195
void divr(const double &a_scalar, cVector3d &a_result) const
This method computes the division of this vector with a scalar.
Definition: CVector3d.h:870
double distancesq(const cVector3d &a_vector) const
This method computes the squared value distance between two points.
Definition: CVector3d.h:1166
cQuaternion operator+(const cQuaternion &a_quaternion0, const cQuaternion &a_quaternion1)
An overloaded + operator for quaternion addition.
Definition: CQuaternion.h:658
cVector3d(const double a_x, const double a_y, const double a_z)
Constructor of cVector3d.
Definition: CVector3d.h:115
void div(const double &a_scalar)
This method computes the division of this vector with a scalar.
Definition: CVector3d.h:842
void crossr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the cross product.
Definition: CVector3d.h:969
void y(const double a_value)
This method sets vector component y.
Definition: CVector3d.h:241
cVector3d operator*(const cMatrix3d &a_matrix, const cVector3d &a_vector)
An overloaded * operator for matrix/vector multiplication.
Definition: CMatrix3d.h:2078
std::string cStr(const bool a_value)
This function converts a boolean into a string.
Definition: CString.cpp:189
void normalizer(cVector3d &a_result) const
This method normalizes this vector to length 1.
Definition: CVector3d.h:1080
double length() const
This method computes the Euclidean norm of this vector.
Definition: CVector3d.h:1009
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.
Definition: CVector3d.h:646
void sub(const cVector3d &a_vector)
This method computes the subtraction of this vector with another.
Definition: CVector3d.h:560
void mulr(const double &a_scalar, cVector3d &a_result) const
This method computes the multiplication of this vector with a scalar.
Definition: CVector3d.h:733
void copyfrom(const cVector3d &a_source)
This method copies the content of a vector to this one.
Definition: CVector3d.h:421
void mulElementr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the element-by-element product between this vector and another.
Definition: CVector3d.h:816
Implements mathematical constants.
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.
Definition: CVector3d.h:295
void add(const double &a_x, const double &a_y, const double &a_z)
This method computes the addition of this vector with another.
Definition: CVector3d.h:473
void z(const double a_value)
This method sets vector component z.
Definition: CVector3d.h:247
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.
Definition: CVector3d.h:532
Implements option settings for CHAI3D.
Implements utility functions for manipulating strings.
cQuaternion operator-(const cQuaternion &a_quaternion0, const cQuaternion &a_quaternion1)
An overloaded - operator for quaternion subtraction.
Definition: CQuaternion.h:667
void negate()
This method computes the negated vector.
Definition: CVector3d.h:894
void addr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the addition of this vector with another.
Definition: CVector3d.h:502
void operator-=(const cVector3d &a_input)
An overloaded -= operator for vector/vector subtraction.
Definition: CVector3d.h:1283
double lengthsq() const
This method computes the squared value of the Euclidean norm of this vector.
Definition: CVector3d.h:1027
double & operator()(const int a_index)
An overloaded () operator.
Definition: CVector3d.h:1292
void negater(cVector3d &a_result) const
This method computes the negated vector.
Definition: CVector3d.h:919
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...
Definition: CVector3d.h:765
void clamp(const double &a_maxLength)
This method clamps this vector to a maximum desired length.
Definition: CVector3d.h:1107
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...
Definition: CVector3d.h:704
void copyto(cVector3d &a_destination) const
This method copies the content of this vector to another.
Definition: CVector3d.h:397
void operator/=(const double &a_val)
An overloaded /= operator for vector/scalar division.
Definition: CVector3d.h:1255
void subr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the subtraction of this vector with another.
Definition: CVector3d.h:616
void x(const double a_value)
This method sets vector component x.
Definition: CVector3d.h:235
double y() const
This method returns vector component y.
Definition: CVector3d.h:223
double x() const
This method returns vector component x.
Definition: CVector3d.h:217
void mul(const double &a_scalar)
This method computes the multiplication of this vector with a scalar.
Definition: CVector3d.h:674
cVector3d()
Definition: CVector3d.h:98
double dot(const cVector3d &a_vector) const
This method computes the dot product between this vector and another.
Definition: CVector3d.h:992
Definition: CAudioBuffer.cpp:56
cVector3d(const std::string &a_string)
Constructor of cVector3d.
Definition: CVector3d.h:196
void add(const cVector3d &a_vector)
This method computes the addition of this vector with another.
Definition: CVector3d.h:446
void cross(const cVector3d &a_vector)
This method computes the cross product.
Definition: CVector3d.h:940
void mulElement(const cVector3d &a_vector)
This method computes the element-by-element product between this vector and another.
Definition: CVector3d.h:791
bool set(const char *a_initStr)
This method initializes this vector from an input ANSI spring.
Definition: CVector3d.h:324
cVector3d(const char *a_string)
Constructor of cVector3d.
Definition: CVector3d.h:179
cVector3d(const cVector3d &a_vector)
Constructor of cVector3d.
Definition: CVector3d.h:135
cVector3d operator/(const cVector3d &a_vector, const double a_scale)
An overloaded / operator for vector/scalar division.
Definition: CVector3d.h:1340
void sub(const double &a_x, const double &a_y, const double &a_z)
This method computes the subtraction of this vector with another.
Definition: CVector3d.h:587
double z() const
This method returns vector component z.
Definition: CVector3d.h:229