diff --git a/AngleAxis.cpp b/AngleAxis.cpp index 529f5d1..98b6d7a 100644 --- a/AngleAxis.cpp +++ b/AngleAxis.cpp @@ -4,14 +4,33 @@ #include "AngleAxis.h" -template -AngleAxis::AngleAxis() { - this->angle = Angle(); - this->axis = Direction(); -} +// template +// AngleAxis::AngleAxis() { +// this->angle = Angle(); +// this->axis = Direction(); +// } -template -AngleAxis::AngleAxis(AngleOf angle, Direction axis) { - this->angle = angle; - this->axis = axis; -} \ No newline at end of file +// 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 +// 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 diff --git a/AngleAxis.h b/AngleAxis.h index a79bd1e..2df36dd 100644 --- a/AngleAxis.h +++ b/AngleAxis.h @@ -7,6 +7,7 @@ #include "Angle.h" #include "Direction.h" +#include "Quaternion.h" namespace Passer { namespace LinearAlgebra { @@ -19,10 +20,46 @@ class AngleAxis { AngleAxis(); AngleAxis(AngleOf angle, Direction axis); + AngleAxis(float angle, Vector3 axis); + + Quaternion ToQuaternion(); + + 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 af31a58..4cd40be 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,10 @@ 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; +// } \ No newline at end of file diff --git a/Direction.h b/Direction.h index 6978b0a..755855a 100644 --- a/Direction.h +++ b/Direction.h @@ -36,4 +36,35 @@ 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