Add quaternion += and -=

This commit is contained in:
Nikita Lisitsa 2021-12-27 11:49:12 +03:00
parent 0a2cfda21f
commit 36854905fc

View file

@ -28,6 +28,9 @@ namespace psemek::geom
T & operator[] (std::size_t i) { return coords[i]; }
T const & operator[] (std::size_t i) const { return coords[i]; }
quaternion<T> & operator += (quaternion<T> const & other);
quaternion<T> & operator -= (quaternion<T> const & other);
};
template <typename ... Args>
@ -136,6 +139,20 @@ namespace psemek::geom
return r;
}
template <typename T>
quaternion<T> & quaternion<T>::operator += (quaternion<T> const & other)
{
(*this) = (*this) + other;
return *this;
}
template <typename T>
quaternion<T> & quaternion<T>::operator -= (quaternion<T> const & other)
{
(*this) = (*this) - other;
return *this;
}
template <typename T>
T norm_sqr(quaternion<T> const & q)
{