CHAI3D  3.0.0
CMaths.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.0.0 $Rev: 1639 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CMathsH
46 #define CMathsH
47 //------------------------------------------------------------------------------
48 #include "math/CTransform.h"
49 #include <math.h>
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 namespace chai3d {
54 //------------------------------------------------------------------------------
55 
56 //==============================================================================
64 //==============================================================================
65 
66 //------------------------------------------------------------------------------
70 //------------------------------------------------------------------------------
71 
73 
74 //==============================================================================
91 //==============================================================================
92 inline bool cCheckBit(const unsigned int& a_value, const unsigned int& a_bitPosition)
93 {
94  if ((a_value & (1<<a_bitPosition)) > 0)
95  {
96  return (true);
97  }
98  else
99  {
100  return (false);
101  }
102 }
103 
104 
105 //==============================================================================
125 //==============================================================================
126 inline unsigned int cSetBit(const unsigned int& a_data, const unsigned int& a_bitPosition, const bool a_value)
127 {
128  if (a_value)
129  {
130  return (a_data | (1<<a_bitPosition));
131  }
132  else
133  {
134  return (a_data & !(1<<a_bitPosition));
135  }
136 }
137 
138 
139 //==============================================================================
152 //==============================================================================
153 inline bool cZero(const double& a_value)
154 {
155  return ((a_value < C_TINY) && (a_value > -C_TINY));
156 }
157 
158 
159 //==============================================================================
172 //==============================================================================
173 template<class T> inline T cAbs(const T& a_value)
174 {
175  return (a_value >= 0 ? a_value : -a_value);
176 }
177 
178 
179 //==============================================================================
191 //==============================================================================
192 template<class T> inline double cSign(const T& a_value)
193 {
194  if (a_value < 0)
195  {
196  return (-1);
197  }
198  else
199  {
200  return (1);
201  }
202 }
203 
204 
205 //==============================================================================
219 //==============================================================================
220 template<class T> inline T cMax(const T& a_value1,
221  const T& a_value2)
222 {
223  return (a_value1 >= a_value2 ? a_value1 : a_value2);
224 }
225 
226 
227 //==============================================================================
241 //==============================================================================
242 template<class T> inline T cMin(const T& a_value1,
243  const T& a_value2)
244 {
245  return (a_value1 <= a_value2 ? a_value1 : a_value2);
246 }
247 
248 
249 //==============================================================================
264 //==============================================================================
265 template<class T> inline T cMax3(const T& a_value1,
266  const T& a_value2,
267  const T& a_value3)
268 {
269  return (cMax(a_value1, cMax(a_value2, a_value3)));
270 }
271 
272 
273 //==============================================================================
288 //==============================================================================
289 template<class T> inline T cMin3(const T& a_value1,
290  const T& a_value2,
291  const T& a_value3)
292 {
293  return (cMin(a_value1, cMin(a_value2, a_value3)));
294 }
295 
296 
297 //==============================================================================
308 //==============================================================================
309 template<class T> inline void cSwap(T& a_value1,
310  T& a_value2)
311 {
312  T value = a_value1;
313  a_value1 = a_value2;
314  a_value2 = value;
315 }
316 
317 
318 //==============================================================================
337 //==============================================================================
338 template<class T> inline T cLerp(const double& a_level,
339  const T& a_value1,
340  const T& a_value2)
341 {
342  return (a_value2 * a_level + a_value1 * (1 - a_level));
343 }
344 
345 
346 //==============================================================================
361 //==============================================================================
362 template<class T> inline T cClamp(const T& a_value,
363  const T& a_low,
364  const T& a_high)
365 {
366  return (a_value < a_low ? a_low : a_value > a_high ? a_high : a_value);
367 }
368 
369 
370 //==============================================================================
383 //==============================================================================
384 template<class T> inline T cClamp0(const T& a_value)
385 {
386  return cMax<T>(0, a_value);
387 }
388 
389 
390 //==============================================================================
403 //==============================================================================
404 inline double cClamp01(const double& a_value)
405 {
406  return (cClamp(a_value, 0.0, 1.0));
407 }
408 
409 
410 //==============================================================================
426 //==============================================================================
427 template<class T, class V> inline bool cContains(const T& a_value,
428  const V& a_low,
429  const V& a_high)
430 {
431  return ((a_value >= a_low) && (a_value <= a_high));
432 }
433 
434 
435 //==============================================================================
451 //==============================================================================
452 inline double cSqr(const double& a_value)
453 {
454  return(a_value*a_value);
455 }
456 
457 
458 //==============================================================================
471 //==============================================================================
472 inline double cSqrt(const double& a_value)
473 {
474  return(sqrt(a_value));
475 }
476 
477 
478 //==============================================================================
490 //==============================================================================
491 inline double cCbrt(const double& a_value)
492 {
493  return (pow(a_value, 1.0/3.0));
494 }
495 
496 
497 //==============================================================================
510 //==============================================================================
511 inline double cCosDeg(const double& a_angleDeg)
512 {
513  return (cos(a_angleDeg * C_DEG2RAD));
514 }
515 
516 
517 //==============================================================================
530 //==============================================================================
531 inline double cSinDeg(const double& a_angleDeg)
532 {
533  return (sin(a_angleDeg * C_DEG2RAD));
534 }
535 
536 
537 //==============================================================================
550 //==============================================================================
551 inline double cTanDeg(const double& a_angleDeg)
552 {
553  return (tan(a_angleDeg * C_DEG2RAD));
554 }
555 
556 
557 //==============================================================================
570 //==============================================================================
571 inline double cCosRad(const double& a_angleRad)
572 {
573  return (cos(a_angleRad));
574 }
575 
576 
577 //==============================================================================
590 //==============================================================================
591 inline double cSinRad(const double& a_angleRad)
592 {
593  return (sin(a_angleRad));
594 }
595 
596 
597 //==============================================================================
610 //==============================================================================
611 inline double cTanRad(const double& a_angleRad)
612 {
613  return (tan(a_angleRad));
614 }
615 
616 
617 //==============================================================================
630 //==============================================================================
631 inline double cDegToRad(const double& a_angleDeg)
632 {
633  return (a_angleDeg * C_DEG2RAD);
634 }
635 
636 
637 //==============================================================================
650 //==============================================================================
651 inline double cRadToDeg(const double& a_angleRad)
652 {
653  return (a_angleRad * C_RAD2DEG);
654 }
655 
656 
657 //==============================================================================
670 //==============================================================================
671 inline int cNumDigits(int a_value)
672 {
673  int value = abs(a_value);
674  int digits = 0;
675  if (value < 10) digits = 1;
676  while (value)
677  {
678  value /= 10;
679  digits++;
680  }
681  return (digits);
682 }
683 
684 
685 //==============================================================================
703 //==============================================================================
704 inline cVector3d cAdd(const cVector3d& a_vector1,
705  const cVector3d& a_vector2)
706 {
707  return cVector3d(
708  a_vector1(0)+a_vector2(0),
709  a_vector1(1)+a_vector2(1),
710  a_vector1(2)+a_vector2(2));
711 }
712 
713 
714 //==============================================================================
734 //==============================================================================
735 inline cVector3d cAdd(const cVector3d& a_vector1,
736  const cVector3d& a_vector2,
737  const cVector3d& a_vector3)
738 {
739  return cVector3d(
740  a_vector1(0) +a_vector2(0) +a_vector3(0) ,
741  a_vector1(1) +a_vector2(1) +a_vector3(1) ,
742  a_vector1(2) +a_vector2(2) +a_vector3(2) );
743 }
744 
745 
746 //==============================================================================
764 //==============================================================================
765 inline cVector3d cSub(const cVector3d& a_vector1,
766  const cVector3d& a_vector2)
767 {
768  return cVector3d(
769  a_vector1(0) -a_vector2(0) ,
770  a_vector1(1) -a_vector2(1) ,
771  a_vector1(2) -a_vector2(2) );
772 }
773 
774 
775 //==============================================================================
792 //==============================================================================
793 inline cVector3d cNegate(const cVector3d& a_vector)
794 {
795  return cVector3d(-a_vector(0),
796  -a_vector(1),
797  -a_vector(2));
798 }
799 
800 
801 //==============================================================================
819 //==============================================================================
820 inline cVector3d cMul(const double& a_value,
821  const cVector3d& a_vector)
822 {
823  return cVector3d(a_vector(0) *a_value,
824  a_vector(1) *a_value,
825  a_vector(2) *a_value);
826 }
827 
828 
829 //==============================================================================
847 //==============================================================================
848 inline cVector3d cDiv(const double& a_value,
849  const cVector3d& a_vector)
850 {
851  double factor = 1.0 / a_value;
852  return (cVector3d(factor * a_vector(0),
853  factor * a_vector(1),
854  factor * a_vector(2)));
855 }
856 
857 
858 //==============================================================================
876 //==============================================================================
877 inline cVector3d cCross(const cVector3d& a_vector1,
878  const cVector3d& a_vector2)
879 {
880  cVector3d result;
881  a_vector1.crossr(a_vector2, result);
882  return (result);
883 }
884 
885 
886 //==============================================================================
904 //==============================================================================
905 inline double cDot(const cVector3d& a_vector1,
906  const cVector3d& a_vector2)
907 {
908  return(a_vector1.dot(a_vector2));
909 }
910 
911 
912 //==============================================================================
925 //==============================================================================
926 inline cVector3d cNormalize(const cVector3d& a_vector)
927 {
928  cVector3d result;
929  a_vector.normalizer(result);
930  return (result);
931 }
932 
933 
934 //==============================================================================
948 //==============================================================================
949 inline double cDistance(const cVector3d& a_point1,
950  const cVector3d& a_point2)
951 {
952  return ( a_point1.distance(a_point2) );
953 }
954 
955 
956 //==============================================================================
970 //==============================================================================
971 inline double cDistanceSq(const cVector3d& a_point1,
972  const cVector3d& a_point2)
973 {
974  return ( a_point1.distancesq(a_point2) );
975 }
976 
977 
978 //==============================================================================
1001 //==============================================================================
1002 bool inline cEqualPoints(const cVector3d& a_point1,
1003  const cVector3d& a_point2,
1004  const double a_epsilon = C_SMALL)
1005 {
1006  // accelerated path for exact equality
1007  if (a_epsilon == 0.0)
1008  {
1009  if ((a_point1(0) == a_point2(0)) && (a_point1(1) == a_point2(1)) && (a_point1(2) == a_point2(2)))
1010  {
1011  return (true);
1012  }
1013  else
1014  {
1015  return (false);
1016  }
1017  }
1018 
1019  if ((fabs(a_point1(0) - a_point2(0)) < a_epsilon) &&
1020  (fabs(a_point1(1) - a_point2(1)) < a_epsilon) &&
1021  (fabs(a_point1(2) - a_point2(2)) < a_epsilon))
1022  {
1023  return (true);
1024  }
1025  else
1026  {
1027  return (false);
1028  }
1029 }
1030 
1031 
1032 //==============================================================================
1042 //==============================================================================
1044 {
1045  cMatrix3d result;
1046  result.identity();
1047  return (result);
1048 }
1049 
1050 
1051 //==============================================================================
1068 //==============================================================================
1069 inline cMatrix3d cAdd(const cMatrix3d& a_matrix1,
1070  const cMatrix3d& a_matrix2)
1071 {
1072  cMatrix3d result;
1073  a_matrix1.addr(a_matrix2, result);
1074  return (result);
1075 }
1076 
1077 
1078 //==============================================================================
1096 //==============================================================================
1097 inline cMatrix3d cSub(const cMatrix3d& a_matrix1,
1098  const cMatrix3d& a_matrix2)
1099 {
1100  cMatrix3d result;
1101  a_matrix1.subr(a_matrix2, result);
1102  return (result);
1103 }
1104 
1105 
1106 //==============================================================================
1133 //==============================================================================
1134 inline cMatrix3d cRotEulerRad(const double& a_angleRad1,
1135  const double& a_angleRad2,
1136  const double& a_angleRad3,
1137  const cEulerOrder a_eulerOrder,
1138  const bool a_useIntrinsicEulerModel = true)
1139 {
1140  // create matrix
1141  cMatrix3d rot;
1142  if (a_useIntrinsicEulerModel)
1143  rot.setIntrinsicEulerRotationRad(a_angleRad1, a_angleRad2, a_angleRad3, a_eulerOrder);
1144  else
1145  rot.setExtrinsicEulerRotationRad(a_angleRad1, a_angleRad2, a_angleRad3, a_eulerOrder);
1146 
1147  // return result
1148  return (rot);
1149 }
1150 
1151 
1152 //==============================================================================
1179 //==============================================================================
1180 inline cMatrix3d cRotEulerDeg(const double& a_angleDeg1,
1181  const double& a_angleDeg2,
1182  const double& a_angleDeg3,
1183  const cEulerOrder a_eulerOrder,
1184  const bool a_useIntrinsicEulerModel = true)
1185 {
1186  // create matrix
1187  cMatrix3d rot;
1188  if (a_useIntrinsicEulerModel)
1189  rot.setExtrinsicEulerRotationDeg(a_angleDeg1, a_angleDeg2, a_angleDeg3, a_eulerOrder);
1190  else
1191  rot.setExtrinsicEulerRotationDeg(a_angleDeg1, a_angleDeg2, a_angleDeg3, a_eulerOrder);
1192 
1193  // return result
1194  return (rot);
1195 }
1196 
1197 
1198 //==============================================================================
1216 //==============================================================================
1217 inline cMatrix3d cRotAxisAngleRad(const double& a_axisX,
1218  const double& a_axisY,
1219  const double& a_axisZ,
1220  const double& a_angleRad)
1221 {
1222  // create matrix
1223  cMatrix3d rot;
1224  rot.setAxisAngleRotationRad(a_axisX,
1225  a_axisY,
1226  a_axisZ,
1227  a_angleRad);
1228 
1229  // return result
1230  return (rot);
1231 }
1232 
1233 
1234 //==============================================================================
1252 //==============================================================================
1253 inline cMatrix3d cRotAxisAngleDeg(const double& a_axisX,
1254  const double& a_axisY,
1255  const double& a_axisZ,
1256  const double& a_angleDeg)
1257 {
1258  // create matrix
1259  cMatrix3d rot;
1260  rot.setAxisAngleRotationDeg(a_axisX,
1261  a_axisY,
1262  a_axisZ,
1263  a_angleDeg);
1264 
1265  // return result
1266  return (rot);
1267 }
1268 
1269 
1270 //==============================================================================
1288 //==============================================================================
1289 inline cMatrix3d cMul(const cMatrix3d& a_matrix1,
1290  const cMatrix3d& a_matrix2)
1291 {
1292  cMatrix3d result;
1293  a_matrix1.mulr(a_matrix2, result);
1294  return (result);
1295 }
1296 
1297 
1298 //==============================================================================
1313 //==============================================================================
1314 inline cVector3d cMul(const cMatrix3d& a_matrix,
1315  const cVector3d& a_vector)
1316 {
1317  cVector3d result;
1318  a_matrix.mulr(a_vector, result);
1319  return(result);
1320 }
1321 
1322 
1323 //==============================================================================
1336 //==============================================================================
1337 inline cMatrix3d cTranspose(const cMatrix3d& a_matrix)
1338 {
1339  cMatrix3d result;
1340  a_matrix.transr(result);
1341  return(result);
1342 }
1343 
1344 
1345 //==============================================================================
1358 //==============================================================================
1359 inline cMatrix3d cInverse(const cMatrix3d& a_matrix)
1360 {
1361  cMatrix3d result;
1362  a_matrix.invertr(result);
1363  return(result);
1364 }
1365 
1366 
1367 //==============================================================================
1381 //==============================================================================
1382 inline double cAngle(const cVector3d& a_vector1,
1383  const cVector3d& a_vector2)
1384 {
1385  // compute length of vectors
1386  double n1 = a_vector1.length();
1387  double n2 = a_vector2.length();
1388  double val = n1 * n2;
1389 
1390  // check if lengths of vectors are not zero
1391  if (fabs(val) < C_SMALL)
1392  {
1393  return (0.0);
1394  }
1395 
1396  // compute angle
1397  double result = a_vector1.dot(a_vector2)/(val);
1398  if (result > 1.0) { result = 1.0; }
1399  else if (result < -1.0) { result = -1.0; }
1400 
1401  return(acos(result));
1402 }
1403 
1404 
1405 //==============================================================================
1419 //==============================================================================
1420 inline double cCosAngle(const cVector3d& a_vector1,
1421  const cVector3d& a_vector2)
1422 {
1423  // compute length of vectors
1424  double n1 = a_vector1.length();
1425  double n2 = a_vector2.length();
1426  double val = n1 * n2;
1427 
1428  // check if lengths of vectors are not zero
1429  if (fabs(val) < C_SMALL)
1430  {
1431  return (0.0);
1432  }
1433 
1434  // compute angle
1435  return(a_vector1.dot(a_vector2)/(val));
1436 }
1437 
1439 
1440 //------------------------------------------------------------------------------
1441 } // namespace chai3d
1442 //------------------------------------------------------------------------------
1443 
1444 //------------------------------------------------------------------------------
1445 #endif // CMathsH
1446 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:85
double cRadToDeg(const double &a_angleRad)
This function converts an angle from radians to degrees.
Definition: CMaths.h:651
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:511
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:1002
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:1140
double cDistance(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the Euclidean distance between two points.
Definition: CMaths.h:949
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:1166
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:1217
int cNumDigits(int a_value)
This function computes the number of digits that compose a given integer.
Definition: CMaths.h:671
void crossr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the cross product.
Definition: CVector3d.h:969
double cCosAngle(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cosine of the angle between two vectors.
Definition: CMaths.h:1420
cVector3d cAdd(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the addition of two vectors.
Definition: CMaths.h:704
double cTanRad(const double &a_angleRad)
This function computes the tangent of an angle defined in radians.
Definition: CMaths.h:611
cMatrix3d cInverse(const cMatrix3d &a_matrix)
This function computes the inverse of a matrix.
Definition: CMaths.h:1359
double cCosRad(const double &a_angleRad)
This function computes the cosine of an angle defined in radians.
Definition: CMaths.h:571
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:1080
double length() const
This method computes the Euclidean norm of this vector.
Definition: CVector3d.h:1009
cVector3d cSub(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the subtraction of two vectors.
Definition: CMaths.h:765
double cSinRad(const double &a_angleRad)
This function computes the sine of an angle defined in radians.
Definition: CMaths.h:591
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:1253
double cCbrt(const double &a_value)
This function computes the cubic root of a scalar.
Definition: CMaths.h:491
double cDegToRad(const double &a_angleDeg)
This function converts an angle from degrees to radians.
Definition: CMaths.h:631
double cDistanceSq(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the squared distance between two points.
Definition: CMaths.h:971
cVector3d cDiv(const double &a_value, const cVector3d &a_vector)
This function computes the division of a vector by a scalar.
Definition: CMaths.h:848
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:551
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:1134
cVector3d cMul(const double &a_value, const cVector3d &a_vector)
This function computes the multiplication of a vector by a scalar.
Definition: CMaths.h:820
double cDot(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the dot product between two vectors.
Definition: CMaths.h:905
Implements a transformation matrix.
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:1043
cVector3d cNormalize(const cVector3d &a_vector)
This function computes the normalized vector.
Definition: CMaths.h:926
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:1180
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:452
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:427
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:384
double cSinDeg(const double &a_angleDeg)
This function computes the sine of an angle defined in degrees.
Definition: CMaths.h:531
cMatrix3d cTranspose(const cMatrix3d &a_matrix)
This function computes the transpose of a matrix.
Definition: CMaths.h:1337
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:793
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:404
cVector3d cCross(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cross product between two vectors.
Definition: CMaths.h:877
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
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:1382
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:472
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

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.