Skip to content

Fix SIOF for error-bounds and put stdx into predicates namespace #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions predicates.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ namespace predicates {
#define PREDICATES_TOKEN_TO_STRING1(x) #x
#define PREDICATES_TOKEN_TO_STRING(x) PREDICATES_TOKEN_TO_STRING1(x)
#define PREDICATES_PORTABLE_STATIC_ASSERT(condition, message) static_assert(condition, PREDICATES_TOKEN_TO_STRING(message))
namespace predicates {
namespace stdx {
using std::array;
using std::copy_n;
}
#else
namespace predicates {
namespace stdx {
// array
template<typename T, size_t N>
Expand Down Expand Up @@ -431,7 +433,6 @@ namespace detail {
);
}

namespace predicates {
namespace exact {
//@brief : determine if the 2d point c is above, on, or below the line defined by a and b
//@param pa: pointer to a as {x, y}
Expand Down Expand Up @@ -553,6 +554,18 @@ namespace predicates {
}
}

template <typename T>
const T& Epsilon()
{
static const T epsilon =
#ifdef PREDICATES_CXX11_IS_SUPPORTED
std::exp2(-std::numeric_limits<T>::digits);
#else
std::ldexp(T(1), -std::numeric_limits<T>::digits);
#endif
return epsilon;
}

template <typename T>
class Constants {
public:
Expand All @@ -563,27 +576,20 @@ namespace predicates {
static const T isperrboundA, isperrboundB, isperrboundC;
};

template <typename T> const T Constants<T>::epsilon = static_cast<T>(
#ifdef PREDICATES_CXX11_IS_SUPPORTED
std::exp2(-std::numeric_limits<T>::digits)
#else
std::ldexp(T(1), -std::numeric_limits<T>::digits)
#endif
);

template <typename T> const T Constants<T>::resulterrbound = (T( 3) + T( 8) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::ccwerrboundA = (T( 3) + T( 16) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::ccwerrboundB = (T( 2) + T( 12) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::ccwerrboundC = (T( 9) + T( 64) * Constants<T>::epsilon) * Constants<T>::epsilon * Constants<T>::epsilon;
template <typename T> const T Constants<T>::o3derrboundA = (T( 7) + T( 56) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::o3derrboundB = (T( 3) + T( 28) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::o3derrboundC = (T(26) + T( 288) * Constants<T>::epsilon) * Constants<T>::epsilon * Constants<T>::epsilon;
template <typename T> const T Constants<T>::iccerrboundA = (T(10) + T( 96) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::iccerrboundB = (T( 4) + T( 48) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::iccerrboundC = (T(44) + T( 576) * Constants<T>::epsilon) * Constants<T>::epsilon * Constants<T>::epsilon;
template <typename T> const T Constants<T>::isperrboundA = (T(16) + T( 224) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::isperrboundB = (T( 5) + T( 72) * Constants<T>::epsilon) * Constants<T>::epsilon;
template <typename T> const T Constants<T>::isperrboundC = (T(71) + T(1408) * Constants<T>::epsilon) * Constants<T>::epsilon * Constants<T>::epsilon;
template <typename T> const T Constants<T>::epsilon = Epsilon<T>();
template <typename T> const T Constants<T>::resulterrbound = (T( 3) + T( 8) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::ccwerrboundA = (T( 3) + T( 16) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::ccwerrboundB = (T( 2) + T( 12) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::ccwerrboundC = (T( 9) + T( 64) * Epsilon<T>()) * Epsilon<T>() * Epsilon<T>();
template <typename T> const T Constants<T>::o3derrboundA = (T( 7) + T( 56) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::o3derrboundB = (T( 3) + T( 28) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::o3derrboundC = (T(26) + T( 288) * Epsilon<T>()) * Epsilon<T>() * Epsilon<T>();
template <typename T> const T Constants<T>::iccerrboundA = (T(10) + T( 96) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::iccerrboundB = (T( 4) + T( 48) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::iccerrboundC = (T(44) + T( 576) * Epsilon<T>()) * Epsilon<T>() * Epsilon<T>();
template <typename T> const T Constants<T>::isperrboundA = (T(16) + T( 224) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::isperrboundB = (T( 5) + T( 72) * Epsilon<T>()) * Epsilon<T>();
template <typename T> const T Constants<T>::isperrboundC = (T(71) + T(1408) * Epsilon<T>()) * Epsilon<T>() * Epsilon<T>();

namespace adaptive {
//@brief : determine if the 2d point c is above, on, or below the line defined by a and b
Expand Down