// 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.0f; verticalAngle = 0.0f; } Axis::Axis(Angle horizontal, Angle vertical) { this->horizontalAngle = horizontal; this->verticalAngle = vertical; }; Axis::Axis(Vector3 v) { this->horizontalAngle = atan2f(v.Right(), v.Forward()) * Angle::Rad2Deg; this->verticalAngle = 90 - acosf(v.Up()) * Angle::Rad2Deg; } const Axis Axis::forward = Axis(0.0f, 0.0f); const Axis Axis::back = Axis(180.0f, 0.0f); const Axis Axis::up = Axis(0.0f, 90.0f); const Axis Axis::down = Axis(0.0f, -90.0f); const Axis Axis::left = Axis(-90.0f, 0.0f); const Axis Axis::right = Axis(90.0f, 0.0f); Vector3 Axis::ToVector3() { Vector3 v = Quaternion::Euler(-this->verticalAngle, this->horizontalAngle, 0) * Vector3::forward; return v; }