Skip to content

Commit ba6219e

Browse files
committed
Centralise M_PI into hydroc/math_constants.h
M_PI was defined independently in multiple files. Consolidate into a single header that's shared.
1 parent 1b93e13 commit ba6219e

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

include/hydroc/helper.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
#include <Eigen/Dense> // Need for the container function
1212

1313
#include <hydroc/logging.h>
14-
15-
//// RADU - why not use constants from Chrono?
16-
#ifndef M_PI
17-
#define M_PI 3.14159265358979323846
18-
#endif
14+
#include <hydroc/math_constants.h>
1915

2016
/**@brief Base namespace for HydroChrono library
2117
*

include/hydroc/math_constants.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*********************************************************************
2+
* @file math_constants.h
3+
* @brief Project-wide mathematical constants.
4+
*
5+
* Include this header instead of defining M_PI locally or relying on
6+
* _USE_MATH_DEFINES.
7+
*********************************************************************/
8+
9+
#ifndef HYDROC_MATH_CONSTANTS_H
10+
#define HYDROC_MATH_CONSTANTS_H
11+
12+
#ifndef M_PI
13+
#define M_PI 3.14159265358979323846
14+
#endif
15+
16+
#ifndef M_PI_2
17+
#define M_PI_2 1.57079632679489661923
18+
#endif
19+
20+
#endif // HYDROC_MATH_CONSTANTS_H

src/gui/vsg_config.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// HydroChrono VSG Configuration Constants
22
#pragma once
33

4-
#include <cmath>
4+
#include <hydroc/math_constants.h>
55

6-
#ifndef M_PI
7-
#define M_PI 3.14159265358979323846
8-
#endif
6+
#include <cmath>
97

108
namespace hydroc {
119
namespace gui {

src/hydro/waves/wave_utilities.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
* @brief Helper routines shared by wave models.
44
*********************************************************************/
55

6-
#ifndef _USE_MATH_DEFINES
7-
#define _USE_MATH_DEFINES
8-
#endif
9-
106
#include "wave_utilities.h"
7+
#include <hydroc/math_constants.h>
118

129
#include <cmath>
1310
#include <algorithm>

0 commit comments

Comments
 (0)