using System;
using GlitchyEngine.Math.Attributes;
namespace GlitchyEngine.Math;
///
/// A matrix with 2 rows and 2 columns of single-precision floating-point values.
///
///
/// The matrix is stored in a column-major order.
/// The positions of the elements is the following:
///
///
/// | M11 | M12 |
///
///
/// | M21 | M22 |
///
///
/// The memory order is M11, M21, M12, M22.
///
[Matrix(typeof(float), 2, 2, "float")]
[ComparableMatrix]
[MatrixMath]
[MatrixVectorMultiplication(typeof(float2))]
[MatrixCast(typeof(double), true)]
[MatrixCast(typeof(Half), true)]
[MatrixCast(typeof(int), true)]
[MatrixCast(typeof(uint), true)]
public partial struct float2x2
{
///
/// A 2x2 matrix whose elements are all equal to zero.
///
public static readonly float2x2 Zero = new(0.0f);
///
/// A 2x2 matrix whose elements are all equal to one.
///
public static readonly float2x2 One = new(1.0f);
///
/// The identity 2x2 matrix.
///
public static readonly float2x2 Identity = new(
1.0f, 0.0f,
0.0f, 1.0f);
///
/// Creates a new 2x2 matrix that represents a rotation by a specified angle.
///
/// The angle of rotation.
/// The matrix representing the rotation.
public static float2x2 Rotation(float angle)
{
float cos = Math.cos(angle);
float sin = Math.sin(angle);
return new float2x2(cos, -sin, sin, cos);
}
}
///
/// A matrix with 3 rows and 3 columns of single-precision floating-point values.
///
[Matrix(typeof(float), 3, 3, "float")]
[ComparableMatrix]
[MatrixMath]
[MatrixVectorMultiplication(typeof(float3))]
[MatrixCast(typeof(double), true)]
[MatrixCast(typeof(Half), true)]
[MatrixCast(typeof(int), true)]
[MatrixCast(typeof(uint), true)]
public partial struct float3x3
{
///
/// A 3x3 matrix whose elements are all equal to zero.
///
public static readonly float3x3 Zero = new(0.0f);
///
/// A 3x3 matrix whose elements are all equal to one.
///
public static readonly float3x3 One = new(1.0f);
///
/// The identity 3x3 matrix.
///
public static readonly float3x3 Identity = new(
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f);
}
///
/// A matrix with 4 rows and 4 columns of single-precision floating-point values.
///
[Matrix(typeof(float), 4, 4, "float")]
[ComparableMatrix]
[MatrixMath]
[MatrixVectorMultiplication(typeof(float4))]
[MatrixCast(typeof(double), true)]
[MatrixCast(typeof(Half), true)]
[MatrixCast(typeof(int), true)]
[MatrixCast(typeof(uint), true)]
public partial struct float4x4
{
///
/// A 4x4 matrix whose elements are all equal to zero.
///
public static readonly float4x4 Zero = new(0.0f);
///
/// A 4x4 matrix whose elements are all equal to one.
///
public static readonly float4x4 One = new(1.0f);
///
/// The identity 4x4 matrix.
///
public static readonly float4x4 Identity = new(
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}