Math::Matrix3 struct

A 3x3 matrix.

Public static functions

static auto FromEuler(const Vector3& angles) -> Matrix3
Builds a 3x3 rotation matrix equivalent to the euler angles provided.
static auto FromAxisAngle(const Vector3& axis, float angle) -> Matrix3
Builds a 3x3 rotation matrix that rotates angle radians around the given axis.
static auto LookAt(const Vector3& position, const Vector3& target, const Vector3& up = Z_AXIS) -> Matrix3
Builds a rotation matrix that can be used in cameras, for a camera at position looking towards target.

Constructors, destructors, conversion operators

Matrix3()
Matrix3(const Matrix3& other)

Public functions

auto Row(int index) const -> Vector3
auto Column(int index) const -> Vector3
auto SetIdentity() -> Matrix3&
Turns this matrix into the identity matrix (1.0s in the diagonal, everything else 0.0s).
auto ToEuler() const -> Vector3
Returns the euler angles (in radians) equivalent to the rotation of this matrix.
auto ToQuaternion() const -> Quaternion
Returns a Quaternion that represents the same rotation as this matrix.
auto Transposed() const -> Matrix3
Returns the transpose of this matrix, switching the rows and columns. transposed[i][j] = matrix[j][i]

Public variables

float m

Function documentation

static Matrix3 Math::Matrix3::FromEuler(const Vector3& angles)

Builds a 3x3 rotation matrix equivalent to the euler angles provided.

Parameters
angles The euler angles, in radians.

The euler angles must be in radians, and each value represents the rotation around the X, Y and Z axes respectively.

static Matrix3 Math::Matrix3::FromAxisAngle(const Vector3& axis, float angle)

Builds a 3x3 rotation matrix that rotates angle radians around the given axis.

Parameters
axis The axis of rotation, which stays fixed.
angle The angle, in radians.

This is equivalent to Quaternion::FromRotation(axis, angle).ToMatrix().

static Matrix3 Math::Matrix3::LookAt(const Vector3& position, const Vector3& target, const Vector3& up = Z_AXIS)

Builds a rotation matrix that can be used in cameras, for a camera at position looking towards target.

Parameters
position The "eye" position
target The position where the "eye" is looking at
up [Optional] The up vector, Z axis by default.

Optionally, the vector that represents the up direction in the world (which usually is the Z axis) can be specified.

This method might give unexpected results if target and position are aligned.

Matrix3& Math::Matrix3::SetIdentity()

Turns this matrix into the identity matrix (1.0s in the diagonal, everything else 0.0s).

Multiplying a matrix/vector with an identity matrix has no effect.

Vector3 Math::Matrix3::ToEuler() const

Returns the euler angles (in radians) equivalent to the rotation of this matrix.

The euler angles are a vector of 3 values that represent the rotation around the X, Y and Z axes respectively.