diff --git a/AngleAxis.cpp b/AngleAxis.cpp new file mode 100644 index 0000000..9cc1f1e --- /dev/null +++ b/AngleAxis.cpp @@ -0,0 +1,15 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0.If a copy of the MPL was not distributed with this +// file, You can obtain one at https ://mozilla.org/MPL/2.0/. + +#include "AngleAxis.h" + +AngleAxis::AngleAxis() { + angle = Angle(); + axis = Axis(); +} + +AngleAxis::AngleAxis(Angle angle, Axis axis) { + this->angle = angle; + this->axis = axis; +} \ No newline at end of file diff --git a/AngleAxis.h b/AngleAxis.h new file mode 100644 index 0000000..68eda55 --- /dev/null +++ b/AngleAxis.h @@ -0,0 +1,20 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0.If a copy of the MPL was not distributed with this +// file, You can obtain one at https ://mozilla.org/MPL/2.0/. + +#ifndef ANGLEAXIS_H +#define ANGLEAXIS_H + +#include "Angle.h" +#include "Axis.h" + +class AngleAxis { +public: + Angle angle; + Axis axis; + + AngleAxis(); + AngleAxis(Angle angle, Axis axis); +}; + +#endif \ No newline at end of file diff --git a/Axis.cpp b/Axis.cpp new file mode 100644 index 0000000..0b21ac0 --- /dev/null +++ b/Axis.cpp @@ -0,0 +1,39 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0.If a copy of the MPL was not distributed with this +// file, You can obtain one at https ://mozilla.org/MPL/2.0/. + +#include "Axis.h" + +#include "Quaternion.h" +#include "Vector3.h" + +#include + +Axis::Axis() { + horizontalAngle = 0; + verticalAngle = 0; +} + +Axis::Axis(Angle horizontal, Angle vertical) { + this->horizontalAngle = horizontal; + this->verticalAngle = vertical; +}; + +Axis::Axis(Vector3 v) { + this->horizontalAngle = atan2f(v.x, v.z) * Angle::Rad2Deg; + this->verticalAngle = 90 - acosf(v.y) * Angle::Rad2Deg; +} + +const Axis Axis::forward = Axis(0, 0); +const Axis Axis::back = Axis(180, 0); +const Axis Axis::up = Axis(0, 90); +const Axis Axis::down = Axis(0, -90); +const Axis Axis::left = Axis(-90, 0); +const Axis Axis::right = Axis(90, 0); + +Vector3 Axis::ToVector3() { + Vector3 v = + Quaternion::Euler(-this->verticalAngle, this->horizontalAngle, 0) * + Vector3::forward; + return v; +} \ No newline at end of file diff --git a/Axis.h b/Axis.h new file mode 100644 index 0000000..992ab58 --- /dev/null +++ b/Axis.h @@ -0,0 +1,31 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0.If a copy of the MPL was not distributed with this +// file, You can obtain one at https ://mozilla.org/MPL/2.0/. + +#ifndef AXIS_H +#define AXIS_H + +#include "Angle.h" + +class Vector3; + +class Axis { +public: + Angle horizontalAngle; + Angle verticalAngle; + + Axis(); + Axis(Angle horizontal, Angle vertical); + Axis(Vector3 v); + + const static Axis forward; + const static Axis back; + const static Axis up; + const static Axis down; + const static Axis left; + const static Axis right; + + Vector3 ToVector3(); +}; + +#endif \ No newline at end of file