#ifndef CORE_QUATERNION_H #define CORE_QUATERNION_H #include "math/Vector.h" #include "utils/ArrayString.h" namespace Core { class Quaternion final { Vector3 xyz; float w; public: Quaternion(); Quaternion(const Vector3& axis, float angle); Quaternion lerp(float f, const Quaternion& other) const; Quaternion& operator*=(const Quaternion& other); Quaternion operator*(const Quaternion& other) const; Vector3 operator*(const Vector3& v) const; template check_return Error toString(String& s) const { CORE_RETURN_ERROR(s.append("(")); CORE_RETURN_ERROR(s.append(xyz[0])); CORE_RETURN_ERROR(s.append(" i + ")); CORE_RETURN_ERROR(s.append(xyz[1])); CORE_RETURN_ERROR(s.append(" j + ")); CORE_RETURN_ERROR(s.append(xyz[2])); CORE_RETURN_ERROR(s.append(" k + ")); CORE_RETURN_ERROR(s.append(w)); CORE_RETURN_ERROR(s.append(')')); return Error::NONE; } }; } #endif