73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
//// 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 <J3ML/LinearAlgebra/Vector3.hpp>
|
|
#include <J3ML/LinearAlgebra/Forward.hpp>
|
|
|
|
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.
|
|
float angle;
|
|
public:
|
|
/// 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;
|
|
[[nodiscard]] Matrix3x3 ToMatrix3x3() const;
|
|
|
|
/// Returns the axis component of this AxisAngle rotation.
|
|
Vector3 Axis() const;
|
|
float Angle() const;
|
|
|
|
/// Normalize this rotation in-place.
|
|
void Normalize();
|
|
/// Return a normalized copy of this rotation.
|
|
[[nodiscard]] AxisAngle Normalized() const;
|
|
|
|
/// Checks if the rotation is an identity rotation (angle is 0).
|
|
bool IsIdentity();
|
|
|
|
/// Inverts this rotation in-place.
|
|
void Inverse();
|
|
|
|
/// Returns an inverted copy of this rotation.
|
|
[[nodiscard]] AxisAngle Inverted() const;
|
|
|
|
|
|
/// Performs a direct Linear Interpolation on the members of the inputs.
|
|
AxisAngle Lerp(const AxisAngle& rhs, float t);
|
|
|
|
/// Performs a Spherical Linear Interpolation by converting the inputs to Quaternions.
|
|
AxisAngle Slerp(const AxisAngle& rhs, float t);
|
|
|
|
|
|
bool Equals(const AxisAngle& rhs, float epsilon = 1e-3f);
|
|
bool operator == (const AxisAngle& rhs);
|
|
|
|
}; |