Added Quaternion constructors, SetFrom(AxisAngle)
Some checks failed
Build Docs With Doxygen / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Build Docs With Doxygen / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
@@ -38,10 +38,13 @@ namespace J3ML::LinearAlgebra
|
||||
//void Inverse();
|
||||
|
||||
explicit Quaternion(Vector4 vector4);
|
||||
explicit Quaternion(const EulerAngle& angle);
|
||||
explicit Quaternion(const AxisAngle& angle);
|
||||
|
||||
void SetFromAxisAngle(const Vector3 &vector3, float between);
|
||||
|
||||
void SetFromAxisAngle(const Vector4 &vector4, float between);
|
||||
void SetFrom(const AxisAngle& angle);
|
||||
|
||||
Quaternion Inverse() const;
|
||||
|
||||
@@ -58,6 +61,22 @@ namespace J3ML::LinearAlgebra
|
||||
|
||||
float GetAngle() const;
|
||||
|
||||
EulerAngle ToEulerAngle() const
|
||||
{
|
||||
// roll (x-axis rotation)
|
||||
double sinr_cosp = 2 * (w * x + y * z);
|
||||
double cosr_cosp = 1 - 2 * (x * x + y * y);
|
||||
|
||||
// pitch (y-axis rotation)
|
||||
double sinp = std::sqrt(1 + 2 * (w * y - x * z));
|
||||
double
|
||||
|
||||
return {
|
||||
.roll = std::atan2(sinr_cosp, cosr_cosp),
|
||||
.pitch =
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Matrix3x3 ToMatrix3x3() const;
|
||||
|
||||
|
Reference in New Issue
Block a user