RoboidControl-cpp/AngleAxis.h
2024-08-06 09:47:48 +02:00

65 lines
1.4 KiB
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/.
#ifndef ANGLEAXIS_H
#define ANGLEAXIS_H
#include "Angle.h"
#include "Direction.h"
#include "Quaternion.h"
namespace Passer {
namespace LinearAlgebra {
template <typename T>
class AngleAxis {
public:
AngleOf<T> angle;
Direction<T> axis;
AngleAxis();
AngleAxis(AngleOf<T> angle, Direction<T> axis);
AngleAxis(float angle, Vector3 axis);
Quaternion ToQuaternion();
Direction<T> GetSwing();
};
template <typename T>
Quaternion AngleAxis<T>::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 <typename T>
AngleAxis<T>::AngleAxis() {
this->angle = Angle();
this->axis = Direction<T>();
}
template <typename T>
AngleAxis<T>::AngleAxis(AngleOf<T> angle, Direction<T> axis) {
this->angle = angle;
this->axis = axis;
}
template <typename T>
AngleAxis<T>::AngleAxis(float angle, Vector3 axis) {
this->angle = AngleOf<T>(angle);
this->axis = Direction<T>(axis);
}
template <typename T>
Direction<T> AngleAxis<T>::GetSwing() {
return this->axis;
}
#endif