brutal/Brutal.Numerics/Matrix/float3x2/float3x2.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

93 lines
2.6 KiB
C#

// <auto-generated /> - edit Matrix.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 3x2 matrix with float components.
/// </summary>
[DebuggerTypeProxy(typeof(DebugView))]
public partial struct float3x2 : IMatrix<float3x2, float>
, IFloatingMatrix3x2<float3x2, float, float2, float3>
{
internal class DebugView(float3x2 m)
{
public float2 X => m.X;
public float2 Y => m.Y;
public float2 Z => m.Z;
}
/// <summary>The first row of the matrix.</summary>
[XmlIgnore]
public float2 X;
/// <summary>The second row of the matrix.</summary>
[XmlIgnore]
public float2 Y;
/// <summary>The third row of the matrix.</summary>
[XmlIgnore]
public float2 Z;
/// <inheritdoc cref="Matrix3x2(float, float, float, float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float3x2(
float m11,
float m12,
float m21,
float m22,
float m31,
float m32
)
{
X = new float2(m11, m12);
Y = new float2(m21, m22);
Z = new float2(m31, m32);
}
/// <summary>Creates a matrix from the leading 6 elements of a span, row by row.</summary>
/// <param name="span">The elements to read; must contain at least 6, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 6 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float3x2(ReadOnlySpan<float> span)
{
if (span.Length < 6)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 6.");
this = Unsafe.ReadUnaligned<float3x2>(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(span)));
}
static float3x2 IMatrix<float3x2, float>.Create(ReadOnlySpan<float> span) => new(span);
/// <inheritdoc />
public static float3x2 Identity
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
float3x2 result;
result.X = float2.UnitX;
result.Y = float2.UnitY;
result.Z = float2.Zero;
return result;
}
}
/// <inheritdoc />
public static int ComponentSize => sizeof(float);
/// <inheritdoc />
public static int RowCount => 3;
/// <inheritdoc />
public static int ColumnCount => 2;
/// <inheritdoc cref="Matrix3x2.IsIdentity" />
public readonly bool IsIdentity
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => X == float2.UnitX && Y == float2.UnitY && Z == float2.Zero;
}
}