// Copyright (C) 2013 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include #include #include #include #include #include #define F(a) static_cast(a) template NzEulerAngles::NzEulerAngles(T P, T Y, T R) { Set(P, Y, R); } template NzEulerAngles::NzEulerAngles(const T angles[3]) { Set(angles); } template NzEulerAngles::NzEulerAngles(const NzQuaternion& quat) { Set(quat); } template template NzEulerAngles::NzEulerAngles(const NzEulerAngles& angles) { Set(angles); } template void NzEulerAngles::MakeZero() { Set(F(0.0), F(0.0), F(0.0)); } template void NzEulerAngles::Normalize() { pitch = NzNormalizeAngle(pitch); yaw = NzNormalizeAngle(yaw); roll = NzNormalizeAngle(roll); } template void NzEulerAngles::Set(T P, T Y, T R) { pitch = P; yaw = Y; roll = R; } template void NzEulerAngles::Set(const T angles[3]) { pitch = angles[0]; yaw = angles[1]; roll = angles[2]; } template void NzEulerAngles::Set(const NzEulerAngles& angles) { std::memcpy(this, &angles, sizeof(NzEulerAngles)); } template void NzEulerAngles::Set(const NzQuaternion& quat) { Set(quat.ToEulerAngles()); } template template void NzEulerAngles::Set(const NzEulerAngles& angles) { pitch = static_cast(angles.pitch); yaw = static_cast(angles.yaw); roll = static_cast(angles.roll); } template NzQuaternion NzEulerAngles::ToQuaternion() const { NzQuaternion rotX(pitch, NzVector3::UnitX()); NzQuaternion rotY(yaw, NzVector3::UnitY()); NzQuaternion rotZ(roll, NzVector3::UnitZ()); return rotY * rotX * rotZ; } template NzString NzEulerAngles::ToString() const { NzStringStream ss; return ss << "EulerAngles(" << pitch << ", " << yaw << ", " << roll << ')'; } template NzEulerAngles NzEulerAngles::operator+(const NzEulerAngles& angles) const { return NzEulerAngles(pitch + angles.pitch, yaw + angles.yaw, roll + angles.roll); } template NzEulerAngles NzEulerAngles::operator-(const NzEulerAngles& angles) const { return NzEulerAngles(pitch - angles.pitch, yaw - angles.yaw, roll - angles.roll); } template NzEulerAngles NzEulerAngles::operator+=(const NzEulerAngles& angles) { pitch += angles.pitch; yaw += angles.yaw; roll += angles.roll; return *this; } template NzEulerAngles NzEulerAngles::operator-=(const NzEulerAngles& angles) { pitch -= angles.pitch; yaw -= angles.yaw; roll -= angles.roll; return *this; } template bool NzEulerAngles::operator==(const NzEulerAngles& angles) const { return NzNumberEquals(pitch, angles.pitch) && NzNumberEquals(yaw, angles.yaw) && NzNumberEquals(roll, angles.roll); } template bool NzEulerAngles::operator!=(const NzEulerAngles& angles) const { return !operator==(angles); } template NzEulerAngles NzEulerAngles::Zero() { NzEulerAngles angles; angles.MakeZero(); return angles; } template std::ostream& operator<<(std::ostream& out, const NzEulerAngles& angles) { return out << angles.ToString(); } #undef F #include