#pragma once #include #ifndef SEAD_MATH_QUAT_H_ #include #endif namespace sead { template inline Quat::Quat(T w_, T x_, T y_, T z_) { QuatCalcCommon::set(*this, w_, x_, y_, z_); } template inline Quat& Quat::operator*=(const Quat& t) { QuatCalcCommon::setMul(*this, *this, t); return *this; } template inline T Quat::length() const { return QuatCalcCommon::length(*this); } template inline T Quat::normalize() { return QuatCalcCommon::normalize(*this); } template inline T Quat::dot(const Self& q) { return QuatCalcCommon::dot(*this, q); } // reference? // conjugate(q) / dot(q)? template inline void Quat::inverse(Self* q) { T prod = dot(*this); if (prod > std::numeric_limits::epsilon()) { T inv = T(1) / prod; q->w = inv * this->w; q->x = inv * -this->x; q->y = inv * -this->y; q->z = inv * -this->z; } else { q->w = this->w; q->x = -this->x; q->y = -this->y; q->z = -this->z; } } template inline void Quat::makeUnit() { QuatCalcCommon::makeUnit(*this); } template inline bool Quat::makeVectorRotation(const Vec3& from, const Vec3& to) { return QuatCalcCommon::makeVectorRotation(*this, from, to); } template inline void Quat::set(T w_, T x_, T y_, T z_) { QuatCalcCommon::set(*this, w_, x_, y_, z_); } template inline void Quat::setRPY(T roll, T pitch, T yaw) { QuatCalcCommon::setRPY(*this, roll, pitch, yaw); } template inline void Quat::calcRPY(Vec3& vec) const { QuatCalcCommon::calcRPY(vec, *this); } } // namespace sead