Adding code x3
This commit is contained in:
@@ -47,4 +47,6 @@ EulerAngle EulerAngle::movementAngle() const
|
||||
a.roll = (sin(Math::Radians(yaw)) * cos(Math::Radians(pitch)));
|
||||
return a;
|
||||
}
|
||||
|
||||
EulerAngle::EulerAngle() : pitch(0), yaw(0), roll(0) {}
|
||||
}
|
@@ -135,11 +135,34 @@ namespace LinearAlgebra {
|
||||
y*reciprocalSinAngle,
|
||||
z*reciprocalSinAngle
|
||||
};
|
||||
return {axis, angle};
|
||||
return AxisAngle(axis, angle);
|
||||
}
|
||||
|
||||
float Quaternion::AngleBetween(const Quaternion &target) const {
|
||||
Quaternion delta = target / *this;
|
||||
return delta.Normalize().Angle();
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator/(const Quaternion &rhs) const {
|
||||
return {
|
||||
x*rhs.w - y*rhs.z + z*rhs.y - w*rhs.x,
|
||||
x*rhs.z + y*rhs.w - z*rhs.x - w*rhs.y,
|
||||
-x*rhs.y + y*rhs.x + z*rhs.w - w*rhs.z,
|
||||
x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w
|
||||
};
|
||||
}
|
||||
|
||||
Matrix3x3 Quaternion::ToMatrix3x3() const {
|
||||
return {
|
||||
1 - 2 *(y*y) - 2*(z*z), 2*x*y - 2*z*w, 2*x*z + 2*y*w,
|
||||
2*x*y + 2*z*w, 1-2*x*x - 2*z*z, 2*y*z - 2*x*w,
|
||||
2*x*z - 2*y*w, 2*y*z + 2*x*w, 1-2*x*x - 2*y*y
|
||||
};
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator+(const Quaternion &rhs) const {
|
||||
return {
|
||||
x + rhs.x, y + rhs.y, z + rhs.z,w + rhs.w
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
|
||||
#pragma region vector4
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -131,6 +134,11 @@ Vector4 Vector4::operator-(const Vector4& rhs) const
|
||||
return this->Distance(rhs) <= margin;
|
||||
}
|
||||
|
||||
Vector4::Vector4(const Vector3 &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#pragma endregion
|
Reference in New Issue
Block a user