Skip to content

Commit 03250da

Browse files
author
Francois Keith
committed
Use boost::pi rather than M_PI for portability.
1 parent e8bc298 commit 03250da

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

unitTesting/math/matrix-homogeneous.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
#include <boost/test/unit_test.hpp>
2121
#include <boost/test/floating_point_comparison.hpp>
2222
#include <boost/test/output_test_stream.hpp>
23+
#include <boost/math/constants/constants.hpp>
2324

2425
#include <jrl/mal/boost.hh>
2526
#include <sot/core/matrix-homogeneous.hh>
2627
#include "sot/core/matrix-twist.hh"
2728

2829
using boost::test_tools::output_test_stream;
30+
using boost::math::constants::pi;
2931

3032
namespace ml = maal::boost;
3133

@@ -69,18 +71,18 @@ BOOST_AUTO_TEST_CASE (product)
6971
tx = (10.*rand())/RAND_MAX - 5.;
7072
ty = (10.*rand())/RAND_MAX - 5.;
7173
tz = (10.*rand())/RAND_MAX - 5.;
72-
roll = (M_PI*rand())/RAND_MAX - .5*M_PI;
73-
pitch = (M_PI*rand())/RAND_MAX - .5*M_PI;
74-
yaw = (2*M_PI*rand())/RAND_MAX - M_PI;
74+
roll = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
75+
pitch = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
76+
yaw = (2*pi<double>()*rand())/RAND_MAX - pi<double>();
7577
MATRIX_HOMO_INIT(H1, tx, ty, tz, roll, pitch, yaw);
7678
ml::Matrix M1(H1);
7779
dynamicgraph::sot::MatrixHomogeneous H2;
7880
tx = (10.*rand())/RAND_MAX;
7981
ty = (10.*rand())/RAND_MAX - 5.;
8082
tz = (10.*rand())/RAND_MAX - 5.;
81-
roll = (M_PI*rand())/RAND_MAX - .5*M_PI;
82-
pitch = (M_PI*rand())/RAND_MAX - .5*M_PI;
83-
yaw = (2*M_PI*rand())/RAND_MAX - M_PI;
83+
roll = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
84+
pitch = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
85+
yaw = (2*pi<double>()*rand())/RAND_MAX - pi<double>();
8486
MATRIX_HOMO_INIT(H2, tx, ty, tz, roll, pitch, yaw);
8587
ml::Matrix M2(H2);
8688
dynamicgraph::sot::MatrixHomogeneous H3 = H1*H2;
@@ -99,17 +101,17 @@ BOOST_AUTO_TEST_CASE (inverse)
99101
tx = (10.*rand())/RAND_MAX - 5.;
100102
ty = (10.*rand())/RAND_MAX - 5.;
101103
tz = (10.*rand())/RAND_MAX - 5.;
102-
roll = (M_PI*rand())/RAND_MAX - .5*M_PI;
103-
pitch = (M_PI*rand())/RAND_MAX - .5*M_PI;
104-
yaw = (2*M_PI*rand())/RAND_MAX - M_PI;
104+
roll = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
105+
pitch = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
106+
yaw = (2*pi<double>()*rand())/RAND_MAX - pi<double>();
105107
MATRIX_HOMO_INIT(H1, tx, ty, tz, roll, pitch, yaw);
106108
dynamicgraph::sot::MatrixHomogeneous H2;
107109
tx = (10.*rand())/RAND_MAX;
108110
ty = (10.*rand())/RAND_MAX - 5.;
109111
tz = (10.*rand())/RAND_MAX - 5.;
110-
roll = (M_PI*rand())/RAND_MAX - .5*M_PI;
111-
pitch = (M_PI*rand())/RAND_MAX - .5*M_PI;
112-
yaw = (2*M_PI*rand())/RAND_MAX - M_PI;
112+
roll = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
113+
pitch = (pi<double>()*rand())/RAND_MAX - .5*pi<double>();
114+
yaw = (2*pi<double>()*rand())/RAND_MAX - pi<double>();
113115
MATRIX_HOMO_INIT(H2, tx, ty, tz, roll, pitch, yaw);
114116
dynamicgraph::sot::MatrixHomogeneous H3 = H1*H2;
115117
dynamicgraph::sot::MatrixHomogeneous invH1, invH2, invH3;

0 commit comments

Comments
 (0)