mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptCore: matrix generator
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of boolean values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(bool), 2, 2, "bool")]
|
||||
[MatrixLogic]
|
||||
public partial struct bool2x2
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of boolean values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(bool), 3, 3, "bool")]
|
||||
[MatrixLogic]
|
||||
public partial struct bool3x3
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of boolean values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(bool), 4, 4, "bool")]
|
||||
[MatrixLogic]
|
||||
public partial struct bool4x4
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of double-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(double), 2, 2, "double")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixVectorMultiplication(typeof(double2))]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct double2x2
|
||||
{
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly double2x2 Zero = new(0.0);
|
||||
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly double2x2 One = new(1.0);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 2x2 matrix.
|
||||
/// </summary>
|
||||
public static readonly double2x2 Identity = new(
|
||||
1.0, 0.0,
|
||||
0.0, 1.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of double-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(double), 3, 3, "double")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixVectorMultiplication(typeof(double3))]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct double3x3
|
||||
{
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly double3x3 Zero = new(0.0);
|
||||
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly double3x3 One = new(1.0);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 3x3 matrix.
|
||||
/// </summary>
|
||||
public static readonly double3x3 Identity = new(
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of double-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(double), 4, 4, "double")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixVectorMultiplication(typeof(double4))]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct double4x4
|
||||
{
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly double4x4 Zero = new(0.0);
|
||||
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly double4x4 One = new(1.0);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 4x4 matrix.
|
||||
/// </summary>
|
||||
public static readonly double4x4 Identity = new(
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of single-precision floating-point values.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The matrix is stored in a column-major order.
|
||||
/// The positions of the elements is the following:
|
||||
/// <table>
|
||||
/// <tr>
|
||||
/// <td>M11</td> <td>M12</td>
|
||||
/// </tr>
|
||||
/// <tr>
|
||||
/// <td>M21</td> <td>M22</td>
|
||||
/// </tr>
|
||||
/// </table>
|
||||
/// The memory order is M11, M21, M12, M22.
|
||||
/// </remarks>
|
||||
[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
|
||||
{
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly float2x2 Zero = new(0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly float2x2 One = new(1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 2x2 matrix.
|
||||
/// </summary>
|
||||
public static readonly float2x2 Identity = new(
|
||||
1.0f, 0.0f,
|
||||
0.0f, 1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new 2x2 matrix that represents a rotation by a specified angle.
|
||||
/// </summary>
|
||||
/// <param name="angle">The angle of rotation.</param>
|
||||
/// <returns>The matrix representing the rotation.</returns>
|
||||
public static float2x2 Rotation(float angle)
|
||||
{
|
||||
float cos = Math.cos(angle);
|
||||
float sin = Math.sin(angle);
|
||||
|
||||
return new float2x2(cos, -sin, sin, cos);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of single-precision floating-point values.
|
||||
/// </summary>
|
||||
[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
|
||||
{
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly float3x3 Zero = new(0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly float3x3 One = new(1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 3x3 matrix.
|
||||
/// </summary>
|
||||
public static readonly float3x3 Identity = new(
|
||||
1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of single-precision floating-point values.
|
||||
/// </summary>
|
||||
[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
|
||||
{
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly float4x4 Zero = new(0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly float4x4 One = new(1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 4x4 matrix.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of half-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(Half), 2, 2, "half")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct half2x2
|
||||
{
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly half2x2 Zero = new((Half)0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 2x2 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly half2x2 One = new((Half)1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 2x2 matrix.
|
||||
/// </summary>
|
||||
public static readonly half2x2 Identity = new(
|
||||
(Half)1.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of half-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(Half), 3, 3, "half")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct half3x3
|
||||
{
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly half3x3 Zero = new((Half)0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 3x3 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly half3x3 One = new((Half)1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 3x3 matrix.
|
||||
/// </summary>
|
||||
public static readonly half3x3 Identity = new(
|
||||
(Half)1.0f, (Half)0.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)1.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)0.0f, (Half)1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of half-precision floating-point values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(Half), 4, 4, "half")]
|
||||
[ComparableMatrix]
|
||||
[MatrixMath]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
public partial struct half4x4
|
||||
{
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to zero.
|
||||
/// </summary>
|
||||
public static readonly half4x4 Zero = new((Half)0.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A 4x4 matrix whose elements are all equal to one.
|
||||
/// </summary>
|
||||
public static readonly half4x4 One = new((Half)1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The identity 4x4 matrix.
|
||||
/// </summary>
|
||||
public static readonly half4x4 Identity = new(
|
||||
(Half)1.0f, (Half)0.0f, (Half)0.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)1.0f, (Half)0.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)0.0f, (Half)1.0f, (Half)0.0f,
|
||||
(Half)0.0f, (Half)0.0f, (Half)0.0f, (Half)1.0f);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of 32-bit signed integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(int), 2, 2, "int")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(uint), true)]
|
||||
public partial struct int2x2
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of 32-bit signed integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(int), 3, 3, "int")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(uint), true)]
|
||||
public partial struct int3x3
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of 32-bit signed integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(int), 4, 4, "int")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(uint), true)]
|
||||
public partial struct int4x4
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using GlitchyEngine.Math.Attributes;
|
||||
|
||||
namespace GlitchyEngine.Math;
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 2 rows and 2 columns of 32-bit unsigned integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(uint), 2, 2, "uint")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(int), true)]
|
||||
public partial struct uint2x2
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 3 rows and 3 columns of 32-bit unsigned integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(uint), 3, 3, "uint")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(int), true)]
|
||||
public partial struct uint3x3
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A matrix with 4 rows and 4 columns of 32-bit unsigned integer values.
|
||||
/// </summary>
|
||||
[Matrix(typeof(uint), 4, 4, "uint")]
|
||||
[MatrixLogic]
|
||||
[MatrixCast(typeof(float), true)]
|
||||
[MatrixCast(typeof(int), true)]
|
||||
public partial struct uint4x4
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user