My Project
Loading...
Searching...
No Matches
CMaths.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CMathsH
46#define CMathsH
47//------------------------------------------------------------------------------
48#include "math/CTransform.h"
49#define _USE_MATH_DEFINES
50#include <math.h>
51//------------------------------------------------------------------------------
52
53//------------------------------------------------------------------------------
54namespace chai3d {
55//------------------------------------------------------------------------------
56
57//==============================================================================
65//==============================================================================
66
67//------------------------------------------------------------------------------
71//------------------------------------------------------------------------------
72
74
75//==============================================================================
92//==============================================================================
93inline bool cCheckBit(const unsigned int& a_value, const unsigned int& a_bitPosition)
94{
95 if ((a_value & (1<<a_bitPosition)) > 0)
96 {
97 return (true);
98 }
99 else
100 {
101 return (false);
102 }
103}
104
105
106//==============================================================================
126//==============================================================================
127inline unsigned int cSetBit(const unsigned int& a_data, const unsigned int& a_bitPosition, const bool a_value)
128{
129 if (a_value)
130 {
131 return (a_data | (1<<a_bitPosition));
132 }
133 else
134 {
135 return (a_data & ~(1<<a_bitPosition));
136 }
137}
138
139
140//==============================================================================
154//==============================================================================
155inline bool cZero(const double& a_value, const double& a_tolerance = C_TINY)
156{
157 return ((a_value < a_tolerance) && (a_value > -a_tolerance));
158}
159
160
161//==============================================================================
176//==============================================================================
177inline bool cEqual(const double& a_value1, const double& a_value2, const double& a_tolerance = C_TINY)
178{
179 double value = a_value1 - a_value2;
180 return ((value < a_tolerance) && (value > -a_tolerance));
181}
182
183
184//==============================================================================
197//==============================================================================
198template<class T> inline T cAbs(const T& a_value)
199{
200 return (a_value >= 0 ? a_value : -a_value);
201}
202
203
204//==============================================================================
216//==============================================================================
217template<class T> inline double cSign(const T& a_value)
218{
219 if (a_value < 0)
220 {
221 return (-1);
222 }
223 else
224 {
225 return (1);
226 }
227}
228
229
230//==============================================================================
244//==============================================================================
245template<class T> inline T cMax(const T& a_value1,
246 const T& a_value2)
247{
248 return (a_value1 >= a_value2 ? a_value1 : a_value2);
249}
250
251
252//==============================================================================
266//==============================================================================
267template<class T> inline T cMin(const T& a_value1,
268 const T& a_value2)
269{
270 return (a_value1 <= a_value2 ? a_value1 : a_value2);
271}
272
273
274//==============================================================================
289//==============================================================================
290template<class T> inline T cMax3(const T& a_value1,
291 const T& a_value2,
292 const T& a_value3)
293{
294 return (cMax(a_value1, cMax(a_value2, a_value3)));
295}
296
297
298//==============================================================================
313//==============================================================================
314template<class T> inline T cMin3(const T& a_value1,
315 const T& a_value2,
316 const T& a_value3)
317{
318 return (cMin(a_value1, cMin(a_value2, a_value3)));
319}
320
321
322//==============================================================================
333//==============================================================================
334template<class T> inline void cSwap(T& a_value1,
335 T& a_value2)
336{
337 T value = a_value1;
338 a_value1 = a_value2;
339 a_value2 = value;
340}
341
342
343//==============================================================================
362//==============================================================================
363template<class T> inline T cLerp(const double& a_level,
364 const T& a_value1,
365 const T& a_value2)
366{
367 return (a_value2 * a_level + a_value1 * (1 - a_level));
368}
369
370
371//==============================================================================
386//==============================================================================
387template<class T> inline T cClamp(const T& a_value,
388 const T& a_low,
389 const T& a_high)
390{
391 if (a_value < a_low) return a_low;
392 else if (a_value > a_high) return a_high;
393 else return a_value;
394}
395
396
397//==============================================================================
410//==============================================================================
411template<class T> inline T cClamp0(const T& a_value)
412{
413 return cMax<T>(0, a_value);
414}
415
416
417//==============================================================================
430//==============================================================================
431inline double cClamp01(const double& a_value)
432{
433 return (cClamp(a_value, 0.0, 1.0));
434}
435
436
437//==============================================================================
453//==============================================================================
454template<class T, class V> inline bool cContains(const T& a_value,
455 const V& a_low,
456 const V& a_high)
457{
458 return ((a_value >= a_low) && (a_value <= a_high));
459}
460
461
462//==============================================================================
478//==============================================================================
479inline double cSqr(const double& a_value)
480{
481 return(a_value*a_value);
482}
483
484
485//==============================================================================
498//==============================================================================
499inline double cSqrt(const double& a_value)
500{
501 return(sqrt(a_value));
502}
503
504
505//==============================================================================
517//==============================================================================
518inline double cCbrt(const double& a_value)
519{
520 return (pow(a_value, 1.0/3.0));
521}
522
523
524//==============================================================================
539//==============================================================================
540inline double cModuloRange(double a_value, double a_min, double a_max)
541{
542 double range = a_max - a_min;
543 double result = a_value;
544
545 if (a_value > a_max)
546 {
547 double value = a_value - a_min;
548 double num = std::trunc(value / range);
549 result = a_value - num * range;
550 }
551 else if (a_value < a_min)
552 {
553 double value = a_max - a_value;
554 double num = std::trunc(value / range);
555 result = a_value + num * range;
556 }
557
558 return result;
559}
560
561
562//==============================================================================
575//==============================================================================
576inline double cCosDeg(const double& a_angleDeg)
577{
578 return (cos(a_angleDeg * C_DEG2RAD));
579}
580
581
582//==============================================================================
595//==============================================================================
596inline double cSinDeg(const double& a_angleDeg)
597{
598 return (sin(a_angleDeg * C_DEG2RAD));
599}
600
601
602//==============================================================================
615//==============================================================================
616inline double cTanDeg(const double& a_angleDeg)
617{
618 return (tan(a_angleDeg * C_DEG2RAD));
619}
620
621
622//==============================================================================
635//==============================================================================
636inline double cCosRad(const double& a_angleRad)
637{
638 return (cos(a_angleRad));
639}
640
641
642//==============================================================================
655//==============================================================================
656inline double cSinRad(const double& a_angleRad)
657{
658 return (sin(a_angleRad));
659}
660
661
662//==============================================================================
675//==============================================================================
676inline double cTanRad(const double& a_angleRad)
677{
678 return (tan(a_angleRad));
679}
680
681
682//==============================================================================
695//==============================================================================
696inline double cDegToRad(const double& a_angleDeg)
697{
698 return (a_angleDeg * C_DEG2RAD);
699}
700
701
702//==============================================================================
715//==============================================================================
716inline double cRadToDeg(const double& a_angleRad)
717{
718 return (a_angleRad * C_RAD2DEG);
719}
720
721
722//==============================================================================
735//==============================================================================
736inline int cNumDigits(int a_value)
737{
738 int digits = 0;
739
740 if (a_value == 0) { return (1); }
741
742 double value = (double)(abs(a_value));
743 while (value >= 1.0)
744 {
745 value /= 10;
746 digits++;
747 }
748 return (digits);
749}
750
751
752//==============================================================================
770//==============================================================================
771inline cVector3d cAdd(const cVector3d& a_vector1,
772 const cVector3d& a_vector2)
773{
774 return cVector3d(
775 a_vector1(0)+a_vector2(0),
776 a_vector1(1)+a_vector2(1),
777 a_vector1(2)+a_vector2(2));
778}
779
780
781//==============================================================================
801//==============================================================================
802inline cVector3d cAdd(const cVector3d& a_vector1,
803 const cVector3d& a_vector2,
804 const cVector3d& a_vector3)
805{
806 return cVector3d(
807 a_vector1(0) +a_vector2(0) +a_vector3(0) ,
808 a_vector1(1) +a_vector2(1) +a_vector3(1) ,
809 a_vector1(2) +a_vector2(2) +a_vector3(2) );
810}
811
812
813//==============================================================================
831//==============================================================================
832inline cVector3d cSub(const cVector3d& a_vector1,
833 const cVector3d& a_vector2)
834{
835 return cVector3d(
836 a_vector1(0) -a_vector2(0) ,
837 a_vector1(1) -a_vector2(1) ,
838 a_vector1(2) -a_vector2(2) );
839}
840
841
842//==============================================================================
859//==============================================================================
860inline cVector3d cNegate(const cVector3d& a_vector)
861{
862 return cVector3d(-a_vector(0),
863 -a_vector(1),
864 -a_vector(2));
865}
866
867
868//==============================================================================
886//==============================================================================
887inline cVector3d cMul(const double& a_value,
888 const cVector3d& a_vector)
889{
890 return cVector3d(a_vector(0) *a_value,
891 a_vector(1) *a_value,
892 a_vector(2) *a_value);
893}
894
895
896//==============================================================================
914//==============================================================================
915inline cVector3d cDiv(const double& a_value,
916 const cVector3d& a_vector)
917{
918 double factor = 1.0 / a_value;
919 return (cVector3d(factor * a_vector(0),
920 factor * a_vector(1),
921 factor * a_vector(2)));
922}
923
924
925//==============================================================================
943//==============================================================================
944inline cVector3d cCross(const cVector3d& a_vector1,
945 const cVector3d& a_vector2)
946{
947 cVector3d result;
948 a_vector1.crossr(a_vector2, result);
949 return (result);
950}
951
952
953//==============================================================================
971//==============================================================================
972inline double cDot(const cVector3d& a_vector1,
973 const cVector3d& a_vector2)
974{
975 return(a_vector1.dot(a_vector2));
976}
977
978
979//==============================================================================
992//==============================================================================
993inline cVector3d cNormalize(const cVector3d& a_vector)
994{
995 cVector3d result;
996 a_vector.normalizer(result);
997 return (result);
998}
999
1000
1001//==============================================================================
1015//==============================================================================
1016inline double cDistance(const cVector3d& a_point1,
1017 const cVector3d& a_point2)
1018{
1019 return ( a_point1.distance(a_point2) );
1020}
1021
1022
1023//==============================================================================
1037//==============================================================================
1038inline double cDistanceSq(const cVector3d& a_point1,
1039 const cVector3d& a_point2)
1040{
1041 return ( a_point1.distancesq(a_point2) );
1042}
1043
1044
1045//==============================================================================
1068//==============================================================================
1069bool inline cEqualPoints(const cVector3d& a_point1,
1070 const cVector3d& a_point2,
1071 const double a_epsilon = C_SMALL)
1072{
1073 // accelerated path for exact equality
1074 if (a_epsilon == 0.0)
1075 {
1076 if ((a_point1(0) == a_point2(0)) && (a_point1(1) == a_point2(1)) && (a_point1(2) == a_point2(2)))
1077 {
1078 return (true);
1079 }
1080 else
1081 {
1082 return (false);
1083 }
1084 }
1085
1086 if ((fabs(a_point1(0) - a_point2(0)) < a_epsilon) &&
1087 (fabs(a_point1(1) - a_point2(1)) < a_epsilon) &&
1088 (fabs(a_point1(2) - a_point2(2)) < a_epsilon))
1089 {
1090 return (true);
1091 }
1092 else
1093 {
1094 return (false);
1095 }
1096}
1097
1098
1099//==============================================================================
1109//==============================================================================
1111{
1112 cMatrix3d result;
1113 result.identity();
1114 return (result);
1115}
1116
1117
1118//==============================================================================
1135//==============================================================================
1136inline cMatrix3d cAdd(const cMatrix3d& a_matrix1,
1137 const cMatrix3d& a_matrix2)
1138{
1139 cMatrix3d result;
1140 a_matrix1.addr(a_matrix2, result);
1141 return (result);
1142}
1143
1144
1145//==============================================================================
1163//==============================================================================
1164inline cMatrix3d cSub(const cMatrix3d& a_matrix1,
1165 const cMatrix3d& a_matrix2)
1166{
1167 cMatrix3d result;
1168 a_matrix1.subr(a_matrix2, result);
1169 return (result);
1170}
1171
1172
1173//==============================================================================
1200//==============================================================================
1201inline cMatrix3d cRotEulerRad(const double& a_angleRad1,
1202 const double& a_angleRad2,
1203 const double& a_angleRad3,
1204 const cEulerOrder a_eulerOrder,
1205 const bool a_useIntrinsicEulerModel = true)
1206{
1207 // create matrix
1208 cMatrix3d rot;
1209 if (a_useIntrinsicEulerModel)
1210 rot.setIntrinsicEulerRotationRad(a_angleRad1, a_angleRad2, a_angleRad3, a_eulerOrder);
1211 else
1212 rot.setExtrinsicEulerRotationRad(a_angleRad1, a_angleRad2, a_angleRad3, a_eulerOrder);
1213
1214 // return result
1215 return (rot);
1216}
1217
1218
1219//==============================================================================
1246//==============================================================================
1247inline cMatrix3d cRotEulerDeg(const double& a_angleDeg1,
1248 const double& a_angleDeg2,
1249 const double& a_angleDeg3,
1250 const cEulerOrder a_eulerOrder,
1251 const bool a_useIntrinsicEulerModel = true)
1252{
1253 // create matrix
1254 cMatrix3d rot;
1255 if (a_useIntrinsicEulerModel)
1256 rot.setIntrinsicEulerRotationDeg(a_angleDeg1, a_angleDeg2, a_angleDeg3, a_eulerOrder);
1257 else
1258 rot.setExtrinsicEulerRotationDeg(a_angleDeg1, a_angleDeg2, a_angleDeg3, a_eulerOrder);
1259
1260 // return result
1261 return (rot);
1262}
1263
1264
1265//==============================================================================
1283//==============================================================================
1284inline cMatrix3d cRotAxisAngleRad(const double& a_axisX,
1285 const double& a_axisY,
1286 const double& a_axisZ,
1287 const double& a_angleRad)
1288{
1289 // create matrix
1290 cMatrix3d rot;
1291 rot.setAxisAngleRotationRad(a_axisX,
1292 a_axisY,
1293 a_axisZ,
1294 a_angleRad);
1295
1296 // return result
1297 return (rot);
1298}
1299
1300
1301//==============================================================================
1319//==============================================================================
1320inline cMatrix3d cRotAxisAngleDeg(const double& a_axisX,
1321 const double& a_axisY,
1322 const double& a_axisZ,
1323 const double& a_angleDeg)
1324{
1325 // create matrix
1326 cMatrix3d rot;
1327 rot.setAxisAngleRotationDeg(a_axisX,
1328 a_axisY,
1329 a_axisZ,
1330 a_angleDeg);
1331
1332 // return result
1333 return (rot);
1334}
1335
1336
1337//==============================================================================
1355//==============================================================================
1356inline cMatrix3d cMul(const cMatrix3d& a_matrix1,
1357 const cMatrix3d& a_matrix2)
1358{
1359 cMatrix3d result;
1360 a_matrix1.mulr(a_matrix2, result);
1361 return (result);
1362}
1363
1364
1365//==============================================================================
1380//==============================================================================
1381inline cVector3d cMul(const cMatrix3d& a_matrix,
1382 const cVector3d& a_vector)
1383{
1384 cVector3d result;
1385 a_matrix.mulr(a_vector, result);
1386 return(result);
1387}
1388
1389
1390//==============================================================================
1403//==============================================================================
1404inline cMatrix3d cTranspose(const cMatrix3d& a_matrix)
1405{
1406 cMatrix3d result;
1407 a_matrix.transr(result);
1408 return(result);
1409}
1410
1411
1412//==============================================================================
1425//==============================================================================
1426inline cMatrix3d cInverse(const cMatrix3d& a_matrix)
1427{
1428 cMatrix3d result;
1429 a_matrix.invertr(result);
1430 return(result);
1431}
1432
1433
1434//==============================================================================
1448//==============================================================================
1449inline double cAngle(const cVector3d& a_vector1,
1450 const cVector3d& a_vector2)
1451{
1452 // compute length of vectors
1453 double n1 = a_vector1.length();
1454 double n2 = a_vector2.length();
1455 double val = n1 * n2;
1456
1457 // check if lengths of vectors are not zero
1458 if (fabs(val) < C_SMALL)
1459 {
1460 return (0.0);
1461 }
1462
1463 // compute angle
1464 double result = a_vector1.dot(a_vector2)/(val);
1465 if (result > 1.0) { result = 1.0; }
1466 else if (result < -1.0) { result = -1.0; }
1467
1468 return(acos(result));
1469}
1470
1471
1472//==============================================================================
1486//==============================================================================
1487inline double cCosAngle(const cVector3d& a_vector1,
1488 const cVector3d& a_vector2)
1489{
1490 // compute length of vectors
1491 double n1 = a_vector1.length();
1492 double n2 = a_vector2.length();
1493 double val = n1 * n2;
1494
1495 // check if lengths of vectors are not zero
1496 if (fabs(val) < C_SMALL)
1497 {
1498 return (0.0);
1499 }
1500
1501 // compute angle
1502 return(a_vector1.dot(a_vector2)/(val));
1503}
1504
1506
1507//------------------------------------------------------------------------------
1508} // namespace chai3d
1509//------------------------------------------------------------------------------
1510
1511//------------------------------------------------------------------------------
1512#endif // CMathsH
1513//------------------------------------------------------------------------------
Implements a transformation matrix.
Definition CAudioBuffer.cpp:57
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:387
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:1069
int cNumDigits(int a_value)
This function computes the number of digits that compose a given integer.
Definition CMaths.h:736
double cRadToDeg(const double &a_angleRad)
This function converts an angle from radians to degrees.
Definition CMaths.h:716
cVector3d cAdd(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the addition of two vectors.
Definition CMaths.h:771
T cMin(const T &a_value1, const T &a_value2)
This function computes the minimum value between two values.
Definition CMaths.h:267
bool cZero(const double &a_value, const double &a_tolerance=C_TINY)
This function checks if a value is equal to or almost near zero.
Definition CMaths.h:155
double cDegToRad(const double &a_angleDeg)
This function converts an angle from degrees to radians.
Definition CMaths.h:696
cVector3d cNegate(const cVector3d &a_vector)
This function computes the negated vector.
Definition CMaths.h:860
cVector3d cCross(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cross product between two vectors.
Definition CMaths.h:944
double cDot(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the dot product between two vectors.
Definition CMaths.h:972
T cMax(const T &a_value1, const T &a_value2)
This function computes the maximum value between two values.
Definition CMaths.h:245
cVector3d cDiv(const double &a_value, const cVector3d &a_vector)
This function computes the division of a vector by a scalar.
Definition CMaths.h:915
double cCosDeg(const double &a_angleDeg)
Compute the cosine of an angle defined in degrees.
Definition CMaths.h:576
const double C_SMALL
Small value near zero.
Definition CConstants.h:103
const double C_RAD2DEG
Conversion from radians to degrees.
Definition CConstants.h:97
double cCbrt(const double &a_value)
This function computes the cubic root of a scalar.
Definition CMaths.h:518
T cClamp0(const T &a_value)
This function clamps a value to a value ranged between 0 and infinity.
Definition CMaths.h:411
cVector3d cMul(const double &a_value, const cVector3d &a_vector)
This function computes the multiplication of a vector by a scalar.
Definition CMaths.h:887
double cDistance(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the Euclidean distance between two points.
Definition CMaths.h:1016
double cModuloRange(double a_value, double a_min, double a_max)
This method computes the modulo of a double within a range.
Definition CMaths.h:540
double cAngle(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the angle in radians between two vectors.
Definition CMaths.h:1449
void cSwap(T &a_value1, T &a_value2)
This function swaps two elements.
Definition CMaths.h:334
const double C_TINY
Smallest value near zero for a double.
Definition CConstants.h:100
cVector3d cNormalize(const cVector3d &a_vector)
This function computes the normalized vector.
Definition CMaths.h:993
cVector3d cSub(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the subtraction of two vectors.
Definition CMaths.h:832
double cTanRad(const double &a_angleRad)
This function computes the tangent of an angle defined in radians.
Definition CMaths.h:676
cMatrix3d cTranspose(const cMatrix3d &a_matrix)
This function computes the transpose of a matrix.
Definition CMaths.h:1404
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:1247
double cCosRad(const double &a_angleRad)
This function computes the cosine of an angle defined in radians.
Definition CMaths.h:636
T cAbs(const T &a_value)
This function computes an absolute value.
Definition CMaths.h:198
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:1201
double cCosAngle(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the cosine of the angle between two vectors.
Definition CMaths.h:1487
double cSinRad(const double &a_angleRad)
This function computes the sine of an angle defined in radians.
Definition CMaths.h:656
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:1284
double cSqr(const double &a_value)
This function computes the square of a scalar.
Definition CMaths.h:479
cMatrix3d cIdentity3d(void)
This function return a 3x3 identity matrix.
Definition CMaths.h:1110
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:314
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:1320
cMatrix3d cInverse(const cMatrix3d &a_matrix)
This function computes the inverse of a matrix.
Definition CMaths.h:1426
double cSqrt(const double &a_value)
This function computes the square root of a scalar.
Definition CMaths.h:499
double cTanDeg(const double &a_angleDeg)
This function computes the tangent of an angle defined in degrees.
Definition CMaths.h:616
bool cEqual(const double &a_value1, const double &a_value2, const double &a_tolerance=C_TINY)
This function checks if a value is equal to a given value.
Definition CMaths.h:177
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:127
double cDistanceSq(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the squared distance between two points.
Definition CMaths.h:1038
double cSign(const T &a_value)
This function computes the sign of a value.
Definition CMaths.h:217
const double C_DEG2RAD
Conversion from degrees to radians.
Definition CConstants.h:94
double cSinDeg(const double &a_angleDeg)
This function computes the sine of an angle defined in degrees.
Definition CMaths.h:596
bool cCheckBit(const unsigned int &a_value, const unsigned int &a_bitPosition)
This function checks if a given bit is enabled.
Definition CMaths.h:93
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:290
cEulerOrder
Definition CMatrix3d.h:58
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:454
double cClamp01(const double &a_value)
This function clamps a value to a value ranged between 0.0 and 1.0.
Definition CMaths.h:431
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:363
This class implements a 3D matrix.
Definition CMatrix3d.h:98
void addr(const cMatrix3d &a_matrix, cMatrix3d &a_result) const
This method computes the addition of this matrix with another.
Definition CMatrix3d.h:785
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 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:1408
void setIntrinsicEulerRotationDeg(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:1615
bool setAxisAngleRotationRad(const cVector3d &a_axis, const double &a_angleRad)
This method builds a rotation matrix from an axis-angle representation.
Definition CMatrix3d.h:1282
void mulr(const double &a_scalar, cMatrix3d &a_result) const
This function computes the multiplication of this matrix by a scalar.
Definition CMatrix3d.h:916
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:1510
bool invertr(cMatrix3d &a_result) const
This method computes the inverse of this matrix.
Definition CMatrix3d.h:1199
void identity()
This method builds an identity matrix.
Definition CMatrix3d.h:325
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:1482
bool setAxisAngleRotationDeg(const cVector3d &a_axis, const double &a_angleDeg)
This method builds a rotation matrix from an axis-angle representation.
Definition CMatrix3d.h:1331
void transr(cMatrix3d &a_result) const
This method computes the transpose of this matrix.
Definition CMatrix3d.h:1116
This class implements a 3D vector.
Definition CVector3d.h:89
double distancesq(const cVector3d &a_vector) const
This method computes the squared value distance between two points.
Definition CVector3d.h:1152
void normalizer(cVector3d &a_result) const
This method normalizes this vector to length 1.
Definition CVector3d.h:1066
double dot(const cVector3d &a_vector) const
This method computes the dot product between this vector and another.
Definition CVector3d.h:978
double distance(const cVector3d &a_vector) const
This method computes the distance between two points.
Definition CVector3d.h:1126
void crossr(const cVector3d &a_vector, cVector3d &a_result) const
This method computes the cross product.
Definition CVector3d.h:955
double length() const
This method computes the Euclidean norm of this vector.
Definition CVector3d.h:995