39 lines
1016 B
C++
39 lines
1016 B
C++
// 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 <math.h>
|
|
|
|
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.Right(), v.Forward()) * Angle::Rad2Deg;
|
|
this->verticalAngle = 90 - acosf(v.Up()) * 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;
|
|
} |