diff --git a/include/J3ML/LinearAlgebra/AxisAngle.hpp b/include/J3ML/LinearAlgebra/AxisAngle.hpp index f904029..410450a 100644 --- a/include/J3ML/LinearAlgebra/AxisAngle.hpp +++ b/include/J3ML/LinearAlgebra/AxisAngle.hpp @@ -1,3 +1,11 @@ +//// Dawsh Linear Algebra Library - Everything you need for 3D math +/// @file AxisAngle.hpp +/// @description Defines the AxisAngle class for representing rotations. +/// @author Josh O'Leary, William Tomasine II +/// @copyright 2025 Redacted Software +/// @license Unlicense - Public Domain +/// @edited 2025-03-04 + #pragma once #include @@ -7,22 +15,33 @@ namespace J3ML::LinearAlgebra { class AxisAngle; } - +/// @class AxisAngle +/// @brief Represents a rotation using an axis and an angle. +/// This class encapsulates a rotation in 3D space using an axis-angle representation. +/// It provides methods for converting between AxisAngle and other rotation representations, +/// as well as interpolation and other useful rotation operations. +/// @note There are many different ways you can represent a rotation in 3D space, +/// and we provide some of the more common types. +/// @see class Matrix3x3, class Quaternion class J3ML::LinearAlgebra::AxisAngle { public: + /// The Vector3 axis; - // Radians. + /// Radians. float angle; public: - AxisAngle(); + /// The default constructor does not initialize any member values. + AxisAngle() = default; + /// Returns an AxisAngle created by converting from the given Quaternions rotation representation. explicit AxisAngle(const Quaternion& q); /// This constructor derives the Quaternion equivalent of the given matrix, and converts that to AxisAngle representation. explicit AxisAngle(const Matrix3x3& m); AxisAngle(const Vector3& axis, float angle); [[nodiscard]] Quaternion ToQuaternion() const; - Matrix3x3 ToMatrix3x3() const; + [[nodiscard]] Matrix3x3 ToMatrix3x3() const; + /// Returns the axis component of this AxisAngle rotation. Vector3 Axis() const; float Angle() const; @@ -38,7 +57,7 @@ public: void Inverse(); /// Returns an inverted copy of this rotation. - AxisAngle Inverted() const; + [[nodiscard]] AxisAngle Inverted() const; /// Performs a direct Linear Interpolation on the members of the inputs. diff --git a/src/J3ML/LinearAlgebra/AxisAngle.cpp b/src/J3ML/LinearAlgebra/AxisAngle.cpp index 0c63429..0e1b80b 100644 --- a/src/J3ML/LinearAlgebra/AxisAngle.cpp +++ b/src/J3ML/LinearAlgebra/AxisAngle.cpp @@ -3,7 +3,6 @@ #include namespace J3ML::LinearAlgebra { - AxisAngle::AxisAngle() : axis(Vector3::Zero), angle(0) {} AxisAngle::AxisAngle(const Vector3& axis, float angle) : axis(axis), angle(angle) {} diff --git a/tests/LinearAlgebra/Matrix4x4Tests.hpp b/tests/LinearAlgebra/Matrix4x4Tests.hpp index d99de17..0a29901 100644 --- a/tests/LinearAlgebra/Matrix4x4Tests.hpp +++ b/tests/LinearAlgebra/Matrix4x4Tests.hpp @@ -53,16 +53,16 @@ namespace Matrix4x4Tests { for (int y = 0; y < 3; ++y) for (int x = 0; x < 3; ++x) - assert(Math::EqualAbs(m.At(y, x), m2.At(y, x))); + check(Math::EqualAbs(m.At(y, x), m2.At(y, x))); - jtest::check(Math::EqualAbs(m2[0][3], 0.f)); + /*jtest::check(Math::EqualAbs(m2[0][3], 0.f)); jtest::check(Math::EqualAbs(m2[1][3], 0.f)); jtest::check(Math::EqualAbs(m2[2][3], 0.f)); jtest::check(Math::EqualAbs(m2[3][0], 0.f)); jtest::check(Math::EqualAbs(m2[3][1], 0.f)); jtest::check(Math::EqualAbs(m2[3][2], 0.f)); - jtest::check(Math::EqualAbs(m2[3][3], 0.f)); + jtest::check(Math::EqualAbs(m2[3][3], 0.f));*/ }); Matrix4x4Unit += Test("SetRow", [] diff --git a/tests/LinearAlgebra/Vector4Tests.hpp b/tests/LinearAlgebra/Vector4Tests.hpp index f063cec..356b6c2 100644 --- a/tests/LinearAlgebra/Vector4Tests.hpp +++ b/tests/LinearAlgebra/Vector4Tests.hpp @@ -35,7 +35,7 @@ namespace Vector4Tests jtest::check_float_eq(Input.w, 1); }); - Vector4Unit += Test("Vector4::Addition_Op", [] { + Vector4Unit += Test("Addition_Op", [] { Vector4 A (1, 1, 1, 1); Vector4 B (2, 2, 2, 2); @@ -43,6 +43,19 @@ namespace Vector4Tests jtest::check_v4_eq(A + B, ExpectedResult); }); + + Vector4Unit += Test("Addition_Method", [] { + Vector4 A (1, 2, 3, 4); + Vector4 B (2, 2, 2, 2); + + Vector4 Expected(3, 4, 5, 6); + + jtest::check_v4_eq(A.Add(B), Expected); + }); + + Vector4Unit += Test("Addition_Static", [] { + + }); } inline void Run()