21 namespace SpatialStructures {
43 template<
typename desired_type,
typename numeric_type>
44 inline constexpr desired_type
DivideBy1(numeric_type n) {
45 return static_cast<desired_type
>(1) /
static_cast<desired_type
>(n);
74 float trunchf(
float f,
float p = 1000.0,
float r = 0.001);
88 template <
typename numeric_type>
92 int precision_2 = precision * 10;
93 r = std::round(f * precision_2);
94 r = std::round(r * 0.1);
113 template <
typename numeric_type>
118 ) {
return std::round(f * p) * r; }
132 template <
typename desired_type,
typename numeric_type>
133 inline constexpr desired_type
roundhf_tmp(numeric_type f, numeric_type p) {
134 return roundhf_tmp(
static_cast<desired_type
>(f), DivideBy1<desired_type>(p),
static_cast<desired_type
>(p));
136 template <
typename desired_type,
typename numeric_type>
150 static_cast<desired_type
>(f),
169 template <
typename numeric_type>
174 ) {
return std::trunc(f * p) * r; }
188 template <
typename desired_type,
typename numeric_type>
189 inline constexpr desired_type
trunchf_tmp(numeric_type f, numeric_type p) {
190 return trunchf_tmp(
static_cast<desired_type
>(f), DivideBy1<desired_type>(p),
static_cast<desired_type
>(p));
203 template <
typename desired_type,
typename numeric_type>
206 static_cast<desired_type
>(f),
Perform human scale analysis on 3D environments.
constexpr float ROUNDING_PRECISION
Minimum value that can be represented in DHART_API.
constexpr desired_type DivideBy1(numeric_type n)
Cast a value to the specific type and divide 1 by it.
numeric_type roundhf_tail(numeric_type f, int precision)
round a number twice, once at the precision+1, and again at the precision This method is to fix cases...
constexpr numeric_type roundhf_tmp(numeric_type f, numeric_type p, numeric_type r)
round a number to the nearest precision defined globally. The global values can be overridden with op...
float roundhf(float f, float p=FLOAT_PRECISION, float r=ROUNDING_PRECISION)
Round a float to the nearest precision defined globally. The global values can be overridden with opt...
float trunchf(float f, float p=1000.0, float r=0.001)
Truncate a float to the nearest precision defined globally. The global values can be overridden with ...
constexpr float GROUND_OFFSET
Offset to be used for offsetting from a polygon when performing checks.
constexpr float FLOAT_PRECISION
Used to convert to a given precision (avoids division)
constexpr numeric_type trunchf_tmp(numeric_type f, numeric_type p, numeric_type r)
truncate a number to the nearest precision defined globally. The global values can be overridden with...