[ignition-math4] 01/03: Imported Upstream version 4.0.0
Jose Luis Rivero
jrivero-guest at moszumanska.debian.org
Tue Jan 2 23:44:04 UTC 2018
This is an automated email from the git hooks/post-receive script.
jrivero-guest pushed a commit to branch master
in repository ignition-math4.
commit 8a068575b4eed5b1cab7b254d9dcf0450bddc4e3
Author: Jose Luis Rivero <jrivero at osrfoundation.org>
Date: Wed Jan 3 00:43:04 2018 +0100
Imported Upstream version 4.0.0
---
.hg_archival.txt | 8 +-
CMakeLists.txt | 9 +-
Changelog.md | 63 +++++++-
Migration.md | 20 +++
bitbucket-pipelines.yml | 13 +-
configure.bat | 3 +
include/ignition/math/Angle.hh | 4 +
include/ignition/math/Box.hh | 4 +
include/ignition/math/Color.hh | 4 +
include/ignition/math/Filter.hh | 4 +
include/ignition/math/Frustum.hh | 4 +
include/ignition/math/Helpers.hh | 161 ++++++++-----------
include/ignition/math/Inertial.hh | 4 +
include/ignition/math/Kmeans.hh | 4 +
include/ignition/math/Line2.hh | 4 +
include/ignition/math/Line3.hh | 4 +
include/ignition/math/MassMatrix3.hh | 4 +
include/ignition/math/Matrix3.hh | 4 +
include/ignition/math/Matrix4.hh | 39 ++++-
include/ignition/math/OrientedBox.hh | 4 +
include/ignition/math/PID.hh | 4 +
include/ignition/math/Plane.hh | 4 +
include/ignition/math/Pose3.hh | 4 +
include/ignition/math/Quaternion.hh | 4 +
include/ignition/math/Rand.hh | 4 +
include/ignition/math/RotationSpline.hh | 4 +
include/ignition/math/SemanticVersion.hh | 4 +
include/ignition/math/SignalStats.hh | 4 +
include/ignition/math/SphericalCoordinates.hh | 4 +
include/ignition/math/Spline.hh | 4 +
include/ignition/math/Temperature.hh | 4 +
include/ignition/math/Triangle.hh | 4 +
include/ignition/math/Triangle3.hh | 4 +
include/ignition/math/Vector2.hh | 4 +
include/ignition/math/Vector3.hh | 4 +
include/ignition/math/Vector3Stats.hh | 4 +
include/ignition/math/Vector4.hh | 6 +-
include/ignition/math/config.hh.in | 2 +
include/ignition/math/graph/Edge.hh | 4 +
include/ignition/math/graph/Graph.hh | 4 +
include/ignition/math/graph/GraphAlgorithms.hh | 4 +
include/ignition/math/graph/Vertex.hh | 4 +
src/Angle.cc | 15 +-
src/BoxPrivate.hh | 4 +
src/Frustum.cc | 96 +++++++++++-
src/FrustumPrivate.hh | 12 +-
src/Frustum_TEST.cc | 180 ++++++++++++++++++++++
src/Helpers.cc | 55 ++++---
src/Helpers_TEST.cc | 16 +-
src/KmeansPrivate.hh | 4 +
src/Matrix4_TEST.cc | 6 +-
src/RotationSplinePrivate.hh | 4 +
src/SemanticVersion.cc | 3 +
src/SignalStatsPrivate.hh | 4 +
src/SplinePrivate.cc | 7 +-
src/SplinePrivate.hh | 4 +
src/Vector3StatsPrivate.hh | 4 +
test/CMakeLists.txt | 1 +
test/integration/CMakeLists.txt | 8 +
test/integration/all_symbols_have_version.bash.in | 27 ++++
tools/code_check.sh | 8 +-
tools/cpplint_to_cppcheckxml.py | 54 +++++++
62 files changed, 792 insertions(+), 172 deletions(-)
diff --git a/.hg_archival.txt b/.hg_archival.txt
index 77fd3c2..d6cf895 100644
--- a/.hg_archival.txt
+++ b/.hg_archival.txt
@@ -1,6 +1,6 @@
repo: e97318167882c5edd21067dd86576efadebd68ed
-node: 3e9ea893e1e4b477e8eb77e40d7a020f3f1b5527
+node: 054f8a99081fb54f7c28bad2ec6cfa8e2edb94a5
branch: ign-math4
-latesttag: ignition-math4_4.0.0~pre1
-latesttagdistance: 3
-changessincelatesttag: 59
+latesttag: ignition-math4_4.0.0~pre4
+latesttagdistance: 5
+changessincelatesttag: 13
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb99ea8..f209add 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,15 +1,20 @@
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
#============================================================================
+# Initialize the project
+#============================================================================
+project(ignition-math4 VERSION 4.0.0)
+
+#============================================================================
# Find ignition-cmake
#============================================================================
# If you get an error at this line, you need to install ignition-cmake
find_package(ignition-cmake0 REQUIRED)
#============================================================================
-# Set up the project
+# Configure the project
#============================================================================
-ign_configure_project(math 4.0.0 VERSION_SUFFIX pre2)
+ign_configure_project()
#============================================================================
diff --git a/Changelog.md b/Changelog.md
index f75a6b3..511f408 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,20 @@
### Ignition Math 4.x.x
+
+
+### Ignition Math 4.0.0 (2017-12-26)
+
+1. Use std::stoi and std::stod in math::parse* functions to reduce code
+ * [Pull request 224](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/224)
+ * [Issue 50](https://bitbucket.org/ignitionrobotics/ign-math/issues/50)
+
+1. Fixing const-correctness for operator* of Pose3
+ * [Pull request 205](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/205)
+
+1. Deprecate Matrix4::Translate and replace by Matrix4::SetTranslation
+ * [Pull request 222](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/222)
+
1. Use ignition-cmake to simplify build scripts
* [Pull request 200](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/200)
@@ -11,10 +25,6 @@
1. Switch to C++14
* [Pull request 180](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/180)
-1. Improved the performance of `graph::InDegree()` and `graph::IncidentsTo()`.
- * [Pull request 188](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/188)
- * [Issue 79](https://bitbucket.org/ignitionrobotics/ign-math/issues/79)
-
1. Removed the box 'extent' field. The default constructor now sets a box's
corners to extrema in order to indicate an uninitialized box.
* [Pull request 172](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/172)
@@ -32,15 +42,44 @@
* [Pull request 177](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/177)
1. Added a function to calculate connected components in undirected
graphs:
- * [Pull request 190](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/190)
+ * [Pull request 190](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/190)
+ 1. Improved the performance of `graph::InDegree()` and `graph::IncidentsTo()`.
+ * [Pull request 188](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/188)
+ * [Issue 79](https://bitbucket.org/ignitionrobotics/ign-math/issues/79)
+
+1. Added Inline Versioned Namespace
+ * [Pull request 216](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/216/)
## Ignition Math 3.x
### Ignition Math 3.x.x
+
+
+### Ignition Math 3.3.0 (2017-11-27)
+
+1. Fixed frustum falsely saying it contained AABB in some cases
+ * [Pull request 193](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/193)
+ * [Issue 78](https://bitbucket.org/ignitionrobotics/ign-math/issues/78)
+
1. Create consistent bracket operators across all Vector# types
* [Pull request 181](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/181)
+1. Change name to the generic BUILDING_DLL macro to avoid conflicts
+ * [Pull request 173](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/173)
+
+1. Fix some compiler warnings
+ * [Pull request 196](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/196)
+
+1. Suppress gtest warnings
+ * [Pull request 199](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/199)
+
+1. Move private headers to src folder
+ * [Pull request 198](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/198)
+
+1. Update configure.bat
+ * [Pull request 206](https://bitbucket.org/ignitionrobotics/ign-math/pull-requests/206)
+
### Ignition Math 3.2.0 (2017-05-15)
1. Construct on first use in Rand class
@@ -85,13 +124,23 @@
## Ignition Math 2.x
-### Ignition Math 2.8
-### Ignition Math 2.8.0
+
+## Ignition Math 2.9 (2017-11-22)
+
+1. Fixed frustum falsely saying it contained AABB in some cases
+ * [Pull request 193](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/193)
1. Added Color
* [Pull request 150](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/150)
+1. Backport updated configure.bat to ign-math2 and fix cppcheck warnings
+ * [Pull request 207](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/207)
+
+### Ignition Math 2.8
+
+### Ignition Math 2.8.0
+
1. Added OrientedBox
* [Pull request 146](https://bitbucket.org/ignitionrobotics/ign-math/pull-request/146)
diff --git a/Migration.md b/Migration.md
index 080663f..66c8f15 100644
--- a/Migration.md
+++ b/Migration.md
@@ -19,9 +19,29 @@ release will remove the deprecated code.
+ Boxes generated with the default constructor do not intersect any other
boxes or contain any points (previously they contained the origin).
+1. **Helpers.hh**
+ + parseInt and parseFloat functions now use std::stoi and std::stod,
+ so parsing an alphanumeric string that starts with numbers
+ no longer returns a NaN, but instead the beginning of the string
+ is parsed (e.g. ("23ab67" -> 23) now, but ("ab23ab67" -> NaN) still).
+
1. **SemanticVersion.hh**
+ The SemanticVersion(const std::string &) constructor is now explicit.
+1. **All Headers**
+ + All headers now have an inline versioned namespace. Code should be
+ unchanged except all forward declarations of math types must be replaced
+ with an include of the header for that type.
+
+### Deprecations
+
+1. **Matrix4.hh**
+ + ***Deprecation:*** public: void Translate(const Vector3<T> &_t)
+ + ***Replacement:*** public: void SetTranslation(const Vector3<T> &_t)
+
+ + ***Deprecation:*** public: void Translate(T _x, T _y, T _z)
+ + ***Replacement:*** public: void SetTranslation(T _x, T _y, T _z)
+
## Ignition Math 2.X to 3.X
### Modifications
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
index 0979a22..af32f20 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -5,9 +5,11 @@ pipelines:
- step:
script:
- apt-get update
- - apt-get -y install cmake build-essential lcov curl mercurial
+ - apt-get -y install cmake build-essential lcov curl mercurial cppcheck
- gcc -v
- g++ -v
+ # Static checking before building - fail fast
+ - sh tools/code_check.sh
# Ignition cmake
- echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-prerelease xenial main" > /etc/apt/sources.list.d/gazebo-prerelease.list
- apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743
@@ -22,3 +24,12 @@ pipelines:
- make test
- make coverage
- bash <(curl -s https://codecov.io/bash)
+ - make install
+ # Examples
+ - cd ..
+ - cd examples
+ - mkdir build
+ - cd build
+ - cmake ..
+ - make
+ - ./graph_example
diff --git a/configure.bat b/configure.bat
index 625cc06..d083d79 100644
--- a/configure.bat
+++ b/configure.bat
@@ -10,6 +10,9 @@ call %win_lib% :install_ign_project ign-cmake default
@if not "%1"=="" set build_type=%1
@echo Configuring for build type %build_type%
+:: Use legacy install location if unset
+ at if "%WORKSPACE_INSTALL_DIR%"=="" set WORKSPACE_INSTALL_DIR="install\%build_type%"
+
:: Go to the directory that this configure.bat file exists in
cd /d %~dp0
diff --git a/include/ignition/math/Angle.hh b/include/ignition/math/Angle.hh
index 3a8bfb2..75d80fd 100644
--- a/include/ignition/math/Angle.hh
+++ b/include/ignition/math/Angle.hh
@@ -19,6 +19,7 @@
#include <iostream>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
/// \brief Macro that converts radians to degrees
/// \param[in] radians
@@ -39,6 +40,8 @@ namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Angle Angle.hh ignition/math/Angle.hh
/// \brief An angle and related functions.
class IGNITION_MATH_VISIBLE Angle
@@ -197,6 +200,7 @@ namespace ignition
/// The angle in radians
private: double value;
};
+ }
}
}
diff --git a/include/ignition/math/Box.hh b/include/ignition/math/Box.hh
index 327c31a..3d89d9a 100644
--- a/include/ignition/math/Box.hh
+++ b/include/ignition/math/Box.hh
@@ -22,11 +22,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Line3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declaration of private data
class BoxPrivate;
@@ -231,6 +234,7 @@ namespace ignition
/// \brief Private data pointer
private: BoxPrivate *dataPtr;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Color.hh b/include/ignition/math/Color.hh
index cb07d7a..1d74980 100644
--- a/include/ignition/math/Color.hh
+++ b/include/ignition/math/Color.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Color Color.hh ignition/math/Color.hh
/// \brief Defines a color using a red (R), green (G), blue (B), and alpha
/// (A) component. Each color component is in the range [0..1].
@@ -313,6 +316,7 @@ namespace ignition
/// \brief Alpha value
private: float a = 1;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Filter.hh b/include/ignition/math/Filter.hh
index dfe9ab3..f51418a 100644
--- a/include/ignition/math/Filter.hh
+++ b/include/ignition/math/Filter.hh
@@ -20,11 +20,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Quaternion.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Filter Filter.hh ignition/math/Filter.hh
/// \brief Filter base class
template <class T>
@@ -241,6 +244,7 @@ namespace ignition
this->Set(math::Vector3d(0, 0, 0));
}
};
+ }
}
}
diff --git a/include/ignition/math/Frustum.hh b/include/ignition/math/Frustum.hh
index 04aa88b..d7f7f29 100644
--- a/include/ignition/math/Frustum.hh
+++ b/include/ignition/math/Frustum.hh
@@ -20,11 +20,14 @@
#include <ignition/math/Plane.hh>
#include <ignition/math/Angle.hh>
#include <ignition/math/Pose3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declaration of private data
class FrustumPrivate;
@@ -176,6 +179,7 @@ namespace ignition
/// \brief Private data pointer
private: FrustumPrivate *dataPtr;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Helpers.hh b/include/ignition/math/Helpers.hh
index fb4eecd..879d617 100644
--- a/include/ignition/math/Helpers.hh
+++ b/include/ignition/math/Helpers.hh
@@ -26,6 +26,7 @@
#include <tuple>
#include <cstdint>
+#include <ignition/math/config.hh>
#include "ignition/math/Export.hh"
/// \brief Double maximum value. This value will be similar to 1.79769e+308
@@ -209,6 +210,8 @@ namespace ignition
/// \brief Math classes and function useful in robot applications.
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief size_t type with a value of 0
static const size_t IGN_ZERO_SIZE_T = 0u;
@@ -351,38 +354,38 @@ namespace ignition
static const int NAN_I = std::numeric_limits<int>::quiet_NaN();
// variables created to deprecate macros in this file
- static const double IGN_DEPRECATED(2) DPRCT_MAX_D = MAX_D;
- static const double IGN_DEPRECATED(2) DPRCT_MIN_D = MIN_D;
- static const double IGN_DEPRECATED(2) DPRCT_LOW_D = LOW_D;
- static const double IGN_DEPRECATED(2) DPRCT_INF_D = INF_D;
- static const float IGN_DEPRECATED(2) DPRCT_MAX_F = MAX_F;
- static const float IGN_DEPRECATED(2) DPRCT_MIN_F = MIN_F;
- static const float IGN_DEPRECATED(2) DPRCT_LOW_F = LOW_F;
- static const float IGN_DEPRECATED(2) DPRCT_INF_F = INF_F;
- static const uint16_t IGN_DEPRECATED(2) DPRCT_MAX_UI16 = MAX_UI16;
- static const uint16_t IGN_DEPRECATED(2) DPRCT_MIN_UI16 = MIN_UI16;
- static const uint16_t IGN_DEPRECATED(2) DPRCT_LOW_UI16 = LOW_UI16;
- static const uint16_t IGN_DEPRECATED(2) DPRCT_INF_UI16 = INF_UI16;
- static const int16_t IGN_DEPRECATED(2) DPRCT_MAX_I16 = MAX_I16;
- static const int16_t IGN_DEPRECATED(2) DPRCT_MIN_I16 = MIN_I16;
- static const int16_t IGN_DEPRECATED(2) DPRCT_LOW_I16 = LOW_I16;
- static const int16_t IGN_DEPRECATED(2) DPRCT_INF_I16 = INF_I16;
- static const uint32_t IGN_DEPRECATED(2) DPRCT_MAX_UI32 = MAX_UI32;
- static const uint32_t IGN_DEPRECATED(2) DPRCT_MIN_UI32 = MIN_UI32;
- static const uint32_t IGN_DEPRECATED(2) DPRCT_LOW_UI32 = LOW_UI32;
- static const uint32_t IGN_DEPRECATED(2) DPRCT_INF_UI32 = INF_UI32;
- static const int32_t IGN_DEPRECATED(2) DPRCT_MAX_I32 = MAX_I32;
- static const int32_t IGN_DEPRECATED(2) DPRCT_MIN_I32 = MIN_I32;
- static const int32_t IGN_DEPRECATED(2) DPRCT_LOW_I32 = LOW_I32;
- static const int32_t IGN_DEPRECATED(2) DPRCT_INF_I32 = INF_I32;
- static const uint64_t IGN_DEPRECATED(2) DPRCT_MAX_UI64 = MAX_UI64;
- static const uint64_t IGN_DEPRECATED(2) DPRCT_MIN_UI64 = MIN_UI64;
- static const uint64_t IGN_DEPRECATED(2) DPRCT_LOW_UI64 = LOW_UI64;
- static const uint64_t IGN_DEPRECATED(2) DPRCT_INF_UI64 = INF_UI64;
- static const int64_t IGN_DEPRECATED(2) DPRCT_MAX_I64 = MAX_I64;
- static const int64_t IGN_DEPRECATED(2) DPRCT_MIN_I64 = MIN_I64;
- static const int64_t IGN_DEPRECATED(2) DPRCT_LOW_I64 = LOW_I64;
- static const int64_t IGN_DEPRECATED(2) DPRCT_INF_I64 = INF_I64;
+ static const double IGN_DEPRECATED(3) DPRCT_MAX_D = MAX_D;
+ static const double IGN_DEPRECATED(3) DPRCT_MIN_D = MIN_D;
+ static const double IGN_DEPRECATED(3) DPRCT_LOW_D = LOW_D;
+ static const double IGN_DEPRECATED(3) DPRCT_INF_D = INF_D;
+ static const float IGN_DEPRECATED(3) DPRCT_MAX_F = MAX_F;
+ static const float IGN_DEPRECATED(3) DPRCT_MIN_F = MIN_F;
+ static const float IGN_DEPRECATED(3) DPRCT_LOW_F = LOW_F;
+ static const float IGN_DEPRECATED(3) DPRCT_INF_F = INF_F;
+ static const uint16_t IGN_DEPRECATED(3) DPRCT_MAX_UI16 = MAX_UI16;
+ static const uint16_t IGN_DEPRECATED(3) DPRCT_MIN_UI16 = MIN_UI16;
+ static const uint16_t IGN_DEPRECATED(3) DPRCT_LOW_UI16 = LOW_UI16;
+ static const uint16_t IGN_DEPRECATED(3) DPRCT_INF_UI16 = INF_UI16;
+ static const int16_t IGN_DEPRECATED(3) DPRCT_MAX_I16 = MAX_I16;
+ static const int16_t IGN_DEPRECATED(3) DPRCT_MIN_I16 = MIN_I16;
+ static const int16_t IGN_DEPRECATED(3) DPRCT_LOW_I16 = LOW_I16;
+ static const int16_t IGN_DEPRECATED(3) DPRCT_INF_I16 = INF_I16;
+ static const uint32_t IGN_DEPRECATED(3) DPRCT_MAX_UI32 = MAX_UI32;
+ static const uint32_t IGN_DEPRECATED(3) DPRCT_MIN_UI32 = MIN_UI32;
+ static const uint32_t IGN_DEPRECATED(3) DPRCT_LOW_UI32 = LOW_UI32;
+ static const uint32_t IGN_DEPRECATED(3) DPRCT_INF_UI32 = INF_UI32;
+ static const int32_t IGN_DEPRECATED(3) DPRCT_MAX_I32 = MAX_I32;
+ static const int32_t IGN_DEPRECATED(3) DPRCT_MIN_I32 = MIN_I32;
+ static const int32_t IGN_DEPRECATED(3) DPRCT_LOW_I32 = LOW_I32;
+ static const int32_t IGN_DEPRECATED(3) DPRCT_INF_I32 = INF_I32;
+ static const uint64_t IGN_DEPRECATED(3) DPRCT_MAX_UI64 = MAX_UI64;
+ static const uint64_t IGN_DEPRECATED(3) DPRCT_MIN_UI64 = MIN_UI64;
+ static const uint64_t IGN_DEPRECATED(3) DPRCT_LOW_UI64 = LOW_UI64;
+ static const uint64_t IGN_DEPRECATED(3) DPRCT_INF_UI64 = INF_UI64;
+ static const int64_t IGN_DEPRECATED(3) DPRCT_MAX_I64 = MAX_I64;
+ static const int64_t IGN_DEPRECATED(3) DPRCT_MIN_I64 = MIN_I64;
+ static const int64_t IGN_DEPRECATED(3) DPRCT_LOW_I64 = LOW_I64;
+ static const int64_t IGN_DEPRECATED(3) DPRCT_INF_I64 = INF_I64;
/// \brief Simple clamping function
/// \param[in] _v value
@@ -639,31 +642,27 @@ namespace ignition
/// \return an integer, 0 or 0 and a message in the error stream
inline int parseInt(const std::string &_input)
{
- const char *p = _input.c_str();
- if (!*p || *p == '?')
+ // Return NAN_I if it is empty
+ if (_input.empty())
+ {
return NAN_I;
-
- int s = 1;
- while (*p == ' ')
- p++;
-
- if (*p == '-')
+ }
+ // Return 0 if it is all spaces
+ else if (_input.find_first_not_of(' ') == std::string::npos)
{
- s = -1;
- p++;
+ return 0;
}
- int acc = 0;
- while (*p >= '0' && *p <= '9')
- acc = acc * 10 + *p++ - '0';
-
- if (*p)
+ // Otherwise try standard library
+ try
+ {
+ return std::stoi(_input);
+ }
+ // if that fails, return NAN_I
+ catch(...)
{
- std::cerr << "Invalid int numeric format[" << _input << "]\n";
return NAN_I;
}
-
- return s * acc;
}
/// \brief parse string into float
@@ -672,66 +671,35 @@ namespace ignition
/// error stream
inline double parseFloat(const std::string &_input)
{
- const char *p = _input.c_str();
- if (!*p || *p == '?')
- return NAN_D;
- int s = 1;
- while (*p == ' ')
- p++;
-
- if (*p == '-')
+ // Return NAN_D if it is empty
+ if (_input.empty())
{
- s = -1;
- p++;
+ return NAN_D;
}
-
- double acc = 0;
- while (*p >= '0' && *p <= '9')
- acc = acc * 10 + *p++ - '0';
-
- if (*p == '.')
+ // Return 0 if it is all spaces
+ else if (_input.find_first_not_of(' ') == std::string::npos)
{
- double k = 0.1;
- p++;
- while (*p >= '0' && *p <= '9')
- {
- acc += (*p++ - '0') * k;
- k *= 0.1;
- }
+ return 0;
}
- if (*p == 'e')
+
+ // Otherwise try standard library
+ try
{
- int es = 1;
- int f = 0;
- p++;
- if (*p == '-')
- {
- es = -1;
- p++;
- }
- else if (*p == '+')
- {
- es = 1;
- p++;
- }
- while (*p >= '0' && *p <= '9')
- f = f * 10 + *p++ - '0';
-
- acc *= pow(10, f*es);
+ return std::stod(_input);
}
-
- if (*p)
+ // if that fails, return NAN_D
+ catch(...)
{
- std::cerr << "Invalid double numeric format[" << _input << "]\n";
return NAN_D;
}
- return s * acc;
}
// Degrade precision on Windows, which cannot handle 'long double'
// values properly. See the implementation of Unpair.
-#ifdef _MSC_VER
+ // 32 bit ARM processors also define 'long double' to be the same
+ // size as 'double', and must also be degraded
+#if defined _MSC_VER || defined __arm__
using PairInput = uint16_t;
using PairOutput = uint32_t;
#else
@@ -764,6 +732,7 @@ namespace ignition
/// \sa Pair
std::tuple<PairInput, PairInput> IGNITION_MATH_VISIBLE Unpair(
const PairOutput _key);
+ }
}
}
diff --git a/include/ignition/math/Inertial.hh b/include/ignition/math/Inertial.hh
index d2ee498..063b79c 100644
--- a/include/ignition/math/Inertial.hh
+++ b/include/ignition/math/Inertial.hh
@@ -17,6 +17,7 @@
#ifndef IGNITION_MATH_INERTIAL_HH_
#define IGNITION_MATH_INERTIAL_HH_
+#include <ignition/math/config.hh>
#include "ignition/math/MassMatrix3.hh"
#include "ignition/math/Pose3.hh"
@@ -24,6 +25,8 @@ namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Inertial Inertial.hh ignition/math/Inertial.hh
/// \brief A class for inertial information about a rigid body
/// consisting of the scalar mass, a 3x3 symmetric moment
@@ -239,6 +242,7 @@ namespace ignition
typedef Inertial<double> Inertiald;
typedef Inertial<float> Inertialf;
+ }
}
}
#endif
diff --git a/include/ignition/math/Kmeans.hh b/include/ignition/math/Kmeans.hh
index 17ff01c..5a47c9e 100644
--- a/include/ignition/math/Kmeans.hh
+++ b/include/ignition/math/Kmeans.hh
@@ -20,11 +20,14 @@
#include <vector>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declare private data
class KmeansPrivate;
@@ -79,6 +82,7 @@ namespace ignition
/// \brief Private data pointer
private: KmeansPrivate *dataPtr;
};
+ }
}
}
diff --git a/include/ignition/math/Line2.hh b/include/ignition/math/Line2.hh
index 2ef886b..54693dc 100644
--- a/include/ignition/math/Line2.hh
+++ b/include/ignition/math/Line2.hh
@@ -19,11 +19,14 @@
#include <algorithm>
#include <ignition/math/Vector2.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Line2 Line2.hh ignition/math/Line2.hh
/// \brief A two dimensional line segment. The line is defined by a
/// start and end point.
@@ -310,6 +313,7 @@ namespace ignition
typedef Line2<int> Line2i;
typedef Line2<double> Line2d;
typedef Line2<float> Line2f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Line3.hh b/include/ignition/math/Line3.hh
index 14b2bd8..c55753c 100644
--- a/include/ignition/math/Line3.hh
+++ b/include/ignition/math/Line3.hh
@@ -19,11 +19,14 @@
#include <algorithm>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Line3 Line3.hh ignition/math/Line3.hh
/// \brief A three dimensional line segment. The line is defined by a
/// start and end point.
@@ -383,6 +386,7 @@ namespace ignition
typedef Line3<int> Line3i;
typedef Line3<double> Line3d;
typedef Line3<float> Line3f;
+ }
}
}
#endif
diff --git a/include/ignition/math/MassMatrix3.hh b/include/ignition/math/MassMatrix3.hh
index 7b7b5f0..951af81 100644
--- a/include/ignition/math/MassMatrix3.hh
+++ b/include/ignition/math/MassMatrix3.hh
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
+#include <ignition/math/config.hh>
#include "ignition/math/Helpers.hh"
#include "ignition/math/Quaternion.hh"
#include "ignition/math/Vector2.hh"
@@ -31,6 +32,8 @@ namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class MassMatrix3 MassMatrix3.hh ignition/math/MassMatrix3.hh
/// \brief A class for inertial information about a rigid body
/// consisting of the scalar mass and a 3x3 symmetric moment
@@ -901,6 +904,7 @@ namespace ignition
typedef MassMatrix3<double> MassMatrix3d;
typedef MassMatrix3<float> MassMatrix3f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Matrix3.hh b/include/ignition/math/Matrix3.hh
index 7fd2704..057bfda 100644
--- a/include/ignition/math/Matrix3.hh
+++ b/include/ignition/math/Matrix3.hh
@@ -22,11 +22,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Quaternion.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
template <typename T> class Quaternion;
/// \class Matrix3 Matrix3.hh ignition/math/Matrix3.hh
@@ -538,6 +541,7 @@ namespace ignition
typedef Matrix3<int> Matrix3i;
typedef Matrix3<double> Matrix3d;
typedef Matrix3<float> Matrix3f;
+ }
}
}
diff --git a/include/ignition/math/Matrix4.hh b/include/ignition/math/Matrix4.hh
index 2784954..8eba75a 100644
--- a/include/ignition/math/Matrix4.hh
+++ b/include/ignition/math/Matrix4.hh
@@ -22,11 +22,14 @@
#include <ignition/math/Matrix3.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Pose3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Matrix4 Matrix4.hh ignition/math/Matrix4.hh
/// \brief A 4x4 matrix class
template<typename T>
@@ -107,7 +110,7 @@ namespace ignition
/// \param[in] _pose Pose.
public: explicit Matrix4(const Pose3<T> &_pose) : Matrix4(_pose.Rot())
{
- this->Translate(_pose.Pos());
+ this->SetTranslation(_pose.Pos());
}
/// \brief Destructor
@@ -181,7 +184,17 @@ namespace ignition
/// \brief Set the translational values [ (0, 3) (1, 3) (2, 3) ]
/// \param[in] _t Values to set
- public: void Translate(const Vector3<T> &_t)
+ /// \deprecated Use SetTranslation instead
+ public: void
+ IGN_DEPRECATED(4)
+ Translate(const Vector3<T> &_t)
+ {
+ this->SetTranslation(_t);
+ }
+
+ /// \brief Set the translational values [ (0, 3) (1, 3) (2, 3) ]
+ /// \param[in] _t Values to set
+ public: void SetTranslation(const Vector3<T> &_t)
{
this->data[0][3] = _t.X();
this->data[1][3] = _t.Y();
@@ -192,7 +205,19 @@ namespace ignition
/// \param[in] _x X translation value.
/// \param[in] _y Y translation value.
/// \param[in] _z Z translation value.
- public: void Translate(T _x, T _y, T _z)
+ /// \deprecated Use SetTranslation instead
+ public: void
+ IGN_DEPRECATED(4)
+ Translate(T _x, T _y, T _z)
+ {
+ this->SetTranslation(_x, _y, _z);
+ }
+
+ /// \brief Set the translational values [ (0, 3) (1, 3) (2, 3) ]
+ /// \param[in] _x X translation value.
+ /// \param[in] _y Y translation value.
+ /// \param[in] _z Z translation value.
+ public: void SetTranslation(T _x, T _y, T _z)
{
this->data[0][3] = _x;
this->data[1][3] = _y;
@@ -379,10 +404,9 @@ namespace ignition
/// Vector3<T> is returned if this matrix is not affine.
/// \deprecated Use bool TransformAffine(const Vector3<T> &_v,
/// Vector3<T> &_result) const;
- public: Vector3<T> TransformAffine(const Vector3<T> &_v) const
-#ifndef _WIN32
- IGN_DEPRECATED(3.0)
-#endif
+ public: Vector3<T>
+ IGN_DEPRECATED(3.0)
+ TransformAffine(const Vector3<T> &_v) const
{
if (this->IsAffine())
{
@@ -885,6 +909,7 @@ namespace ignition
typedef Matrix4<int> Matrix4i;
typedef Matrix4<double> Matrix4d;
typedef Matrix4<float> Matrix4f;
+ }
}
}
#endif
diff --git a/include/ignition/math/OrientedBox.hh b/include/ignition/math/OrientedBox.hh
index 083eb41..8c59789 100644
--- a/include/ignition/math/OrientedBox.hh
+++ b/include/ignition/math/OrientedBox.hh
@@ -22,11 +22,14 @@
#include <ignition/math/Matrix4.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Mathematical representation of a box which can be arbitrarily
/// positioned and rotated.
template<typename T>
@@ -182,6 +185,7 @@ namespace ignition
typedef OrientedBox<int> OrientedBoxi;
typedef OrientedBox<double> OrientedBoxd;
typedef OrientedBox<float> OrientedBoxf;
+ }
}
}
#endif
diff --git a/include/ignition/math/PID.hh b/include/ignition/math/PID.hh
index 0587a62..6385605 100644
--- a/include/ignition/math/PID.hh
+++ b/include/ignition/math/PID.hh
@@ -19,11 +19,14 @@
#include <chrono>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class PID PID.hh ignition/math/PID.hh
/// \brief Generic PID controller class.
/// Generic proportional-integral-derivative controller class that
@@ -223,6 +226,7 @@ namespace ignition
/// \brief Command offset.
private: double cmdOffset = 0.0;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Plane.hh b/include/ignition/math/Plane.hh
index 27b8f59..042f527 100644
--- a/include/ignition/math/Plane.hh
+++ b/include/ignition/math/Plane.hh
@@ -20,11 +20,14 @@
#include <ignition/math/Box.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Vector2.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Plane Plane.hh ignition/math/Plane.hh
/// \brief A plane and related functions.
template<typename T>
@@ -225,6 +228,7 @@ namespace ignition
typedef Plane<int> Planei;
typedef Plane<double> Planed;
typedef Plane<float> Planef;
+ }
}
}
diff --git a/include/ignition/math/Pose3.hh b/include/ignition/math/Pose3.hh
index 31981ff..cb71f06 100644
--- a/include/ignition/math/Pose3.hh
+++ b/include/ignition/math/Pose3.hh
@@ -19,11 +19,14 @@
#include <ignition/math/Quaternion.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Pose3 Pose3.hh ignition/math/Pose3.hh
/// \brief Encapsulates a position and rotation in three space
template<typename T>
@@ -406,6 +409,7 @@ namespace ignition
typedef Pose3<int> Pose3i;
typedef Pose3<double> Pose3d;
typedef Pose3<float> Pose3f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Quaternion.hh b/include/ignition/math/Quaternion.hh
index a810561..a906e14 100644
--- a/include/ignition/math/Quaternion.hh
+++ b/include/ignition/math/Quaternion.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Angle.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Matrix3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
template <typename T> class Matrix3;
/// \class Quaternion Quaternion.hh ignition/math/Quaternion.hh
@@ -1078,6 +1081,7 @@ namespace ignition
typedef Quaternion<double> Quaterniond;
typedef Quaternion<float> Quaternionf;
typedef Quaternion<int> Quaternioni;
+ }
}
}
#endif
diff --git a/include/ignition/math/Rand.hh b/include/ignition/math/Rand.hh
index 6695d9d..79af41f 100644
--- a/include/ignition/math/Rand.hh
+++ b/include/ignition/math/Rand.hh
@@ -21,11 +21,14 @@
#include <cmath>
#include <cstdint>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \def GeneratorType
/// \brief std::mt19937
typedef std::mt19937 GeneratorType;
@@ -81,6 +84,7 @@ namespace ignition
/// static member if it hasn't been created yet).
private: static GeneratorType &RandGenerator();
};
+ }
}
}
#endif
diff --git a/include/ignition/math/RotationSpline.hh b/include/ignition/math/RotationSpline.hh
index 0f3a986..4e6f7cf 100644
--- a/include/ignition/math/RotationSpline.hh
+++ b/include/ignition/math/RotationSpline.hh
@@ -18,11 +18,14 @@
#define IGNITION_MATH_ROTATIONSPLINE_HH_
#include <ignition/math/Quaternion.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declare private data
class RotationSplinePrivate;
@@ -115,6 +118,7 @@ namespace ignition
/// \brief Private data pointer
private: RotationSplinePrivate *dataPtr;
};
+ }
}
}
diff --git a/include/ignition/math/SemanticVersion.hh b/include/ignition/math/SemanticVersion.hh
index 8f28723..fbddd19 100644
--- a/include/ignition/math/SemanticVersion.hh
+++ b/include/ignition/math/SemanticVersion.hh
@@ -21,11 +21,14 @@
#include <memory>
#include <string>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declare private data class
class SemanticVersionPrivate;
@@ -154,6 +157,7 @@ namespace ignition
#pragma warning(pop)
#endif
};
+ }
}
}
#endif
diff --git a/include/ignition/math/SignalStats.hh b/include/ignition/math/SignalStats.hh
index eb5350d..bdf02be 100644
--- a/include/ignition/math/SignalStats.hh
+++ b/include/ignition/math/SignalStats.hh
@@ -21,11 +21,14 @@
#include <memory>
#include <string>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Forward declare private data class.
class SignalStatisticPrivate;
@@ -251,6 +254,7 @@ namespace ignition
#pragma warning(pop)
#endif
};
+ }
/// \}
}
}
diff --git a/include/ignition/math/SphericalCoordinates.hh b/include/ignition/math/SphericalCoordinates.hh
index d138be5..3b040cd 100644
--- a/include/ignition/math/SphericalCoordinates.hh
+++ b/include/ignition/math/SphericalCoordinates.hh
@@ -23,11 +23,14 @@
#include <ignition/math/Angle.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
class SphericalCoordinatesPrivate;
/// \class SphericalCoordinates SphericalCoordinates.hh commmon/common.hh
@@ -227,6 +230,7 @@ namespace ignition
#endif
};
/// \}
+ }
}
}
#endif
diff --git a/include/ignition/math/Spline.hh b/include/ignition/math/Spline.hh
index ef16ca7..1896865 100644
--- a/include/ignition/math/Spline.hh
+++ b/include/ignition/math/Spline.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declare private classes
class ControlPoint;
class SplinePrivate;
@@ -256,6 +259,7 @@ namespace ignition
/// \brief Private data pointer
private: SplinePrivate *dataPtr;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Temperature.hh b/include/ignition/math/Temperature.hh
index ffb1c80..4202b83 100644
--- a/include/ignition/math/Temperature.hh
+++ b/include/ignition/math/Temperature.hh
@@ -20,12 +20,15 @@
#include <iostream>
#include <memory>
+#include <ignition/math/config.hh>
#include "ignition/math/Helpers.hh"
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
// Forward declare private data class.
class TemperaturePrivate;
@@ -370,6 +373,7 @@ namespace ignition
#pragma warning(pop)
#endif
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Triangle.hh b/include/ignition/math/Triangle.hh
index ce27979..8c1104c 100644
--- a/include/ignition/math/Triangle.hh
+++ b/include/ignition/math/Triangle.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/Line2.hh>
#include <ignition/math/Vector2.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Triangle Triangle.hh ignition/math/Triangle.hh
/// \brief Triangle class and related functions.
template<typename T>
@@ -237,6 +240,7 @@ namespace ignition
/// Float specialization of the Triangle class.
typedef Triangle<float> Trianglef;
+ }
}
}
#endif
diff --git a/include/ignition/math/Triangle3.hh b/include/ignition/math/Triangle3.hh
index 12a02af..8bdb9ce 100644
--- a/include/ignition/math/Triangle3.hh
+++ b/include/ignition/math/Triangle3.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Line3.hh>
#include <ignition/math/Plane.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Triangle3 Triangle3.hh ignition/math/Triangle3.hh
/// \brief A 3-dimensional triangle and related functions.
template<typename T>
@@ -273,6 +276,7 @@ namespace ignition
/// \brief Float specialization of the Triangle class.
typedef Triangle3<float> Triangle3f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Vector2.hh b/include/ignition/math/Vector2.hh
index 96a27aa..8a3b936 100644
--- a/include/ignition/math/Vector2.hh
+++ b/include/ignition/math/Vector2.hh
@@ -18,11 +18,14 @@
#define IGNITION_MATH_VECTOR2_HH_
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Vector2 Vector2.hh ignition/math/Vector2.hh
/// \brief Two dimensional (x, y) vector.
template<typename T>
@@ -473,6 +476,7 @@ namespace ignition
typedef Vector2<int> Vector2i;
typedef Vector2<double> Vector2d;
typedef Vector2<float> Vector2f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Vector3.hh b/include/ignition/math/Vector3.hh
index 698bce0..897bc97 100644
--- a/include/ignition/math/Vector3.hh
+++ b/include/ignition/math/Vector3.hh
@@ -23,11 +23,14 @@
#include <algorithm>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Vector3 Vector3.hh ignition/math/Vector3.hh
/// \brief The Vector3 class represents the generic vector containing 3
/// elements. Since it's commonly used to keep coordinate system
@@ -752,6 +755,7 @@ namespace ignition
typedef Vector3<int> Vector3i;
typedef Vector3<double> Vector3d;
typedef Vector3<float> Vector3f;
+ }
}
}
#endif
diff --git a/include/ignition/math/Vector3Stats.hh b/include/ignition/math/Vector3Stats.hh
index 6fc323d..6e6ee4f 100644
--- a/include/ignition/math/Vector3Stats.hh
+++ b/include/ignition/math/Vector3Stats.hh
@@ -21,11 +21,14 @@
#include <ignition/math/Helpers.hh>
#include <ignition/math/SignalStats.hh>
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Forward declare private data class.
class Vector3StatsPrivate;
@@ -101,6 +104,7 @@ namespace ignition
/// \brief Pointer to private data.
protected: Vector3StatsPrivate *dataPtr;
};
+ }
}
}
#endif
diff --git a/include/ignition/math/Vector4.hh b/include/ignition/math/Vector4.hh
index de3ffa5..69a3360 100644
--- a/include/ignition/math/Vector4.hh
+++ b/include/ignition/math/Vector4.hh
@@ -19,11 +19,14 @@
#include <ignition/math/Matrix4.hh>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \class Vector4 Vector4.hh ignition/math/Vector4.hh
/// \brief T Generic x, y, z, w vector
template<typename T>
@@ -255,7 +258,7 @@ namespace ignition
public: friend inline Vector4<T> operator-(const T _s,
const Vector4<T> &_v)
{
- return Vector4<T>(_s - _v.X(), _s - _v.Y(), _s - _v.Z(), _s - _v.W());
+ return {_s - _v.X(), _s - _v.Y(), _s - _v.Z(), _s - _v.W()};
}
/// \brief Subtraction assignment operator
@@ -584,6 +587,7 @@ namespace ignition
typedef Vector4<int> Vector4i;
typedef Vector4<double> Vector4d;
typedef Vector4<float> Vector4f;
+ }
}
}
#endif
diff --git a/include/ignition/math/config.hh.in b/include/ignition/math/config.hh.in
index 16cf225..8513e67 100644
--- a/include/ignition/math/config.hh.in
+++ b/include/ignition/math/config.hh.in
@@ -8,6 +8,8 @@
#define IGNITION_MATH_VERSION "${PROJECT_VERSION}"
#define IGNITION_MATH_VERSION_FULL "${PROJECT_VERSION_FULL}"
+#define IGNITION_MATH_VERSION_NAMESPACE v${PROJECT_VERSION_MAJOR}
+
#define IGNITION_MATH_VERSION_HEADER "Ignition math, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2014 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n"
#cmakedefine IGNITION_MATH_BUILD_TYPE_PROFILE 1
diff --git a/include/ignition/math/graph/Edge.hh b/include/ignition/math/graph/Edge.hh
index afed5b6..bc67443 100644
--- a/include/ignition/math/graph/Edge.hh
+++ b/include/ignition/math/graph/Edge.hh
@@ -24,12 +24,15 @@
#include <map>
#include <set>
+#include <ignition/math/config.hh>
#include "ignition/math/graph/Vertex.hh"
namespace ignition
{
namespace math
{
+inline namespace IGNITION_MATH_VERSION_NAMESPACE
+{
namespace graph
{
/// \def EdgeId.
@@ -334,4 +337,5 @@ namespace graph
}
}
}
+}
#endif
diff --git a/include/ignition/math/graph/Graph.hh b/include/ignition/math/graph/Graph.hh
index c9f3afa..5866996 100644
--- a/include/ignition/math/graph/Graph.hh
+++ b/include/ignition/math/graph/Graph.hh
@@ -23,6 +23,7 @@
#include <string>
#include <vector>
+#include <ignition/math/config.hh>
#include "ignition/math/graph/Edge.hh"
#include "ignition/math/graph/Vertex.hh"
@@ -30,6 +31,8 @@ namespace ignition
{
namespace math
{
+inline namespace IGNITION_MATH_VERSION_NAMESPACE
+{
namespace graph
{
/// \brief A generic graph class.
@@ -760,4 +763,5 @@ namespace graph
}
}
}
+}
#endif
diff --git a/include/ignition/math/graph/GraphAlgorithms.hh b/include/ignition/math/graph/GraphAlgorithms.hh
index b8796e0..a0fcf8e 100644
--- a/include/ignition/math/graph/GraphAlgorithms.hh
+++ b/include/ignition/math/graph/GraphAlgorithms.hh
@@ -25,6 +25,7 @@
#include <utility>
#include <vector>
+#include <ignition/math/config.hh>
#include "ignition/math/graph/Graph.hh"
#include "ignition/math/Helpers.hh"
@@ -32,6 +33,8 @@ namespace ignition
{
namespace math
{
+inline namespace IGNITION_MATH_VERSION_NAMESPACE
+{
namespace graph
{
/// \def CostInfo.
@@ -320,4 +323,5 @@ namespace graph
}
}
}
+}
#endif
diff --git a/include/ignition/math/graph/Vertex.hh b/include/ignition/math/graph/Vertex.hh
index 20f39dc..5fa94a6 100644
--- a/include/ignition/math/graph/Vertex.hh
+++ b/include/ignition/math/graph/Vertex.hh
@@ -25,12 +25,15 @@
#include <string>
#include <utility>
+#include <ignition/math/config.hh>
#include <ignition/math/Helpers.hh>
namespace ignition
{
namespace math
{
+inline namespace IGNITION_MATH_VERSION_NAMESPACE
+{
namespace graph
{
/// \def VertexId.
@@ -137,4 +140,5 @@ namespace graph
}
}
}
+}
#endif
diff --git a/src/Angle.cc b/src/Angle.cc
index def990b..784cfb6 100644
--- a/src/Angle.cc
+++ b/src/Angle.cc
@@ -17,13 +17,12 @@
#include "ignition/math/Helpers.hh"
#include "ignition/math/Angle.hh"
-using namespace ignition;
-using namespace math;
+using namespace ignition::math;
-const Angle Angle::Zero = math::Angle(0);
-const Angle Angle::Pi = math::Angle(IGN_PI);
-const Angle Angle::HalfPi = math::Angle(IGN_PI_2);
-const Angle Angle::TwoPi = math::Angle(IGN_PI * 2.0);
+const Angle Angle::Zero = Angle(0);
+const Angle Angle::Pi = Angle(IGN_PI);
+const Angle Angle::HalfPi = Angle(IGN_PI_2);
+const Angle Angle::TwoPi = Angle(IGN_PI * 2.0);
//////////////////////////////////////////////////
Angle::Angle()
@@ -151,7 +150,7 @@ bool Angle::operator<(const Angle &angle) const
//////////////////////////////////////////////////
bool Angle::operator<=(const Angle &angle) const
{
- return this->value < angle.value || math::equal(this->value, angle.value);
+ return this->value < angle.value || equal(this->value, angle.value);
}
//////////////////////////////////////////////////
@@ -163,7 +162,7 @@ bool Angle::operator>(const Angle &angle) const
//////////////////////////////////////////////////
bool Angle::operator>=(const Angle &angle) const
{
- return this->value > angle.value || math::equal(this->value, angle.value);
+ return this->value > angle.value || equal(this->value, angle.value);
}
//////////////////////////////////////////////////
diff --git a/src/BoxPrivate.hh b/src/BoxPrivate.hh
index 583711b..20dccee 100644
--- a/src/BoxPrivate.hh
+++ b/src/BoxPrivate.hh
@@ -18,11 +18,14 @@
#define IGNITION_MATH_BOXPRIVATE_HH_
#include <ignition/math/Vector3.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \internal
/// \brief Private data for Box class
class BoxPrivate
@@ -33,6 +36,7 @@ namespace ignition
/// \brief Maximum corner of the box
public: Vector3d max = Vector3d(LOW_D, LOW_D, LOW_D);
};
+ }
}
}
#endif
diff --git a/src/Frustum.cc b/src/Frustum.cc
index 9246798..01de738 100644
--- a/src/Frustum.cc
+++ b/src/Frustum.cc
@@ -67,12 +67,82 @@ Planed Frustum::Plane(const FrustumPlane _plane) const
/////////////////////////////////////////////////
bool Frustum::Contains(const Box &_b) const
{
+ // This is a fast test used for culling.
// If the box is on the negative side of a plane, then the box is not
// visible.
+ int overlapping = 0;
for (auto const &plane : this->dataPtr->planes)
{
- if (plane.Side(_b) == Planed::NEGATIVE_SIDE)
+ auto const sign = plane.Side(_b);
+ if (sign == Planed::NEGATIVE_SIDE)
return false;
+ else if (sign == Planed::BOTH_SIDE)
+ ++overlapping;
+ }
+
+ // it is possible to be outside of frustum and overlapping multiple planes
+ if (overlapping >= 2)
+ {
+ // return true if any box point is inside the frustum
+ auto const &min = _b.Min();
+ auto const &max = _b.Max();
+ for (int p = 0; p < 8; ++p)
+ {
+ const double &x = (p & 4) ? min.X() : max.X();
+ const double &y = (p & 2) ? min.Y() : max.Y();
+ const double &z = (p & 1) ? min.Z() : max.Z();
+ if (this->Contains(Vector3d(x, y, z)))
+ return true;
+ }
+ // return true if any frustum point is inside the box
+ for (auto const &pt : this->dataPtr->points)
+ {
+ if (_b.Contains(pt))
+ return true;
+ }
+
+ // Return true if any edge of the frustum passes through the AABB
+ for (const auto &edge : this->dataPtr->edges)
+ {
+ // If the edge projected onto a world axis does not overlapp with the AABB
+ // then the edge could not be passing through the AABB.
+ if (edge.first.X() < min.X() && edge.second.X() < min.X())
+ {
+ // both frustum edge points are below AABB on x axis
+ continue;
+ }
+ else if (edge.first.X() > max.X() && edge.second.X() > max.X())
+ {
+ // both frustum edge points are above AABB on x axis
+ continue;
+ }
+ else if (edge.first.Y() < min.Y() && edge.second.Y() < min.Y())
+ {
+ // both frustum edge points are below AABB on y axis
+ continue;
+ }
+ else if (edge.first.Y() > max.Y() && edge.second.Y() > max.Y())
+ {
+ // both frustum edge points are above AABB on y axis
+ continue;
+ }
+ else if (edge.first.Z() < min.Z() && edge.second.Z() < min.Z())
+ {
+ // both frustum edge points are below AABB on z axis
+ continue;
+ }
+ else if (edge.first.Z() > max.Z() && edge.second.Z() > max.Z())
+ {
+ // both frustum edge points are above AABB on z axis
+ continue;
+ }
+ else
+ {
+ // TODO prove or disprove that Frustum must penetrate AABB???
+ return true;
+ }
+ }
+ return false;
}
return true;
@@ -206,6 +276,30 @@ void Frustum::ComputePlanes()
Vector3d farBottomLeft = farCenter - upFarHeight2 - rightFarWidth2;
Vector3d farBottomRight = farCenter - upFarHeight2 + rightFarWidth2;
+ // Save these vertices
+ this->dataPtr->points[0] = nearTopLeft;
+ this->dataPtr->points[1] = nearTopRight;
+ this->dataPtr->points[2] = nearBottomLeft;
+ this->dataPtr->points[3] = nearBottomRight;
+ this->dataPtr->points[4] = farTopLeft;
+ this->dataPtr->points[5] = farTopRight;
+ this->dataPtr->points[6] = farBottomLeft;
+ this->dataPtr->points[7] = farBottomRight;
+
+ // Save the edges
+ this->dataPtr->edges[0] = {nearTopLeft, nearTopRight};
+ this->dataPtr->edges[1] = {nearTopLeft, nearBottomLeft};
+ this->dataPtr->edges[2] = {nearTopLeft, farTopLeft};
+ this->dataPtr->edges[3] = {nearTopRight, nearBottomRight};
+ this->dataPtr->edges[4] = {nearTopRight, farTopRight};
+ this->dataPtr->edges[5] = {nearBottomLeft, nearBottomRight};
+ this->dataPtr->edges[6] = {nearBottomLeft, farBottomLeft};
+ this->dataPtr->edges[7] = {farTopLeft, farTopRight};
+ this->dataPtr->edges[8] = {farTopLeft, farBottomLeft};
+ this->dataPtr->edges[9] = {farTopRight, farBottomRight};
+ this->dataPtr->edges[10] = {farBottomLeft, farBottomRight};
+ this->dataPtr->edges[11] = {farBottomRight, nearBottomRight};
+
Vector3d leftCenter =
(farTopLeft + nearTopLeft + farBottomLeft + nearBottomLeft) / 4.0;
diff --git a/src/FrustumPrivate.hh b/src/FrustumPrivate.hh
index 251dd65..3077655 100644
--- a/src/FrustumPrivate.hh
+++ b/src/FrustumPrivate.hh
@@ -18,15 +18,18 @@
#define IGNITION_MATH_FRUSTUMPRIVATE_HH_
#include <array>
-
+#include <utility>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Angle.hh>
#include <ignition/math/Plane.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \internal
/// \brief Private data for the Frustum class
class FrustumPrivate
@@ -72,7 +75,14 @@ namespace ignition
/// \brief Each plane of the frustum.
/// \sa Frustum::FrustumPlane
public: std::array<Planed, 6> planes;
+
+ /// \brief Each corner of the frustum.
+ public: std::array<Vector3d, 8> points;
+
+ /// \brief each edge of the frustum.
+ public: std::array<std::pair<Vector3d, Vector3d>, 12> edges;
};
+ }
}
}
#endif
diff --git a/src/Frustum_TEST.cc b/src/Frustum_TEST.cc
index e51bb82..0466e9e 100644
--- a/src/Frustum_TEST.cc
+++ b/src/Frustum_TEST.cc
@@ -470,3 +470,183 @@ TEST(FrustumTest, PoseContains)
EXPECT_FALSE(frustum.Contains(Vector3d(0, 0, 0)));
EXPECT_FALSE(frustum.Contains(Vector3d(1, 1, 0)));
}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, ContainsAABBNoOverlap)
+{
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ // Boxes that don't overlapp any planes
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1.45, -0.05, 1.95), Vector3d(1.55, 0.05, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.55, -0.05, 1.95), Vector3d(2.65, 0.05, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(0.35, -0.05, 1.95), Vector3d(0.45, 0.05, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(1.45, -0.05, 2.55), Vector3d(1.55, 0.05, 2.65))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(1.45, -0.05, 1.35), Vector3d(1.55, 0.05, 1.45))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(1.45, -1.05, 1.95), Vector3d(1.55, -0.95, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(1.45, 0.95, 1.95), Vector3d(1.55, 1.05, 2.05))));
+}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, ContainsAABBOverlapOnePlane)
+{
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ // Boxes overlapping one plane
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.43, -0.05, 1.95), Vector3d(2.53, 0.05, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.05, 1.95), Vector3d(0.595, 0.05, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1.45, -0.05, 2.42), Vector3d(1.55, 0.05, 2.52))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1.45, -0.05, 1.48), Vector3d(1.55, 0.05, 1.58))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1.45, -0.9, 1.95), Vector3d(1.55, -0.8, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1.45, 0.8, 1.95), Vector3d(1.55, 0.9, 2.05))));
+}
+
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, ContainsAABBOverlapTwoPlanes)
+{
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ // Boxes overlapping two planes
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, -0.05, 2.7), Vector3d(2.52, 0.05, 2.8))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, -0.05, 1.2), Vector3d(2.52, 0.05, 1.3))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, -1.44, 1.95), Vector3d(2.52, -1.34, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, 1.34, 1.95), Vector3d(2.52, 1.44, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.05, 2.1), Vector3d(0.595, 0.05, 2.2))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.05, 1.8), Vector3d(0.595, 0.05, 1.9))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, 0.25, 1.95), Vector3d(0.595, 0.35, 2.05))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.35, 1.95), Vector3d(0.595, -0.25, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, -0.05, 2.81), Vector3d(2.58, 0.05, 2.91))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, -0.05, 1.09), Vector3d(2.58, 0.05, 1.19))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, -1.55, 1.95), Vector3d(2.58, -1.45, 2.05))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, 1.45, 1.95), Vector3d(2.58, 1.55, 2.05))));
+}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, ContainsAABBOverlapThreePlanes)
+{
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ // Boxes overlapping three planes
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, 0.25, 2.1), Vector3d(0.595, 0.35, 2.2))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, 0.25, 1.8), Vector3d(0.595, 0.35, 1.9))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.35, 2.1), Vector3d(0.595, -0.25, 2.2))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(0.495, -0.35, 1.8), Vector3d(0.595, -0.25, 1.9))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, 1.34, 2.7), Vector3d(2.52, 1.44, 2.8))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, 1.34, 1.2), Vector3d(2.52, 1.44, 1.3))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, -1.44, 2.7), Vector3d(2.52, -1.34, 2.8))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(2.42, -1.44, 1.2), Vector3d(2.52, -1.34, 1.3))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, 1.45, 2.81), Vector3d(2.58, 1.55, 2.91))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, -1.55, 2.81), Vector3d(2.58, -1.45, 2.91))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, 1.45, 1.09), Vector3d(2.58, 1.55, 1.19))));
+ EXPECT_FALSE(frustum.Contains(
+ Box(Vector3d(2.48, -1.55, 1.09), Vector3d(2.58, -1.45, 1.19))));
+}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, AABBContainsFrustum)
+{
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(-100, -100, -100), Vector3d(100, 100, 100))));
+}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, AABBFrustumEdgeOverlap)
+{
+ // This test case has the top of an AABB overlap a frustum, but all the
+ // corners of AABB fall outside the frustum.
+
+ double ybounds = 10;
+
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1, -ybounds, 0), Vector3d(2, ybounds, 2))));
+}
+
+//////////////////////////////////////////////////
+TEST(FrustumTest, AABBBFWall)
+{
+ // Frustum contains at a large but thin wall
+
+ Frustum frustum;
+ frustum.SetNear(0.55);
+ frustum.SetFar(2.5);
+ frustum.SetFOV(1.05);
+ frustum.SetAspectRatio(1.8);
+ frustum.SetPose(Pose3d(0, 0, 2, 0, 0, 0));
+
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(1, -10, -10), Vector3d(2, 10, 10))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(-10, 1, -10), Vector3d(10, 1.1, 10))));
+ EXPECT_TRUE(frustum.Contains(
+ Box(Vector3d(-10, -10, 1.95), Vector3d(10, 10, 2.05))));
+}
diff --git a/src/Helpers.cc b/src/Helpers.cc
index 836a613..1d0c8b2 100644
--- a/src/Helpers.cc
+++ b/src/Helpers.cc
@@ -16,32 +16,39 @@
*/
#include "ignition/math/Helpers.hh"
-/////////////////////////////////////////////
-ignition::math::PairOutput ignition::math::Pair(
- const ignition::math::PairInput _a, const ignition::math::PairInput _b)
+namespace ignition
{
- // Store in 64bit local variable so that we don't overflow.
- uint64_t a = _a;
- uint64_t b = _b;
+ namespace math
+ {
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
+ /////////////////////////////////////////////
+ PairOutput Pair(const PairInput _a, const PairInput _b)
+ {
+ // Store in 64bit local variable so that we don't overflow.
+ uint64_t a = _a;
+ uint64_t b = _b;
- // Szudzik's function
- return _a >= _b ?
- static_cast<PairOutput>(a * a + a + b) :
- static_cast<PairOutput>(a + b * b);
-}
+ // Szudzik's function
+ return _a >= _b ?
+ static_cast<PairOutput>(a * a + a + b) :
+ static_cast<PairOutput>(a + b * b);
+ }
-/////////////////////////////////////////////
-std::tuple<ignition::math::PairInput, ignition::math::PairInput>
-ignition::math::Unpair(const ignition::math::PairOutput _key)
-{
- // Must explicitly cast so that the _key is not auto cast to a double
- uint64_t sqrt = static_cast<uint64_t>(
- std::floor(std::sqrt(static_cast<long double>(_key))));
- uint64_t sq = sqrt * sqrt;
+ /////////////////////////////////////////////
+ std::tuple<PairInput, PairInput> Unpair(const PairOutput _key)
+ {
+ // Must explicitly cast so that the _key is not auto cast to a double
+ uint64_t sqrt = static_cast<uint64_t>(
+ std::floor(std::sqrt(static_cast<long double>(_key))));
+ uint64_t sq = sqrt * sqrt;
- return ((_key - sq) >= sqrt) ?
- std::make_tuple(static_cast<PairInput>(sqrt),
- static_cast<PairInput>(_key - sq - sqrt)) :
- std::make_tuple(static_cast<PairInput>(_key - sq),
- static_cast<PairInput>(sqrt));
+ return ((_key - sq) >= sqrt) ?
+ std::make_tuple(static_cast<PairInput>(sqrt),
+ static_cast<PairInput>(_key - sq - sqrt)) :
+ std::make_tuple(static_cast<PairInput>(_key - sq),
+ static_cast<PairInput>(sqrt));
+ }
+ }
+ }
}
diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc
index a573ca4..ed65003 100644
--- a/src/Helpers_TEST.cc
+++ b/src/Helpers_TEST.cc
@@ -31,10 +31,11 @@ TEST(HelpersTest, Helpers)
EXPECT_EQ(-12345, math::parseInt("-12345"));
EXPECT_EQ(-12345, math::parseInt(" -12345"));
EXPECT_EQ(0, math::parseInt(" "));
+ EXPECT_EQ(23, math::parseInt("23ab67"));
EXPECT_EQ(math::NAN_I, math::parseInt(""));
EXPECT_EQ(math::NAN_I, math::parseInt("?"));
- EXPECT_EQ(math::NAN_I, math::parseInt("23ab67"));
+ EXPECT_EQ(math::NAN_I, math::parseInt("ab23ab67"));
EXPECT_DOUBLE_EQ(12.345, math::parseFloat("12.345"));
EXPECT_DOUBLE_EQ(-12.345, math::parseFloat("-12.345"));
@@ -54,10 +55,11 @@ TEST(HelpersTest, Helpers)
EXPECT_TRUE(math::greaterOrNearEqual(1.0, 1.0 + 9e-3, 1e-2));
EXPECT_FALSE(math::greaterOrNearEqual(1.0, 1.0 + 1.1e-2, 1e-2));
EXPECT_DOUBLE_EQ(1.2345, math::parseFloat("1.2345e+0"));
+ EXPECT_DOUBLE_EQ(23.0, math::parseFloat("23ab67"));
EXPECT_TRUE(math::isnan(math::parseFloat("")));
EXPECT_TRUE(math::isnan(math::parseFloat("?")));
- EXPECT_TRUE(math::isnan(math::parseFloat("23ab67")));
+ EXPECT_TRUE(math::isnan(math::parseFloat("ab23ab67")));
EXPECT_EQ(1u, math::roundUpPowerOfTwo(0));
EXPECT_EQ(1u, math::roundUpPowerOfTwo(1));
@@ -413,7 +415,7 @@ TEST(HelpersTest, Volume)
/////////////////////////////////////////////////
TEST(HelpersTest, Pair)
{
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __arm__
math::PairInput maxA = math::MAX_UI16;
math::PairInput maxB = math::MAX_UI16;
#else
@@ -425,7 +427,7 @@ TEST(HelpersTest, Pair)
// Maximum parameters should generate a maximum key
math::PairOutput maxKey = math::Pair(maxA, maxB);
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __arm__
EXPECT_EQ(maxKey, math::MAX_UI32);
#else
EXPECT_EQ(maxKey, math::MAX_UI64);
@@ -435,7 +437,7 @@ TEST(HelpersTest, Pair)
EXPECT_EQ(maxC, maxA);
EXPECT_EQ(maxD, maxB);
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __arm__
math::PairInput minA = math::MIN_UI16;
math::PairInput minB = math::MIN_UI16;
#else
@@ -446,7 +448,7 @@ TEST(HelpersTest, Pair)
// Minimum parameters should generate a minimum key
math::PairOutput minKey = math::Pair(minA, minB);
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __arm__
EXPECT_EQ(minKey, math::MIN_UI32);
#else
EXPECT_EQ(minKey, math::MIN_UI64);
@@ -497,7 +499,7 @@ TEST(HelpersTest, Pair)
}
}
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __arm__
// Iterate over large numbers, and check for unique keys.
for (math::PairInput a = math::MAX_UI32-5000; a < math::MAX_UI32; a++)
{
diff --git a/src/KmeansPrivate.hh b/src/KmeansPrivate.hh
index 8c1cbbb..bcda8ef 100644
--- a/src/KmeansPrivate.hh
+++ b/src/KmeansPrivate.hh
@@ -20,11 +20,14 @@
#include <vector>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Helpers.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \internal
/// \brief Private data for Kmeans class
class KmeansPrivate
@@ -44,6 +47,7 @@ namespace ignition
/// \brief Counts the number of observations contained in each partition.
public: std::vector<unsigned int> counters;
};
+ }
}
}
#endif
diff --git a/src/Matrix4_TEST.cc b/src/Matrix4_TEST.cc
index 37ffc05..2dc98f0 100644
--- a/src/Matrix4_TEST.cc
+++ b/src/Matrix4_TEST.cc
@@ -236,11 +236,11 @@ TEST(Matrix4dTest, GetAsPose3d)
}
/////////////////////////////////////////////////
-TEST(Matrix4dTest, Translate)
+TEST(Matrix4dTest, Translation)
{
math::Matrix4d mat, mat2;
- mat.Translate(math::Vector3d(1, 2, 3));
- mat2.Translate(1, 2, 3);
+ mat.SetTranslation(math::Vector3d(1, 2, 3));
+ mat2.SetTranslation(1, 2, 3);
EXPECT_EQ(mat, mat2);
diff --git a/src/RotationSplinePrivate.hh b/src/RotationSplinePrivate.hh
index c668034..34af9b9 100644
--- a/src/RotationSplinePrivate.hh
+++ b/src/RotationSplinePrivate.hh
@@ -18,12 +18,15 @@
#define IGNITION_MATH_ROTATIONSPLINEPRIVATE_HH_
#include <vector>
+#include <ignition/math/config.hh>
#include "ignition/math/Quaternion.hh"
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \internal
/// \brief Private data for RotationSpline
class RotationSplinePrivate
@@ -41,6 +44,7 @@ namespace ignition
/// \brief the tangents
public: std::vector<Quaterniond> tangents;
};
+ }
}
}
#endif
diff --git a/src/SemanticVersion.cc b/src/SemanticVersion.cc
index 2f1efba..ca594d5 100644
--- a/src/SemanticVersion.cc
+++ b/src/SemanticVersion.cc
@@ -26,6 +26,8 @@ namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
class SemanticVersionPrivate
{
/// \brief Major revision (incompatible api changes)
@@ -47,6 +49,7 @@ namespace ignition
/// immediately following the patch or pre-release version
public: std::string build = "";
};
+ }
}
}
diff --git a/src/SignalStatsPrivate.hh b/src/SignalStatsPrivate.hh
index 6c7240a..e5e045e 100644
--- a/src/SignalStatsPrivate.hh
+++ b/src/SignalStatsPrivate.hh
@@ -19,11 +19,14 @@
#include <memory>
#include <vector>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Private data class for the SignalStatistic class.
class SignalStatisticPrivate
{
@@ -72,6 +75,7 @@ namespace ignition
return dataPtr;
}
};
+ }
}
}
#endif
diff --git a/src/SplinePrivate.cc b/src/SplinePrivate.cc
index 7248fe8..8543404 100644
--- a/src/SplinePrivate.cc
+++ b/src/SplinePrivate.cc
@@ -23,7 +23,8 @@ namespace ignition
{
namespace math
{
-
+inline namespace IGNITION_MATH_VERSION_NAMESPACE
+{
///////////////////////////////////////////////////////////
Vector4d PolynomialPowers(const unsigned int _order,
const double _t)
@@ -149,8 +150,6 @@ Vector3d IntervalCubicSpline::InterpolateMthDerivative(
return this->DoInterpolateMthDerivative(_mth, _t);
}
-
-
-
+}
}
}
diff --git a/src/SplinePrivate.hh b/src/SplinePrivate.hh
index 9106f07..5b1613d 100644
--- a/src/SplinePrivate.hh
+++ b/src/SplinePrivate.hh
@@ -22,11 +22,14 @@
#include <ignition/math/Vector3.hh>
#include <ignition/math/Vector4.hh>
#include <ignition/math/Matrix4.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Control point representation for
/// polynomial interpolation, defined in terms
/// of arbitrary m derivatives at such point.
@@ -201,6 +204,7 @@ namespace ignition
// \brief spline arc length.
public: double arcLength;
};
+ }
}
}
diff --git a/src/Vector3StatsPrivate.hh b/src/Vector3StatsPrivate.hh
index d4439b3..6715876 100644
--- a/src/Vector3StatsPrivate.hh
+++ b/src/Vector3StatsPrivate.hh
@@ -18,11 +18,14 @@
#define IGNITION_MATH_VECTOR3STATSPRIVATE_HH_
#include <ignition/math/SignalStats.hh>
+#include <ignition/math/config.hh>
namespace ignition
{
namespace math
{
+ inline namespace IGNITION_MATH_VERSION_NAMESPACE
+ {
/// \brief Private data class for the Vector3Stats class.
class Vector3StatsPrivate
{
@@ -38,6 +41,7 @@ namespace ignition
/// \brief Statistics for magnitude of signal.
public: SignalStats mag;
};
+ }
}
}
#endif
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b40c9d6..6e99760 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -2,6 +2,7 @@ include_directories (
${PROJECT_SOURCE_DIR}/test/gtest/include
${PROJECT_SOURCE_DIR}/test/gtest
${PROJECT_SOURCE_DIR}/test
+ ${CMAKE_BINARY_DIR}/include
)
configure_file (test_config.h.in ${PROJECT_BINARY_DIR}/test_config.h)
diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt
index ba38c2d..d4262a2 100644
--- a/test/integration/CMakeLists.txt
+++ b/test/integration/CMakeLists.txt
@@ -5,4 +5,12 @@ set(tests
link_directories(${PROJECT_BINARY_DIR}/test)
+# Test symbols having the right name on linux only
+if (UNIX AND NOT APPLE)
+ set(PATH_TO_PROJECT_LIBRARY )
+ configure_file(all_symbols_have_version.bash.in ${CMAKE_CURRENT_BINARY_DIR}/all_symbols_have_version.bash @ONLY)
+ add_test(NAME INTEGRATION_versioned_symbols
+ COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/all_symbols_have_version.bash $<TARGET_FILE:${PROJECT_LIBRARY_TARGET_NAME}>)
+endif()
+
ign_build_tests(TYPE INTEGRATION SOURCES ${tests})
diff --git a/test/integration/all_symbols_have_version.bash.in b/test/integration/all_symbols_have_version.bash.in
new file mode 100644
index 0000000..3eccf56
--- /dev/null
+++ b/test/integration/all_symbols_have_version.bash.in
@@ -0,0 +1,27 @@
+# Returns non-zero exit code if there are symbols which don't contain the project major version
+
+LIBPATH=$1
+VERSIONED_NS=v at PROJECT_MAJOR_VERSION@
+IGN_PROJECT=@IGN_PROJECT_NAME@
+
+# Sanity check - there should be at least one symbol
+NUM_SYMBOLS=$(nm $LIBPATH | grep -e "ignition.*$IGN_PROJECT" | wc -l)
+
+if [ $NUM_SYMBOLS -eq 0 ]
+then
+ echo >&2 "ERROR: Did not find any symbols in the project library"
+ exit 1
+fi
+
+# There must be no unversioned symbols
+UNVERSIONED_SYMBOLS=$(nm $LIBPATH | grep -e "ignition.*$IGN_PROJECT" | grep -e "$VERSIONED_NS" -v)
+UNVERSIONED_SYMBOL_CHARS=$(printf "$UNVERSIONED_SYMBOLS" | wc -m)
+
+if [ $UNVERSIONED_SYMBOL_CHARS -ne 0 ]
+then
+ echo >&2 "ERROR: Found unversioned symbols:\n$UNVERSIONED_SYMBOLS"
+ exit 1
+fi
+
+echo "No unversioned symbols found (num versioned symbols:$NUM_SYMBOLS)"
+exit 0
diff --git a/tools/code_check.sh b/tools/code_check.sh
index 42b03e3..d2105c0 100644
--- a/tools/code_check.sh
+++ b/tools/code_check.sh
@@ -64,12 +64,8 @@ SUPPRESS=/tmp/cpp_check.suppress
SUPPRESS=/tmp/gazebo_cpp_check.suppress
# false positives related to explicit constructors where there is no
# constructor declared
-echo "*:include/ignition/math/Vector2.hh:230" > $SUPPRESS
-echo "*:include/ignition/math/Vector3.hh:372" >> $SUPPRESS
-echo "*:include/ignition/math/Vector3.hh:433" >> $SUPPRESS
-echo "*:include/ignition/math/Vector3.hh:536" >> $SUPPRESS
-echo "*:include/ignition/math/Vector4.hh:257" >> $SUPPRESS
-echo "*:include/ignition/math/Vector4.hh:258" >> $SUPPRESS
+rm $SUPPRESS
+touch $SUPPRESS
#cppcheck
CPPCHECK_BASE="cppcheck -q --suppressions-list=$SUPPRESS --inline-suppr"
diff --git a/tools/cpplint_to_cppcheckxml.py b/tools/cpplint_to_cppcheckxml.py
new file mode 100644
index 0000000..93ba7a2
--- /dev/null
+++ b/tools/cpplint_to_cppcheckxml.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+# Convert output from Google's cpplint.py to the cppcheck XML format for
+# consumption by the Jenkins cppcheck plugin.
+
+# Reads from stdin and writes to stderr (to mimic cppcheck)
+
+
+import sys
+import re
+import xml.sax.saxutils
+
+def cpplint_score_to_cppcheck_severity(score):
+ # I'm making this up
+ if score == 1:
+ return 'style'
+ elif score == 2:
+ return 'style'
+ elif score == 3:
+ return 'warning'
+ elif score == 4:
+ return 'warning'
+ elif score == 5:
+ return 'error'
+
+
+def parse():
+ # TODO: do this properly, using the xml module.
+ # Write header
+ sys.stderr.write('''<?xml version="1.0" encoding="UTF-8"?>\n''')
+ sys.stderr.write('''<results>\n''')
+
+ # Do line-by-line conversion
+ r = re.compile('([^:]*):([0-9]*): ([^\[]*)\[([^\]]*)\] \[([0-9]*)\].*')
+
+ for l in sys.stdin.readlines():
+ m = r.match(l.strip())
+ if not m:
+ continue
+ g = m.groups()
+ if len(g) != 5:
+ continue
+ fname, lineno, rawmsg, label, score = g
+ # Protect Jenkins from bad XML, which makes it barf
+ msg = xml.sax.saxutils.quoteattr(rawmsg)
+ severity = cpplint_score_to_cppcheck_severity(int(score))
+ sys.stderr.write('''<error file="%s" line="%s" id="%s" severity="%s" msg=%s/>\n'''%(fname, lineno, label, severity, msg))
+
+ # Write footer
+ sys.stderr.write('''</results>\n''')
+
+
+if __name__ == '__main__':
+ parse()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ignition-math4.git
More information about the debian-science-commits
mailing list