Commit 72331aa7 authored by Philip Trettner's avatar Philip Trettner
Browse files

Merge branch 'kschuster' into 'develop'

Fixed contains(sphere, pos) test.

See merge request !37
parents a3b7af6d 95740035
...@@ -102,7 +102,8 @@ TG_NODISCARD constexpr bool contains(ball<D, ScalarT> const& s, pos<D, ScalarT> ...@@ -102,7 +102,8 @@ TG_NODISCARD constexpr bool contains(ball<D, ScalarT> const& s, pos<D, ScalarT>
template <int D, class ScalarT> template <int D, class ScalarT>
TG_NODISCARD constexpr bool contains(sphere<D, ScalarT> const& s, pos<D, ScalarT> const& p, ScalarT eps = ScalarT(0)) TG_NODISCARD constexpr bool contains(sphere<D, ScalarT> const& s, pos<D, ScalarT> const& p, ScalarT eps = ScalarT(0))
{ {
return tg::abs(distance_sqr(s.center, p) - s.radius * s.radius) <= eps; auto r = s.radius + eps;
return distance_sqr(s.center, p) <= r * r;
} }
// Note that eps is used to compare 2D areas, not 1D lengths // Note that eps is used to compare 2D areas, not 1D lengths
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment