coord/ops: generalise vectors hypot function
This commit is contained in:
parent
70689fd449
commit
109d47e971
@ -547,6 +547,23 @@ namespace util {
|
||||
return k;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// root of sum of squares
|
||||
template <
|
||||
size_t S,
|
||||
typename T,
|
||||
template <size_t,typename> class K,
|
||||
typename = std::enable_if_t<
|
||||
is_coord_v<K<S,T>>, void
|
||||
>
|
||||
>
|
||||
constexpr
|
||||
T
|
||||
hypot (K<S,T> k)
|
||||
{
|
||||
return std::sqrt (sum (k * k));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <
|
||||
|
@ -50,12 +50,6 @@ namespace util {
|
||||
template <typename T> vector<2,T> to_euler (vector<3,T>);
|
||||
template <typename T> vector<3,T> from_euler (vector<2,T>);
|
||||
|
||||
// root of sum of squares
|
||||
template <size_t S, typename T>
|
||||
constexpr
|
||||
T
|
||||
hypot (util::vector<S,T>);
|
||||
|
||||
// output and serialisation operators
|
||||
template <size_t S, typename T>
|
||||
const json::tree::node&
|
||||
|
10
vector.ipp
10
vector.ipp
@ -32,13 +32,3 @@ util::vector<S,T>::homog (void) const
|
||||
static_assert (D > S, "reducing size loses data");
|
||||
return (*this).template redim<D> (0.f);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
constexpr
|
||||
T
|
||||
util::hypot (util::vector<S,T> v)
|
||||
{
|
||||
return std::sqrt (sum (v * v));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user