Program Listing for File spatial.hpp
↰ Return to documentation for file (rcppsw/spatial/spatial.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcppsw/math/vector3.hpp"
#include "rcppsw/math/vector2.hpp"
#include "rcppsw/spatial/euclidean_dist.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace rcppsw::spatial {
/*******************************************************************************
* Macros
******************************************************************************/
#define RCPPSW_MATH_SPAN_FUNC_FLT(component) \
template<typename TCoord, \
RCPPSW_SFINAE_DECLDEF(std::is_floating_point<typename TCoord::value_type>::value)> \
static inline rmath::ranged component##span(const TCoord& anchor, \
const double& dim) { \
return { anchor.component(), (anchor.component() + dim) }; \
}
#define RCPPSW_MATH_SPAN_FUNC_DISC(component) \
template <typename TCoord, \
RCPPSW_SFINAE_DECLDEF(!std::is_floating_point<typename TCoord::value_type>::value)>\
static inline rmath::rangez component##span(const TCoord& anchor, size_t dim) { \
/* rely on truncation of the 0.5 remainder (if it exists) to 0 */ \
return { anchor.component(), anchor.component() + dim - 1 }; \
}
/*******************************************************************************
* Free Functions
******************************************************************************/
RCPPSW_MATH_SPAN_FUNC_FLT(x);
RCPPSW_MATH_SPAN_FUNC_FLT(y);
RCPPSW_MATH_SPAN_FUNC_FLT(z);
RCPPSW_MATH_SPAN_FUNC_DISC(x);
RCPPSW_MATH_SPAN_FUNC_DISC(y);
RCPPSW_MATH_SPAN_FUNC_DISC(z);
} /* namespace rcppsw::spatial */