mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 14:11:28 +07:00
qua: distance func
This commit is contained in:
@@ -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}));
|
||||
|
||||
Reference in New Issue
Block a user