118 cVector3d(
const double a_x,
const double a_y,
const double a_z)
140 (*this)(0) = a_vector(0);
141 (*this)(1) = a_vector(1);
142 (*this)(2) = a_vector(2);
160 cVector3d (
const Eigen::Vector3d &a_vector)
162 (*this)(0) = a_vector(0);
163 (*this)(1) = a_vector(1);
164 (*this)(2) = a_vector(2);
212 Eigen::Vector3d eigen()
214 return (Eigen::Vector3d((*
this)(0), (*
this)(1), (*
this)(2)));
220 inline double x()
const 226 inline double y()
const 232 inline double z()
const 238 inline void x(
const double a_value)
240 (*this)(0) = a_value;
244 inline void y(
const double a_value)
246 (*this)(1) = a_value;
250 inline void z(
const double a_value)
252 (*this)(2) = a_value;
277 inline double get(
const unsigned int& a_component)
const 279 return ((
const double*)(
this))[a_component];
298 inline void set(
const double& a_x,
const double& a_y,
const double& a_z)
327 inline bool set(
const char* a_initStr)
330 if (a_initStr == 0)
return (
false);
333 const char* curpos = a_initStr;
334 while( (*curpos !=
'\0') &&
335 (*curpos ==
' ' || *curpos ==
'\t' || *curpos ==
'('))
342 std::string
str = a_initStr;
344 for (
int j=0; j<(int)(str.length()); j++)
if (!std::isdigit(str[j], loc) && str[j] !=
'.') str[j] =
' ';
345 std::istringstream is(str);
346 if (!(is >> ax && !is.fail()))
return (
false);
347 if (!(is >> ay && !is.fail()))
return (
false);
348 if (!(is >> az && !is.fail()))
return (
false);
381 inline bool set(
const std::string& a_initStr)
383 return (
set(a_initStr.c_str()) );
405 a_destination(0) = (*this)(0);
406 a_destination(1) = (*this)(1);
407 a_destination(2) = (*this)(2);
429 (*this)(0) = a_source(0);
430 (*this)(1) = a_source(1);
431 (*this)(2) = a_source(2);
454 (*this)(0) = (*
this)(0) + a_vector(0);
455 (*this)(1) = (*
this)(1) + a_vector(1);
456 (*this)(2) = (*
this)(2) + a_vector(2);
479 inline void add(
const double& a_x,
483 (*this)(0) = (*
this)(0) + a_x;
484 (*this)(1) = (*
this)(1) + a_y;
485 (*this)(2) = (*
this)(2) + a_z;
511 a_result(0) = (*this)(0) + a_vector(0);
512 a_result(1) = (*this)(1) + a_vector(1);
513 a_result(2) = (*this)(2) + a_vector(2);
538 inline void addr(
const double& a_x,
543 a_result(0) = (*this)(0) + a_x;
544 a_result(1) = (*this)(1) + a_y;
545 a_result(2) = (*this)(2) + a_z;
568 (*this)(0) = (*
this)(0) - a_vector(0);
569 (*this)(1) = (*
this)(1) - a_vector(1);
570 (*this)(2) = (*
this)(2) - a_vector(2);
593 inline void sub(
const double& a_x,
597 (*this)(0) = (*
this)(0) - a_x;
598 (*this)(1) = (*
this)(1) - a_y;
599 (*this)(2) = (*
this)(2) - a_z;
625 a_result(0) = (*this)(0) - a_vector(0);
626 a_result(1) = (*this)(1) - a_vector(1);
627 a_result(2) = (*this)(2) - a_vector(2);
652 inline void subr(
const double& a_x,
657 a_result(0) = (*this)(0) - a_x;
658 a_result(1) = (*this)(1) - a_y;
659 a_result(2) = (*this)(2) - a_z;
680 inline void mul(
const double &a_scalar)
682 (*this)(0) = a_scalar * (*
this)(0);
683 (*this)(1) = a_scalar * (*
this)(1);
684 (*this)(2) = a_scalar * (*
this)(2);
710 inline void mul(
const double &a_scalar0,
711 const double &a_scalar1,
712 const double &a_scalar2)
714 (*this)(0) = a_scalar0 * (*
this)(0);
715 (*this)(1) = a_scalar1 * (*
this)(1);
716 (*this)(2) = a_scalar2 * (*
this)(2);
739 inline void mulr(
const double& a_scalar,
742 a_result(0) = a_scalar * (*this)(0);
743 a_result(1) = a_scalar * (*this)(1);
744 a_result(2) = a_scalar * (*this)(2);
771 inline void mulr(
const double &a_scalar0,
772 const double &a_scalar1,
773 const double &a_scalar2,
776 a_result(0) = a_scalar0 * (*this)(0);
777 a_result(1) = a_scalar1 * (*this)(1);
778 a_result(2) = a_scalar2 * (*this)(2);
799 (*this)(0)*=a_vector(0);
800 (*this)(1)*=a_vector(1);
801 (*this)(2)*=a_vector(2);
825 a_result(0) = (*this)(0)*a_vector(0);
826 a_result(1) = (*this)(1)*a_vector(1);
827 a_result(2) = (*this)(2)*a_vector(2);
848 inline void div(
const double& a_scalar)
850 double factor = 1.0 / a_scalar;
851 (*this)(0) = (*
this)(0) * factor;
852 (*this)(1) = (*
this)(1) * factor;
853 (*this)(2) = (*
this)(2) * factor;
876 inline void divr(
const double& a_scalar,
879 double factor = 1.0 / a_scalar;
880 a_result(0) = (*this)(0) * factor;
881 a_result(1) = (*this)(1) * factor;
882 a_result(2) = (*this)(2) * factor;
902 (*this)(0) = -(*
this)(0);
903 (*this)(1) = -(*
this)(1);
904 (*this)(2) = -(*
this)(2);
927 a_result(0) = -(*this)(0);
928 a_result(1) = -(*this)(1);
929 a_result(2) = -(*this)(2);
949 double a = ((*this)(1) * a_vector(2) ) - ((*
this)(2) * a_vector(1) );
950 double b = -((*this)(0) * a_vector(2) ) + ((*
this)(2) * a_vector(0) );
951 double c = ((*this)(0) * a_vector(1) ) - ((*
this)(1) * a_vector(0) );
978 a_result(0) = ((*this)(1) * a_vector(2) ) - ((*
this)(2) * a_vector(1) );
979 a_result(1) = -((*this)(0) * a_vector(2) ) + ((*
this)(2) * a_vector(0) );
980 a_result(2) = ((*this)(0) * a_vector(1) ) - ((*
this)(1) * a_vector(0) );
1000 return(((*
this)(0) * a_vector(0) ) + ((*
this)(1) * a_vector(1) ) + ((*
this)(2) * a_vector(2) ));
1017 return(sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2))));
1035 return(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1057 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1058 if (len == 0.0) {
return; }
1059 double factor = 1.0 / len;
1062 (*this)(0) = (*
this)(0) * factor;
1063 (*this)(1) = (*
this)(1) * factor;
1064 (*this)(2) = (*
this)(2) * factor;
1089 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1090 double factor = 1.0 / len;
1093 a_result(0) = (*this)(0) * factor;
1094 a_result(1) = (*this)(1) * factor;
1095 a_result(2) = (*this)(2) * factor;
1113 inline void clamp(
const double& a_maxLength)
1115 double len = sqrt(((*
this)(0) * (*
this)(0)) + ((*
this)(1) * (*
this)(1)) + ((*
this)(2) * (*
this)(2)));
1116 if (a_maxLength == 0)
1122 else if (len > a_maxLength)
1124 double factor = a_maxLength / len;
1125 (*this)(0) = (*
this)(0) * factor;
1126 (*this)(1) = (*
this)(1) * factor;
1127 (*this)(2) = (*
this)(2) * factor;
1149 double dx = (*this)(0) - a_vector(0) ;
1150 double dy = (*this)(1) - a_vector(1) ;
1151 double dz = (*this)(2) - a_vector(2) ;
1154 return(sqrt(dx*dx + dy*dy + dz*dz));
1175 double dx = (*this)(0) - a_vector(0) ;
1176 double dy = (*this)(1) - a_vector(1) ;
1177 double dz = (*this)(2) - a_vector(2) ;
1180 return(dx*dx + dy*dy + dz*dz);
1202 const double a_epsilon = 0.0)
const 1205 if (a_epsilon == 0.0)
1207 if ( ((*
this)(0) == a_vector(0) ) && ((*
this)(1) == a_vector(1) ) && ((*
this)(2) == a_vector(2) ) )
1217 if ((fabs(a_vector(0) - (*
this)(0)) < a_epsilon) &&
1218 (fabs(a_vector(1) - (*
this)(1)) < a_epsilon) &&
1219 (fabs(a_vector(2) - (*
this)(2)) < a_epsilon))
1244 inline std::string
str(
const unsigned int a_precision = 2)
const 1247 result = (
cStr((*
this)(0), a_precision) +
", " +
1248 cStr((*
this)(1), a_precision) +
", " +
1249 cStr((*
this)(2), a_precision));
1263 double factor = 1.0 / a_val;
1264 (*this)(0) *= factor;
1265 (*this)(1) *= factor;
1266 (*this)(2) *= factor;
1273 (*this)(0) *= a_val;
1274 (*this)(1) *= a_val;
1275 (*this)(2) *= a_val;
1282 (*this)(0) += a_input(0);
1283 (*this)(1) += a_input(1);
1284 (*this)(2) += a_input(2);
1291 (*this)(0) -= a_input(0);
1292 (*this)(1) -= a_input(1);
1293 (*this)(2) -= a_input(2);
1300 return m_data[a_index];
1307 return m_data[a_index];
1330 return (
cVector3d(a_vector(0) * a_scale,
1331 a_vector(1) * a_scale,
1332 a_vector(2) * a_scale));
1339 return (
cVector3d(a_vector(0) * a_scale,
1340 a_vector(1) * a_scale,
1341 a_vector(2) * a_scale));
1348 return (
cVector3d(a_vector(0) / a_scale,
1349 a_vector(1) / a_scale,
1350 a_vector(2) / a_scale));
1357 return cVector3d(a_vector0(0) + a_vector1(0),
1358 a_vector0(1) + a_vector1(1),
1359 a_vector0(2) + a_vector1(2));
1366 return cVector3d(a_vector0(0) - a_vector1(0),
1367 a_vector0(1) - a_vector1(1),
1368 a_vector0(2) - a_vector1(2));
1384 return (a_vector0(0) * a_vector1(0) +
1385 a_vector0(1) * a_vector1(1) +
1386 a_vector0(2) * a_vector1(2));
1391 static inline std::ostream &operator << (std::ostream &a_os,
cVector3d const& a_vector)
1393 a_os << a_vector(0) <<
", " << a_vector(1) <<
", " << a_vector(2) ;
This class implements a 3D vector.
Definition: CVector3d.h:88
std::string str(const unsigned int a_precision=2) const
This method convert this vector into a string.
Definition: CVector3d.h:1244
void operator+=(const cVector3d &a_input)
An overloaded += operator for vector/vector addition.
Definition: CVector3d.h:1280
void operator*=(const double &a_val)
An overloaded *= operator for vector/scalar multiplication.
Definition: CVector3d.h:1271
double distance(const cVector3d &a_vector) const
This method computes the distance between two points.
Definition: CVector3d.h:1146
void normalize()
This method normalizes this vector to length 1.
Definition: CVector3d.h:1054
void zero()
This method clears all vector components with zeros.
Definition: CVector3d.h:256
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:1201
void divr(const double &a_scalar, cVector3d &a_result) const
This method computes the division of this vector with a scalar.
Definition: CVector3d.h:876
double distancesq(const cVector3d &a_vector) const
This method computes the squared value distance between two points.
Definition: CVector3d.h:1172
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:118
void div(const double &a_scalar)
This method computes the division of this vector with a scalar.
Definition: CVector3d.h:848
void crossr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the cross product.
Definition: CVector3d.h:975
void y(const double a_value)
This method sets vector component y.
Definition: CVector3d.h:244
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:1086
double length() const
This method computes the Euclidean norm of this vector.
Definition: CVector3d.h:1015
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:652
void sub(const cVector3d &a_vector)
This method computes the subtraction of this vector with another.
Definition: CVector3d.h:566
void mulr(const double &a_scalar, cVector3d &a_result) const
This method computes the multiplication of this vector with a scalar.
Definition: CVector3d.h:739
void copyfrom(const cVector3d &a_source)
This method copies the content of a vector to this one.
Definition: CVector3d.h:427
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:822
Implements mathematical constants.
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:479
void z(const double a_value)
This method sets vector component z.
Definition: CVector3d.h:250
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:538
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:900
void addr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the addition of this vector with another.
Definition: CVector3d.h:508
void operator-=(const cVector3d &a_input)
An overloaded -= operator for vector/vector subtraction.
Definition: CVector3d.h:1289
double lengthsq() const
This method computes the squared value of the Euclidean norm of this vector.
Definition: CVector3d.h:1033
double & operator()(const int a_index)
An overloaded () operator.
Definition: CVector3d.h:1298
void negater(cVector3d &a_result) const
This method computes the negated vector.
Definition: CVector3d.h:925
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:771
void clamp(const double &a_maxLength)
This method clamps this vector to a maximum desired length.
Definition: CVector3d.h:1113
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:710
void copyto(cVector3d &a_destination) const
This method copies the content of this vector to another.
Definition: CVector3d.h:403
void operator/=(const double &a_val)
An overloaded /= operator for vector/scalar division.
Definition: CVector3d.h:1261
void subr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the subtraction of this vector with another.
Definition: CVector3d.h:622
void x(const double a_value)
This method sets vector component x.
Definition: CVector3d.h:238
double y() const
This method returns vector component y.
Definition: CVector3d.h:226
double x() const
This method returns vector component x.
Definition: CVector3d.h:220
void mul(const double &a_scalar)
This method computes the multiplication of this vector with a scalar.
Definition: CVector3d.h:680
cVector3d()
Definition: CVector3d.h:101
double dot(const cVector3d &a_vector) const
This method computes the dot product between this vector and another.
Definition: CVector3d.h:998
Definition: CAudioBuffer.cpp:56
cVector3d(const std::string &a_string)
Constructor of cVector3d.
Definition: CVector3d.h:199
void add(const cVector3d &a_vector)
This method computes the addition of this vector with another.
Definition: CVector3d.h:452
void cross(const cVector3d &a_vector)
This method computes the cross product.
Definition: CVector3d.h:946
void mulElement(const cVector3d &a_vector)
This method computes the element-by-element product between this vector and another.
Definition: CVector3d.h:797
cVector3d(const char *a_string)
Constructor of cVector3d.
Definition: CVector3d.h:182
cVector3d(const cVector3d &a_vector)
Constructor of cVector3d.
Definition: CVector3d.h:138
cVector3d operator/(const cVector3d &a_vector, const double a_scale)
An overloaded / operator for vector/scalar division.
Definition: CVector3d.h:1346
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:593
double z() const
This method returns vector component z.
Definition: CVector3d.h:232