qua: distance func

This commit is contained in:
BlackMATov
2021-02-09 19:00:34 +07:00
parent 3d521fd745
commit c15095c098
2 changed files with 13 additions and 0 deletions

View File

@@ -244,6 +244,12 @@ namespace vmath_hpp
return length2(vec{xs});
}
template < typename T >
[[nodiscard]] T distance(const qua<T>& xs, const qua<T>& ys) {
const qua zs = xs * conjugate(ys);
return T(2) * atan2(length(zs.v), abs(zs.s));
}
template < typename T >
[[nodiscard]] constexpr qua<T> normalize(const qua<T>& xs) {
return qua(normalize(vec{xs}));