diff --git a/AngleAxis.cpp b/AngleAxis.cpp index 98b6d7a..49379ef 100644 --- a/AngleAxis.cpp +++ b/AngleAxis.cpp @@ -4,33 +4,36 @@ #include "AngleAxis.h" -// template -// AngleAxis::AngleAxis() { -// this->angle = Angle(); -// this->axis = Direction(); -// } +template +AngleAxis::AngleAxis() { + this->angle = AngleOf(); + this->axis = Direction(); +} -// template -// AngleAxis::AngleAxis(AngleOf angle, Direction axis) { -// this->angle = angle; -// this->axis = axis; -// } +template +AngleAxis::AngleAxis(AngleOf angle, Direction axis) { + this->angle = angle; + this->axis = axis; +} -// template -// AngleAxis::AngleAxis(float angle, Vector3 axis) { -// this->angle = AngleOf(angle); -// this->axis = Direction(axis); -// } +template +AngleAxis::AngleAxis(float angle, Vector3 axis) { + this->angle = AngleOf(angle); + this->axis = Direction(axis); +} -// template -// Quaternion AngleAxis::ToQuaternion() { -// Vector3 axisVector = this->axis.ToVector3(); -// float angleFloat = this->angle.ToFloat(); -// Quaternion q = Quaternion::AngleAxis(angleFloat, axisVector); -// return q; -// } +template +Quaternion AngleAxis::ToQuaternion() { + Vector3 axisVector = this->axis.ToVector3(); + float angleFloat = this->angle.ToFloat(); + Quaternion q = Quaternion::AngleAxis(angleFloat, axisVector); + return q; +} -// template -// Direction AngleAxis::GetSwing() { -// return this->axis; -// } \ No newline at end of file +template +Direction AngleAxis::GetSwing() { + return this->axis; +} + +template class AngleAxis; +template class AngleAxis; diff --git a/AngleAxis.h b/AngleAxis.h index 2df36dd..14e2f3d 100644 --- a/AngleAxis.h +++ b/AngleAxis.h @@ -27,39 +27,8 @@ class AngleAxis { Direction GetSwing(); }; -template -Quaternion AngleAxis::ToQuaternion() { - Vector3 axisVector = this->axis.ToVector3(); - float angleFloat = this->angle.ToFloat(); - Quaternion q = Quaternion::AngleAxis(angleFloat, axisVector); - return q; -} - } // namespace LinearAlgebra } // namespace Passer using namespace Passer::LinearAlgebra; -template -AngleAxis::AngleAxis() { - this->angle = Angle(); - this->axis = Direction(); -} - -template -AngleAxis::AngleAxis(AngleOf angle, Direction axis) { - this->angle = angle; - this->axis = axis; -} - -template -AngleAxis::AngleAxis(float angle, Vector3 axis) { - this->angle = AngleOf(angle); - this->axis = Direction(axis); -} - -template -Direction AngleAxis::GetSwing() { - return this->axis; -} - #endif \ No newline at end of file diff --git a/Direction.cpp b/Direction.cpp index 4cd40be..f17f271 100644 --- a/Direction.cpp +++ b/Direction.cpp @@ -9,24 +9,24 @@ #include -// template -// Direction::Direction() { -// this->horizontalAngle = AngleOf(0.0f); -// this->verticalAngle = AngleOf(0.0f); -// } +template +Direction::Direction() { + this->horizontalAngle = AngleOf(0.0f); + this->verticalAngle = AngleOf(0.0f); +} -// template -// Direction::Direction(AngleOf horizontal, AngleOf vertical) { -// this->horizontalAngle = horizontal; -// this->verticalAngle = vertical; -// }; +template +Direction::Direction(AngleOf horizontal, AngleOf vertical) { + this->horizontalAngle = horizontal; + this->verticalAngle = vertical; +}; -// template -// Direction::Direction(Vector3 v) { -// this->horizontalAngle = -// atan2f(v.Right(), v.Forward()) * Passer::LinearAlgebra::Rad2Deg; -// this->verticalAngle = 90 - acosf(v.Up()) * Passer::LinearAlgebra::Rad2Deg; -// } +template +Direction::Direction(Vector3 v) { + this->horizontalAngle = + atan2f(v.Right(), v.Forward()) * Passer::LinearAlgebra::Rad2Deg; + this->verticalAngle = 90 - acosf(v.Up()) * Passer::LinearAlgebra::Rad2Deg; +} template const Direction Direction::forward = Direction(0.0f, 0.0f); @@ -41,10 +41,14 @@ const Direction Direction::left = Direction(-90.0f, 0.0f); template const Direction Direction::right = Direction(90.0f, 0.0f); -// template -// Vector3 Direction::ToVector3() { -// Vector3 v = Quaternion::Euler(-(this->verticalAngle.ToFloat()), -// this->horizontalAngle.ToFloat(), 0) * -// Vector3::forward; -// return v; -// } \ No newline at end of file +template +Vector3 Direction::ToVector3() { + Vector3 v = Quaternion::Euler(-(this->verticalAngle.ToFloat()), + this->horizontalAngle.ToFloat(), 0) * + Vector3::forward; + return v; +} + +template class Direction; +template class Direction; +template class Direction; \ No newline at end of file diff --git a/Direction.h b/Direction.h index 755855a..6978b0a 100644 --- a/Direction.h +++ b/Direction.h @@ -36,35 +36,4 @@ class Direction { } // namespace Passer using namespace Passer::LinearAlgebra; -#include -#include "Quaternion.h" -#include "Vector3.h" - -template -Direction::Direction() { - this->horizontalAngle = AngleOf(0.0f); - this->verticalAngle = AngleOf(0.0f); -} - -template -Direction::Direction(AngleOf horizontal, AngleOf vertical) { - this->horizontalAngle = horizontal; - this->verticalAngle = vertical; -}; - -template -Direction::Direction(Vector3 v) { - this->horizontalAngle = - atan2f(v.Right(), v.Forward()) * Passer::LinearAlgebra::Rad2Deg; - this->verticalAngle = 90 - acosf(v.Up()) * Passer::LinearAlgebra::Rad2Deg; -} - -template -Vector3 Direction::ToVector3() { - Vector3 v = Quaternion::Euler(-(this->verticalAngle.ToFloat()), - this->horizontalAngle.ToFloat(), 0) * - Vector3::forward; - return v; -} - #endif \ No newline at end of file