Add quaternion/scalar operator & rename quaternion norm -> length
This commit is contained in:
parent
1f0e4e545e
commit
4c48790497
1 changed files with 15 additions and 3 deletions
|
|
@ -128,6 +128,12 @@ namespace psemek::geom
|
|||
return {s * q.coords};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
quaternion<T> operator / (quaternion<T> const & q, T s)
|
||||
{
|
||||
return {q.coords / s};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
quaternion<T> operator * (quaternion<T> const & q1, quaternion<T> const & q2)
|
||||
{
|
||||
|
|
@ -154,17 +160,23 @@ namespace psemek::geom
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
T norm_sqr(quaternion<T> const & q)
|
||||
T length_sqr(quaternion<T> const & q)
|
||||
{
|
||||
return length_sqr(q.coords);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T norm(quaternion<T> const & q)
|
||||
T length(quaternion<T> const & q)
|
||||
{
|
||||
return length(q.coords);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
quaternion<T> normalized(quaternion<T> const & q)
|
||||
{
|
||||
return {normalized(q.coords)};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
quaternion<T> conjugate(quaternion<T> const & q)
|
||||
{
|
||||
|
|
@ -174,7 +186,7 @@ namespace psemek::geom
|
|||
template <typename T>
|
||||
quaternion<T> inverse(quaternion<T> const & q)
|
||||
{
|
||||
return {conjugate(q).coords / norm(q)};
|
||||
return conjugate(q) / length(q);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue