mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
8 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
// <auto-generated /> - edit Matrix.access.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public float this[int row, int column]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get
|
||||
{
|
||||
if ((uint)row >= RowCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(row));
|
||||
|
||||
return Unsafe.Add(ref Unsafe.AsRef(in X), row)[column];
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set
|
||||
{
|
||||
if ((uint)row >= RowCount)
|
||||
throw new ArgumentOutOfRangeException(nameof(row));
|
||||
|
||||
Unsafe.Add(ref X, row)[column] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly void Deconstruct(out float2 x, out float2 y, out float2 z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
public Span<float> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<float3x2, float>(ref this), 6);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<float> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<float3x2, float>(ref Unsafe.AsRef(in this)), 6);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
// <auto-generated /> - edit Matrix.equality.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
/// <inheritdoc cref="Matrix3x2.Equals(object?)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is float3x2 other && Equals(other);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Equals(Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(float3x2 other)
|
||||
{
|
||||
// This function needs to account for floating-point equality around NaN
|
||||
// and so must behave equivalently to the underlying float/float.Equals
|
||||
|
||||
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.GetHashCode()" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X, Y, Z);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// <auto-generated /> - edit Matrix.format.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
return $"{{ X:{X.ToString(format, formatProvider)}, Y:{Y.ToString(format, formatProvider)}, Z:{Z.ToString(format, formatProvider)} }}";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return $"{{ X:{X}, Y:{Y}, Z:{Z} }}";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
// <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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,381 @@
|
|||
// <auto-generated /> - edit Matrix.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
private const float RotationEpsilon = 0.001f * float.Pi / 180f; // 0.1% of a degree
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Translation" />
|
||||
[XmlIgnore]
|
||||
public float2 Translation
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Z;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateRotation(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateRotation(float radians)
|
||||
{
|
||||
radians = float.Ieee754Remainder(radians, float.Pi * 2);
|
||||
|
||||
float c;
|
||||
float s;
|
||||
|
||||
if (radians > -RotationEpsilon && radians < RotationEpsilon)
|
||||
{
|
||||
// Exact case for zero rotation.
|
||||
c = 1;
|
||||
s = 0;
|
||||
}
|
||||
else if (radians > float.Pi / 2 - RotationEpsilon && radians < float.Pi / 2 + RotationEpsilon)
|
||||
{
|
||||
// Exact case for 90 degree rotation.
|
||||
c = 0;
|
||||
s = 1;
|
||||
}
|
||||
else if (radians < -float.Pi + RotationEpsilon || radians > float.Pi - RotationEpsilon)
|
||||
{
|
||||
// Exact case for 180 degree rotation.
|
||||
c = -1;
|
||||
s = 0;
|
||||
}
|
||||
else if (radians > -float.Pi / 2 - RotationEpsilon && radians < -float.Pi / 2 + RotationEpsilon)
|
||||
{
|
||||
// Exact case for 270 degree rotation.
|
||||
c = 0;
|
||||
s = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Arbitrary rotation.
|
||||
(s, c) = float.SinCos(radians);
|
||||
}
|
||||
|
||||
// [ c s ]
|
||||
// [ -s c ]
|
||||
// [ 0 0 ]
|
||||
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(c, s);
|
||||
result.Y = new float2(-s, c);
|
||||
result.Z = float2.Zero;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateRotation(float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateRotation(float radians, float2 centerPoint)
|
||||
{
|
||||
radians = float.Ieee754Remainder(radians, float.Pi * 2);
|
||||
|
||||
float c,
|
||||
s;
|
||||
|
||||
if (radians > -RotationEpsilon && radians < RotationEpsilon)
|
||||
{
|
||||
// Exact case for zero rotation.
|
||||
c = 1;
|
||||
s = 0;
|
||||
}
|
||||
else if (radians > float.Pi / 2 - RotationEpsilon && radians < float.Pi / 2 + RotationEpsilon)
|
||||
{
|
||||
// Exact case for 90 degree rotation.
|
||||
c = 0;
|
||||
s = 1;
|
||||
}
|
||||
else if (radians < -float.Pi + RotationEpsilon || radians > float.Pi - RotationEpsilon)
|
||||
{
|
||||
// Exact case for 180 degree rotation.
|
||||
c = -1;
|
||||
s = 0;
|
||||
}
|
||||
else if (radians > -float.Pi / 2 - RotationEpsilon && radians < -float.Pi / 2 + RotationEpsilon)
|
||||
{
|
||||
// Exact case for 270 degree rotation.
|
||||
c = 0;
|
||||
s = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Arbitrary rotation.
|
||||
(s, c) = float.SinCos(radians);
|
||||
}
|
||||
|
||||
var x = centerPoint.X * (1 - c) + centerPoint.Y * s;
|
||||
var y = centerPoint.Y * (1 - c) - centerPoint.X * s;
|
||||
|
||||
// [ c s ]
|
||||
// [ -s c ]
|
||||
// [ x y ]
|
||||
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(c, s);
|
||||
result.Y = new float2(-s, c);
|
||||
result.Z = new float2(x, y);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float2 scales)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scales.X, 0);
|
||||
result.Y = new float2(0, scales.Y);
|
||||
result.Z = float2.Zero;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float scaleX, float scaleY)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scaleX, 0);
|
||||
result.Y = new float2(0, scaleY);
|
||||
result.Z = float2.Zero;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(float, float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float scaleX, float scaleY, float2 centerPoint)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scaleX, 0);
|
||||
result.Y = new float2(0, scaleY);
|
||||
result.Z = centerPoint * (float2.One - new float2(scaleX, scaleY));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(Vector2, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float2 scales, float2 centerPoint)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scales.X, 0);
|
||||
result.Y = new float2(0, scales.Y);
|
||||
result.Z = centerPoint * (float2.One - scales);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float scale)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scale, 0);
|
||||
result.Y = new float2(0, scale);
|
||||
result.Z = float2.Zero;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateScale(float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateScale(float scale, float2 centerPoint)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(scale, 0);
|
||||
result.Y = new float2(0, scale);
|
||||
result.Z = centerPoint * (float2.One - new float2(scale));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateSkew(float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateSkew(float radiansX, float radiansY)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(1, float.Tan(radiansY));
|
||||
result.Y = new float2(float.Tan(radiansX), 1);
|
||||
result.Z = float2.Zero;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateSkew(float, float, Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateSkew(float radiansX, float radiansY, float2 centerPoint)
|
||||
{
|
||||
var xTan = float.Tan(radiansX);
|
||||
var yTan = float.Tan(radiansY);
|
||||
|
||||
var tx = -centerPoint.Y * xTan;
|
||||
var ty = -centerPoint.X * yTan;
|
||||
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(1, yTan);
|
||||
result.Y = new float2(xTan, 1);
|
||||
result.Z = new float2(tx, ty);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateTranslation(Vector2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateTranslation(float2 position)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = float2.UnitX;
|
||||
result.Y = float2.UnitY;
|
||||
result.Z = position;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.CreateTranslation(float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 CreateTranslation(float positionX, float positionY)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = float2.UnitX;
|
||||
result.Y = float2.UnitY;
|
||||
result.Z = new float2(positionX, positionY);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Invert(Matrix3x2, out Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool Invert(float3x2 matrix, out float3x2 result)
|
||||
{
|
||||
var det = matrix.X.X * matrix.Y.Y - matrix.Y.X * matrix.X.Y;
|
||||
|
||||
if (float.Abs(det) < float.Epsilon)
|
||||
{
|
||||
var vNaN = new float2(float.NaN);
|
||||
|
||||
result.X = vNaN;
|
||||
result.Y = vNaN;
|
||||
result.Z = vNaN;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var invDet = 1.0f / det;
|
||||
|
||||
result.X = new float2(+matrix.Y.Y * invDet, -matrix.X.Y * invDet);
|
||||
result.Y = new float2(-matrix.Y.X * invDet, +matrix.X.X * invDet);
|
||||
result.Z = new float2(
|
||||
(matrix.Y.X * matrix.Z.Y - matrix.Z.X * matrix.Y.Y) * invDet,
|
||||
(matrix.Z.X * matrix.X.Y - matrix.X.X * matrix.Z.Y) * invDet
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Lerp(Matrix3x2, Matrix3x2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Lerp(float3x2 a, float3x2 b, float amount)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = float2.Lerp(a.X, b.X, amount);
|
||||
result.Y = float2.Lerp(a.Y, b.Y, amount);
|
||||
result.Z = float2.Lerp(a.Z, b.Z, amount);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.GetDeterminant()" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float GetDeterminant()
|
||||
{
|
||||
// There isn't actually any such thing as a determinant for a non-square matrix,
|
||||
// but this 3x2 type is really just an optimization of a 3x3 where we happen to
|
||||
// know the rightmost column is always (0, 0, 1). So we expand to 3x3 format:
|
||||
//
|
||||
// [ X.X, X.Y, 0 ]
|
||||
// [ Y.X, Y.Y, 0 ]
|
||||
// [ Z.X, Z.Y, 1 ]
|
||||
//
|
||||
// Sum the diagonal products:
|
||||
// (X.X * Y.Y * 1) + (X.Y * 0 * Z.X) + (0 * Y.X * Z.Y)
|
||||
//
|
||||
// Subtract the opposite diagonal products:
|
||||
// (Z.X * Y.Y * 0) + (Z.Y * 0 * X.X) + (1 * Y.X * X.Y)
|
||||
//
|
||||
// Collapse out the constants and oh look, this is just a 2x2 determinant!
|
||||
|
||||
return X.X * Y.Y - Y.X * X.Y;
|
||||
}
|
||||
|
||||
/// <summary>Performs matrix multiplication to multiply a matrix by a vector to compute the product.</summary>
|
||||
/// <param name="matrix">The matrix.</param>
|
||||
/// <param name="vector">The vector.</param>
|
||||
/// <returns>The product vector.</returns>
|
||||
/// <remarks>
|
||||
/// The <see cref="Multiply(float3x2, float2)" /> method defines the operation
|
||||
/// of the multiplication operator for <see cref="float3x2" /> objects.
|
||||
/// </remarks>
|
||||
public static float3 Multiply(float3x2 matrix, float2 vector)
|
||||
{
|
||||
float3 result;
|
||||
|
||||
result.X = float2.Dot(matrix.X, vector);
|
||||
result.Y = float2.Dot(matrix.Y, vector);
|
||||
result.Z = float2.Dot(matrix.Z, vector);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Add(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Add(float3x2 a, float3x2 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Multiply(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Multiply(float3x2 a, float3x2 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Multiply(Matrix3x2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Multiply(float3x2 a, float b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Negate(Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Negate(float3x2 value)
|
||||
{
|
||||
return -value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.Subtract(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 Subtract(float3x2 a, float3x2 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
// <auto-generated /> - edit Matrix.operators.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
/// <inheritdoc cref="Matrix3x2.op_Addition(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 operator +(float3x2 left, float3x2 right)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = left.X + right.X;
|
||||
result.Y = left.Y + right.Y;
|
||||
result.Z = left.Z + right.Z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_Equality(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(float3x2 left, float3x2 right)
|
||||
{
|
||||
return left.X == right.X && left.Y == right.Y && left.Z == right.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_Inequality(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(float3x2 left, float3x2 right)
|
||||
{
|
||||
return left.X != right.X || left.Y != right.Y || left.Z != right.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_Multiply(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 operator *(float3x2 left, float3x2 right)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = new float2(
|
||||
left.X.X * right.X.X + left.X.Y * right.Y.X,
|
||||
left.X.X * right.X.Y + left.X.Y * right.Y.Y
|
||||
);
|
||||
result.Y = new float2(
|
||||
left.Y.X * right.X.X + left.Y.Y * right.Y.X,
|
||||
left.Y.X * right.X.Y + left.Y.Y * right.Y.Y
|
||||
);
|
||||
result.Z = new float2(
|
||||
left.Z.X * right.X.X + left.Z.Y * right.Y.X + right.Z.X,
|
||||
left.Z.X * right.X.Y + left.Z.Y * right.Y.Y + right.Z.Y
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Multiply(float3x2, float2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3 operator *(float3x2 matrix, float2 vector)
|
||||
{
|
||||
return Multiply(matrix, vector);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_Multiply(Matrix3x2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 operator *(float3x2 left, float right)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = left.X * right;
|
||||
result.Y = left.Y * right;
|
||||
result.Z = left.Z * right;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_Subtraction(Matrix3x2, Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 operator -(float3x2 left, float3x2 right)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = left.X - right.X;
|
||||
result.Y = left.Y - right.Y;
|
||||
result.Z = left.Z - right.Z;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.op_UnaryNegation(Matrix3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3x2 operator -(float3x2 value)
|
||||
{
|
||||
float3x2 result;
|
||||
|
||||
result.X = -value.X;
|
||||
result.Y = -value.Y;
|
||||
result.Z = -value.Z;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// <auto-generated /> - edit Matrix.pack.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
public static float3x2 Pack(in double3x2 vector, Func<double, float> elementConverter)
|
||||
{
|
||||
MatrixPack.Pack(vector, out float3x2 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void Pack(
|
||||
in ReadOnlySpan<double3x2> source,
|
||||
Span<float3x2> destination,
|
||||
Func<double, float> elementConverter
|
||||
)
|
||||
{
|
||||
MatrixPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static float3x2 Pack(in double3x2 vector)
|
||||
{
|
||||
return Pack(vector, f => (float)f);
|
||||
}
|
||||
|
||||
public static void Pack(in ReadOnlySpan<double3x2> source, Span<float3x2> destination)
|
||||
{
|
||||
Pack(source, destination, f => (float)f);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
// <auto-generated /> - edit Matrix.swizzle.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3x2
|
||||
{
|
||||
/// <inheritdoc cref="Matrix3x2.M11" />
|
||||
[XmlAttribute]
|
||||
public float M11
|
||||
{
|
||||
readonly get => X.X;
|
||||
set => X.X = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.M12" />
|
||||
[XmlAttribute]
|
||||
public float M12
|
||||
{
|
||||
readonly get => X.Y;
|
||||
set => X.Y = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.M21" />
|
||||
[XmlAttribute]
|
||||
public float M21
|
||||
{
|
||||
readonly get => Y.X;
|
||||
set => Y.X = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.M22" />
|
||||
[XmlAttribute]
|
||||
public float M22
|
||||
{
|
||||
readonly get => Y.Y;
|
||||
set => Y.Y = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.M31" />
|
||||
[XmlAttribute]
|
||||
public float M31
|
||||
{
|
||||
readonly get => Z.X;
|
||||
set => Z.X = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Matrix3x2.M32" />
|
||||
[XmlAttribute]
|
||||
public float M32
|
||||
{
|
||||
readonly get => Z.Y;
|
||||
set => Z.Y = value;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue