92 inline bool cCheckBit(
const unsigned int& a_value,
const unsigned int& a_bitPosition)
94 if ((a_value & (1<<a_bitPosition)) > 0)
126 inline unsigned int cSetBit(
const unsigned int& a_data,
const unsigned int& a_bitPosition,
const bool a_value)
130 return (a_data | (1<<a_bitPosition));
134 return (a_data & !(1<<a_bitPosition));
153 inline bool cZero(
const double& a_value)
173 template<
class T>
inline T
cAbs(
const T& a_value)
175 return (a_value >= 0 ? a_value : -a_value);
192 template<
class T>
inline double cSign(
const T& a_value)
220 template<
class T>
inline T
cMax(
const T& a_value1,
223 return (a_value1 >= a_value2 ? a_value1 : a_value2);
242 template<
class T>
inline T
cMin(
const T& a_value1,
245 return (a_value1 <= a_value2 ? a_value1 : a_value2);
265 template<
class T>
inline T
cMax3(
const T& a_value1,
269 return (
cMax(a_value1,
cMax(a_value2, a_value3)));
289 template<
class T>
inline T
cMin3(
const T& a_value1,
293 return (
cMin(a_value1,
cMin(a_value2, a_value3)));
309 template<
class T>
inline void cSwap(T& a_value1,
338 template<
class T>
inline T
cLerp(
const double& a_level,
342 return (a_value2 * a_level + a_value1 * (1 - a_level));
362 template<
class T>
inline T
cClamp(
const T& a_value,
366 if (a_value < a_low)
return a_low;
367 else if (a_value > a_high)
return a_high;
386 template<
class T>
inline T
cClamp0(
const T& a_value)
388 return cMax<T>(0, a_value);
408 return (
cClamp(a_value, 0.0, 1.0));
429 template<
class T,
class V>
inline bool cContains(
const T& a_value,
433 return ((a_value >= a_low) && (a_value <= a_high));
454 inline double cSqr(
const double& a_value)
456 return(a_value*a_value);
474 inline double cSqrt(
const double& a_value)
476 return(sqrt(a_value));
493 inline double cCbrt(
const double& a_value)
495 return (pow(a_value, 1.0/3.0));
513 inline double cCosDeg(
const double& a_angleDeg)
533 inline double cSinDeg(
const double& a_angleDeg)
553 inline double cTanDeg(
const double& a_angleDeg)
573 inline double cCosRad(
const double& a_angleRad)
575 return (cos(a_angleRad));
593 inline double cSinRad(
const double& a_angleRad)
595 return (sin(a_angleRad));
613 inline double cTanRad(
const double& a_angleRad)
615 return (tan(a_angleRad));
677 if (a_value == 0) {
return (1); }
679 double value = (double)(abs(a_value));
712 a_vector1(0)+a_vector2(0),
713 a_vector1(1)+a_vector2(1),
714 a_vector1(2)+a_vector2(2));
744 a_vector1(0) +a_vector2(0) +a_vector3(0) ,
745 a_vector1(1) +a_vector2(1) +a_vector3(1) ,
746 a_vector1(2) +a_vector2(2) +a_vector3(2) );
773 a_vector1(0) -a_vector2(0) ,
774 a_vector1(1) -a_vector2(1) ,
775 a_vector1(2) -a_vector2(2) );
828 a_vector(1) *a_value,
829 a_vector(2) *a_value);
855 double factor = 1.0 / a_value;
857 factor * a_vector(1),
858 factor * a_vector(2)));
885 a_vector1.
crossr(a_vector2, result);
912 return(a_vector1.
dot(a_vector2));
956 return ( a_point1.
distance(a_point2) );
1008 const double a_epsilon =
C_SMALL)
1011 if (a_epsilon == 0.0)
1013 if ((a_point1(0) == a_point2(0)) && (a_point1(1) == a_point2(1)) && (a_point1(2) == a_point2(2)))
1023 if ((fabs(a_point1(0) - a_point2(0)) < a_epsilon) &&
1024 (fabs(a_point1(1) - a_point2(1)) < a_epsilon) &&
1025 (fabs(a_point1(2) - a_point2(2)) < a_epsilon))
1077 a_matrix1.
addr(a_matrix2, result);
1105 a_matrix1.
subr(a_matrix2, result);
1139 const double& a_angleRad2,
1140 const double& a_angleRad3,
1142 const bool a_useIntrinsicEulerModel =
true)
1146 if (a_useIntrinsicEulerModel)
1185 const double& a_angleDeg2,
1186 const double& a_angleDeg3,
1188 const bool a_useIntrinsicEulerModel =
true)
1192 if (a_useIntrinsicEulerModel)
1222 const double& a_axisY,
1223 const double& a_axisZ,
1224 const double& a_angleRad)
1258 const double& a_axisY,
1259 const double& a_axisZ,
1260 const double& a_angleDeg)
1297 a_matrix1.
mulr(a_matrix2, result);
1322 a_matrix.
mulr(a_vector, result);
1390 double n1 = a_vector1.
length();
1391 double n2 = a_vector2.
length();
1392 double val = n1 * n2;
1401 double result = a_vector1.
dot(a_vector2)/(val);
1402 if (result > 1.0) { result = 1.0; }
1403 else if (result < -1.0) { result = -1.0; }
1405 return(acos(result));
1428 double n1 = a_vector1.
length();
1429 double n2 = a_vector2.
length();
1430 double val = n1 * n2;
1439 return(a_vector1.
dot(a_vector2)/(val));
This class implements a 3D vector.
Definition: CVector3d.h:88
double cRadToDeg(const double &a_angleRad)
This function converts an angle from radians to degrees.
Definition: CMaths.h:653
void setExtrinsicEulerRotationDeg(const double &a_angle1, const double &a_angle2, const double &a_angle3, const cEulerOrder a_eulerOrder)
This method builds a rotation matrix from an Euler angle representation.
Definition: CMatrix3d.h:1411
bool setAxisAngleRotationRad(const cVector3d &a_axis, const double &a_angleRad)
This method builds a rotation matrix from an axis-angle representation.
Definition: CMatrix3d.h:1211
const double C_SMALL
Small value near zero.
Definition: CConstants.h:103
double cCosDeg(const double &a_angleDeg)
Compute the cosine of an angle defined in degrees.
Definition: CMaths.h:513
bool cEqualPoints(const cVector3d &a_point1, const cVector3d &a_point2, const double a_epsilon=C_SMALL)
This function determines whether two vectors are equal (i.e. represent the same point).
Definition: CMaths.h:1006
bool setAxisAngleRotationDeg(const cVector3d &a_axis, const double &a_angleDeg)
This method builds a rotation matrix from an axis-angle representation.
Definition: CMatrix3d.h:1260
void mulr(const cMatrix3d &a_matrix, cMatrix3d &a_result) const
This function computes the multiplication of this matrix with another.
Definition: CMatrix3d.h:922
T cLerp(const double &a_level, const T &a_value1, const T &a_value2)
This function computes a linear interpolation between two values.
Definition: CMaths.h:338
double distance(const cVector3d &a_vector) const
This method computes the distance between two points.
Definition: CVector3d.h:1146
double cDistance(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the Euclidean distance between two points.
Definition: CMaths.h:953
const double C_RAD2DEG
Conversion from radians to degrees.
Definition: CConstants.h:97
double distancesq(const cVector3d &a_vector) const
This method computes the squared value distance between two points.
Definition: CVector3d.h:1172
cMatrix3d cRotAxisAngleRad(const double &a_axisX, const double &a_axisY, const double &a_axisZ, const double &a_angleRad)
This function builds a rotation matrix from an axis-angle representation.
Definition: CMaths.h:1221
int cNumDigits(int a_value)
This function computes the number of digits that compose a given integer.
Definition: CMaths.h:673
void crossr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the cross product.
Definition: CVector3d.h:975
double cCosAngle(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cosine of the angle between two vectors.
Definition: CMaths.h:1424
cVector3d cAdd(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the addition of two vectors.
Definition: CMaths.h:708
double cTanRad(const double &a_angleRad)
This function computes the tangent of an angle defined in radians.
Definition: CMaths.h:613
cMatrix3d cInverse(const cMatrix3d &a_matrix)
This function computes the inverse of a matrix.
Definition: CMaths.h:1363
double cCosRad(const double &a_angleRad)
This function computes the cosine of an angle defined in radians.
Definition: CMaths.h:573
unsigned int cSetBit(const unsigned int &a_data, const unsigned int &a_bitPosition, const bool a_value)
This function sets the value of a specified bit of an unsigned integer.
Definition: CMaths.h:126
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
cVector3d cSub(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the subtraction of two vectors.
Definition: CMaths.h:769
double cSinRad(const double &a_angleRad)
This function computes the sine of an angle defined in radians.
Definition: CMaths.h:593
cMatrix3d cRotAxisAngleDeg(const double &a_axisX, const double &a_axisY, const double &a_axisZ, const double &a_angleDeg)
This function builds a rotation matrix from an axis-angle representation.
Definition: CMaths.h:1257
double cCbrt(const double &a_value)
This function computes the cubic root of a scalar.
Definition: CMaths.h:493
double cDegToRad(const double &a_angleDeg)
This function converts an angle from degrees to radians.
Definition: CMaths.h:633
double cDistanceSq(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the squared distance between two points.
Definition: CMaths.h:975
cVector3d cDiv(const double &a_value, const cVector3d &a_vector)
This function computes the division of a vector by a scalar.
Definition: CMaths.h:852
const double C_DEG2RAD
Conversion from degrees to radians.
Definition: CConstants.h:94
T cMin3(const T &a_value1, const T &a_value2, const T &a_value3)
This function computes the minimum value between three values.
Definition: CMaths.h:289
This class implements a 3D matrix.
Definition: CMatrix3d.h:97
double cTanDeg(const double &a_angleDeg)
This function computes the tangent of an angle defined in degrees.
Definition: CMaths.h:553
cMatrix3d cRotEulerRad(const double &a_angleRad1, const double &a_angleRad2, const double &a_angleRad3, const cEulerOrder a_eulerOrder, const bool a_useIntrinsicEulerModel=true)
This function builds a rotation matrix from a set of Euler angles defined in radians.
Definition: CMaths.h:1138
cVector3d cMul(const double &a_value, const cVector3d &a_vector)
This function computes the multiplication of a vector by a scalar.
Definition: CMaths.h:824
double cDot(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the dot product between two vectors.
Definition: CMaths.h:909
const double C_TINY
Smallest value near zero for a double.
Definition: CConstants.h:100
void cSwap(T &a_value1, T &a_value2)
This function swaps two elements.
Definition: CMaths.h:309
cMatrix3d cIdentity3d(void)
This function return a 3x3 identity matrix.
Definition: CMaths.h:1047
cVector3d cNormalize(const cVector3d &a_vector)
This function computes the normalized vector.
Definition: CMaths.h:930
T cMax3(const T &a_value1, const T &a_value2, const T &a_value3)
This function computes the maximum value between three values.
Definition: CMaths.h:265
cMatrix3d cRotEulerDeg(const double &a_angleDeg1, const double &a_angleDeg2, const double &a_angleDeg3, const cEulerOrder a_eulerOrder, const bool a_useIntrinsicEulerModel=true)
This function builds a rotation matrix from a set of Euler angles defined in degrees.
Definition: CMaths.h:1184
double cSign(const T &a_value)
This function computes the sign of a value.
Definition: CMaths.h:192
cEulerOrder
Definition: CMatrix3d.h:57
double cSqr(const double &a_value)
This function computes the square of a scalar.
Definition: CMaths.h:454
T cAbs(const T &a_value)
This function computes an absolute value.
Definition: CMaths.h:173
bool cCheckBit(const unsigned int &a_value, const unsigned int &a_bitPosition)
This function checks if a given bit is enabled.
Definition: CMaths.h:92
bool cContains(const T &a_value, const V &a_low, const V &a_high)
This function checks whether a value is within a specified range.
Definition: CMaths.h:429
void setExtrinsicEulerRotationRad(const double &a_angle1, const double &a_angle2, const double &a_angle3, const cEulerOrder a_eulerOrder)
This method builds a rotation matrix from an Euler angle representation.
Definition: CMatrix3d.h:1337
T cClamp0(const T &a_value)
This function clamps a value to a value ranged between 0 and infinity.
Definition: CMaths.h:386
double cSinDeg(const double &a_angleDeg)
This function computes the sine of an angle defined in degrees.
Definition: CMaths.h:533
cMatrix3d cTranspose(const cMatrix3d &a_matrix)
This function computes the transpose of a matrix.
Definition: CMaths.h:1341
T cMin(const T &a_value1, const T &a_value2)
This function computes the minimum value between two values.
Definition: CMaths.h:242
bool invertr(cMatrix3d &a_result) const
This method computes the inverse of this matrix.
Definition: CMatrix3d.h:1132
cVector3d cNegate(const cVector3d &a_vector)
This function computes the negated vector.
Definition: CMaths.h:797
T cClamp(const T &a_value, const T &a_low, const T &a_high)
This function clamps a value to a specified range.
Definition: CMaths.h:362
double cClamp01(const double &a_value)
This function clamps a value to a value ranged between 0.0 and 1.0.
Definition: CMaths.h:406
cVector3d cCross(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cross product between two vectors.
Definition: CMaths.h:881
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
void identity()
This method builds an identity matrix.
Definition: CMatrix3d.h:325
double cAngle(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the angle in radians between two vectors.
Definition: CMaths.h:1386
bool cZero(const double &a_value)
This function checks if a value is equal to or almost near zero.
Definition: CMaths.h:153
void setIntrinsicEulerRotationRad(const double &a_angle1, const double &a_angle2, const double &a_angle3, const cEulerOrder a_eulerOrder)
This method builds a rotation matrix from an Euler angle representation.
Definition: CMatrix3d.h:1439
void subr(const cMatrix3d &a_matrix, cMatrix3d &a_result) const
This method computes the subtraction of this matrix with another.
Definition: CMatrix3d.h:850
void addr(const cMatrix3d &a_matrix, cMatrix3d &a_result) const
This method computes the addition of this matrix with another.
Definition: CMatrix3d.h:785
double cSqrt(const double &a_value)
This function computes the square root of a scalar.
Definition: CMaths.h:474
T cMax(const T &a_value1, const T &a_value2)
This function computes the maximum value between two values.
Definition: CMaths.h:220
void transr(cMatrix3d &a_result) const
This method computes the transpose of this matrix.
Definition: CMatrix3d.h:1049