Commit afa57ab9 authored by Julius Nehring-Wirxel's avatar Julius Nehring-Wirxel

Fixed are_orthogonal for real.

parent 69649b8a
...@@ -32,7 +32,9 @@ template <int D, class ScalarT, class = enable_if<is_floating_point<ScalarT>>> ...@@ -32,7 +32,9 @@ template <int D, class ScalarT, class = enable_if<is_floating_point<ScalarT>>>
template <int D, class ScalarT> template <int D, class ScalarT>
[[nodiscard]] constexpr bool are_orthogonal(vec<D, ScalarT> const& a, vec<D, ScalarT> const& b, ScalarT eps = 100 * D * tg::epsilon<ScalarT>) [[nodiscard]] constexpr bool are_orthogonal(vec<D, ScalarT> const& a, vec<D, ScalarT> const& b, ScalarT eps = 100 * D * tg::epsilon<ScalarT>)
{ {
return abs(dot(a, b)) < max(max_element(abs(a)), max_element(abs(b))) * eps; // the error scales with the square of the magnitude of the inputs
auto const scale = max(max_element(abs(a)), max_element(abs(b)));
return abs(dot(a, b)) < scale * scale * eps;
} }
template <int D, class ScalarT> template <int D, class ScalarT>
......
Markdown is supported
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