Skip to content

Commit 7efc1eb

Browse files
authored
Merge pull request #3 from otac0n/feature/math-3.0
Sync latest
2 parents 4f74ab3 + 16e68e2 commit 7efc1eb

31 files changed

Lines changed: 902 additions & 351 deletions

sources/Maths/Maths/Matrix2x2F.gen.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x2F<T> : IEquatable<Matrix2x2F<T>> where T : IFloatingPointIeee754<T>
6+
partial struct Matrix2x2F<T> :
7+
IEquatable<Matrix2x2F<T>>
8+
where T : IFloatingPointIeee754<T>
79
{
810
/// <summary>The multiplicative identity matrix of size 2x2.</summary>
911
public static readonly Matrix2x2F<T> Identity = new(
@@ -39,7 +41,7 @@ public ref Vector2F<T> this[int row]
3941
}
4042

4143
[UnscopedRef]
42-
public ref Vector2F<T> this[int row, int column] => ref this[row][column];
44+
public ref T this[int row, int column] => ref this[row][column];
4345

4446
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4547
[UnscopedRef]
@@ -69,7 +71,7 @@ public ref Vector2F<T> this[int row]
6971
/// <summary>Computes the transpose of the matrix.</summary>
7072
public Matrix2x2F<T> Transpose() =>
7173
new(new(M11, M21),
72-
new(M12, M22))
74+
new(M12, M22));
7375

7476
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
7577
/// <param name="left">The first matrix to compare.</param>
@@ -116,4 +118,12 @@ public Matrix2x2F<T> Transpose() =>
116118
new(left.M11 * right.Row1 + left.M12 * right.Row2,
117119
left.M21 * right.Row1 + left.M22 * right.Row2);
118120
}
121+
122+
static partial class Matrix2x2F
123+
{
124+
public static Matrix2x2F<T> Lerp<T>(Matrix2x2F<T> value1, Matrix2x2F<T> value2, T amount)
125+
where T : IFloatingPointIeee754<T> =>
126+
new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)),
127+
new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)));
128+
}
119129
}

sources/Maths/Maths/Matrix2x2I.gen.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x2I<T> : IEquatable<Matrix2x2I<T>> where T : IBinaryInteger<T>
6+
partial struct Matrix2x2I<T> :
7+
IEquatable<Matrix2x2I<T>>
8+
where T : IBinaryInteger<T>
79
{
810
/// <summary>The multiplicative identity matrix of size 2x2.</summary>
911
public static readonly Matrix2x2I<T> Identity = new(
@@ -39,7 +41,7 @@ public ref Vector2I<T> this[int row]
3941
}
4042

4143
[UnscopedRef]
42-
public ref Vector2I<T> this[int row, int column] => ref this[row][column];
44+
public ref T this[int row, int column] => ref this[row][column];
4345

4446
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4547
[UnscopedRef]
@@ -69,7 +71,7 @@ public ref Vector2I<T> this[int row]
6971
/// <summary>Computes the transpose of the matrix.</summary>
7072
public Matrix2x2I<T> Transpose() =>
7173
new(new(M11, M21),
72-
new(M12, M22))
74+
new(M12, M22));
7375

7476
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
7577
/// <param name="left">The first matrix to compare.</param>
@@ -116,4 +118,5 @@ public Matrix2x2I<T> Transpose() =>
116118
new(left.M11 * right.Row1 + left.M12 * right.Row2,
117119
left.M21 * right.Row1 + left.M22 * right.Row2);
118120
}
121+
119122
}

sources/Maths/Maths/Matrix2x3F.gen.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x3F<T> : IEquatable<Matrix2x3F<T>> where T : IFloatingPointIeee754<T>
6+
partial struct Matrix2x3F<T> :
7+
IEquatable<Matrix2x3F<T>>
8+
where T : IFloatingPointIeee754<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector3F<T> Row1;
@@ -34,7 +36,7 @@ public ref Vector3F<T> this[int row]
3436
}
3537

3638
[UnscopedRef]
37-
public ref Vector3F<T> this[int row, int column] => ref this[row][column];
39+
public ref T this[int row, int column] => ref this[row][column];
3840

3941
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4042
[UnscopedRef]
@@ -73,7 +75,7 @@ public ref Vector3F<T> this[int row]
7375
public Matrix3x2F<T> Transpose() =>
7476
new(new(M11, M21),
7577
new(M12, M22),
76-
new(M13, M23))
78+
new(M13, M23));
7779

7880
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
7981
/// <param name="left">The first matrix to compare.</param>
@@ -128,4 +130,12 @@ public Matrix3x2F<T> Transpose() =>
128130
new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3,
129131
left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3);
130132
}
133+
134+
static partial class Matrix2x3F
135+
{
136+
public static Matrix2x3F<T> Lerp<T>(Matrix2x3F<T> value1, Matrix2x3F<T> value2, T amount)
137+
where T : IFloatingPointIeee754<T> =>
138+
new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)),
139+
new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)));
140+
}
131141
}

sources/Maths/Maths/Matrix2x3I.gen.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x3I<T> : IEquatable<Matrix2x3I<T>> where T : IBinaryInteger<T>
6+
partial struct Matrix2x3I<T> :
7+
IEquatable<Matrix2x3I<T>>
8+
where T : IBinaryInteger<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector3I<T> Row1;
@@ -34,7 +36,7 @@ public ref Vector3I<T> this[int row]
3436
}
3537

3638
[UnscopedRef]
37-
public ref Vector3I<T> this[int row, int column] => ref this[row][column];
39+
public ref T this[int row, int column] => ref this[row][column];
3840

3941
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4042
[UnscopedRef]
@@ -73,7 +75,7 @@ public ref Vector3I<T> this[int row]
7375
public Matrix3x2I<T> Transpose() =>
7476
new(new(M11, M21),
7577
new(M12, M22),
76-
new(M13, M23))
78+
new(M13, M23));
7779

7880
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
7981
/// <param name="left">The first matrix to compare.</param>
@@ -128,4 +130,5 @@ public Matrix3x2I<T> Transpose() =>
128130
new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3,
129131
left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3);
130132
}
133+
131134
}

sources/Maths/Maths/Matrix2x4F.gen.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x4F<T> : IEquatable<Matrix2x4F<T>> where T : IFloatingPointIeee754<T>
6+
partial struct Matrix2x4F<T> :
7+
IEquatable<Matrix2x4F<T>>
8+
where T : IFloatingPointIeee754<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector4F<T> Row1;
@@ -34,7 +36,7 @@ public ref Vector4F<T> this[int row]
3436
}
3537

3638
[UnscopedRef]
37-
public ref Vector4F<T> this[int row, int column] => ref this[row][column];
39+
public ref T this[int row, int column] => ref this[row][column];
3840

3941
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4042
[UnscopedRef]
@@ -82,7 +84,7 @@ public Matrix4x2F<T> Transpose() =>
8284
new(new(M11, M21),
8385
new(M12, M22),
8486
new(M13, M23),
85-
new(M14, M24))
87+
new(M14, M24));
8688

8789
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
8890
/// <param name="left">The first matrix to compare.</param>
@@ -146,4 +148,12 @@ public Matrix4x2F<T> Transpose() =>
146148
left.M21 * right.Row1 + left.M22 * right.Row2,
147149
left.M31 * right.Row1 + left.M32 * right.Row2);
148150
}
151+
152+
static partial class Matrix2x4F
153+
{
154+
public static Matrix2x4F<T> Lerp<T>(Matrix2x4F<T> value1, Matrix2x4F<T> value2, T amount)
155+
where T : IFloatingPointIeee754<T> =>
156+
new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)),
157+
new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)));
158+
}
149159
}

sources/Maths/Maths/Matrix2x4I.gen.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix2x4I<T> : IEquatable<Matrix2x4I<T>> where T : IBinaryInteger<T>
6+
partial struct Matrix2x4I<T> :
7+
IEquatable<Matrix2x4I<T>>
8+
where T : IBinaryInteger<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector4I<T> Row1;
@@ -34,7 +36,7 @@ public ref Vector4I<T> this[int row]
3436
}
3537

3638
[UnscopedRef]
37-
public ref Vector4I<T> this[int row, int column] => ref this[row][column];
39+
public ref T this[int row, int column] => ref this[row][column];
3840

3941
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4042
[UnscopedRef]
@@ -82,7 +84,7 @@ public Matrix4x2I<T> Transpose() =>
8284
new(new(M11, M21),
8385
new(M12, M22),
8486
new(M13, M23),
85-
new(M14, M24))
87+
new(M14, M24));
8688

8789
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
8890
/// <param name="left">The first matrix to compare.</param>
@@ -146,4 +148,5 @@ public Matrix4x2I<T> Transpose() =>
146148
left.M21 * right.Row1 + left.M22 * right.Row2,
147149
left.M31 * right.Row1 + left.M32 * right.Row2);
148150
}
151+
149152
}

sources/Maths/Maths/Matrix3x2F.gen.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix3x2F<T> : IEquatable<Matrix3x2F<T>> where T : IFloatingPointIeee754<T>
6+
partial struct Matrix3x2F<T> :
7+
IEquatable<Matrix3x2F<T>>
8+
where T : IFloatingPointIeee754<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector2F<T> Row1;
@@ -39,7 +41,7 @@ public ref Vector2F<T> this[int row]
3941
}
4042

4143
[UnscopedRef]
42-
public ref Vector2F<T> this[int row, int column] => ref this[row][column];
44+
public ref T this[int row, int column] => ref this[row][column];
4345

4446
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4547
[UnscopedRef]
@@ -77,7 +79,7 @@ public ref Vector2F<T> this[int row]
7779
/// <summary>Computes the transpose of the matrix.</summary>
7880
public Matrix2x3F<T> Transpose() =>
7981
new(new(M11, M21, M31),
80-
new(M12, M22, M32))
82+
new(M12, M22, M32));
8183

8284
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
8385
/// <param name="left">The first matrix to compare.</param>
@@ -138,4 +140,13 @@ public Matrix2x3F<T> Transpose() =>
138140
left.M21 * right.Row1 + left.M22 * right.Row2,
139141
left.M31 * right.Row1 + left.M32 * right.Row2);
140142
}
143+
144+
static partial class Matrix3x2F
145+
{
146+
public static Matrix3x2F<T> Lerp<T>(Matrix3x2F<T> value1, Matrix3x2F<T> value2, T amount)
147+
where T : IFloatingPointIeee754<T> =>
148+
new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)),
149+
new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)),
150+
new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount)));
151+
}
141152
}

sources/Maths/Maths/Matrix3x2I.gen.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix3x2I<T> : IEquatable<Matrix3x2I<T>> where T : IBinaryInteger<T>
6+
partial struct Matrix3x2I<T> :
7+
IEquatable<Matrix3x2I<T>>
8+
where T : IBinaryInteger<T>
79
{
810
/// <summary>The 1st row of the matrix represented as a vector.</summary>
911
public Vector2I<T> Row1;
@@ -39,7 +41,7 @@ public ref Vector2I<T> this[int row]
3941
}
4042

4143
[UnscopedRef]
42-
public ref Vector2I<T> this[int row, int column] => ref this[row][column];
44+
public ref T this[int row, int column] => ref this[row][column];
4345

4446
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
4547
[UnscopedRef]
@@ -77,7 +79,7 @@ public ref Vector2I<T> this[int row]
7779
/// <summary>Computes the transpose of the matrix.</summary>
7880
public Matrix2x3I<T> Transpose() =>
7981
new(new(M11, M21, M31),
80-
new(M12, M22, M32))
82+
new(M12, M22, M32));
8183

8284
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
8385
/// <param name="left">The first matrix to compare.</param>
@@ -138,4 +140,5 @@ public Matrix2x3I<T> Transpose() =>
138140
left.M21 * right.Row1 + left.M22 * right.Row2,
139141
left.M31 * right.Row1 + left.M32 * right.Row2);
140142
}
143+
141144
}

sources/Maths/Maths/Matrix3x3F.gen.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix3x3F<T> : IEquatable<Matrix3x3F<T>> where T : IFloatingPointIeee754<T>
6+
partial struct Matrix3x3F<T> :
7+
IEquatable<Matrix3x3F<T>>
8+
where T : IFloatingPointIeee754<T>
79
{
810
/// <summary>The multiplicative identity matrix of size 3x3.</summary>
911
public static readonly Matrix3x3F<T> Identity = new(
@@ -45,7 +47,7 @@ public ref Vector3F<T> this[int row]
4547
}
4648

4749
[UnscopedRef]
48-
public ref Vector3F<T> this[int row, int column] => ref this[row][column];
50+
public ref T this[int row, int column] => ref this[row][column];
4951

5052
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
5153
[UnscopedRef]
@@ -96,7 +98,7 @@ public ref Vector3F<T> this[int row]
9698
public Matrix3x3F<T> Transpose() =>
9799
new(new(M11, M21, M31),
98100
new(M12, M22, M32),
99-
new(M13, M23, M33))
101+
new(M13, M23, M33));
100102

101103
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
102104
/// <param name="left">The first matrix to compare.</param>
@@ -165,4 +167,13 @@ public Matrix3x3F<T> Transpose() =>
165167
left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3,
166168
left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3);
167169
}
170+
171+
static partial class Matrix3x3F
172+
{
173+
public static Matrix3x3F<T> Lerp<T>(Matrix3x3F<T> value1, Matrix3x3F<T> value2, T amount)
174+
where T : IFloatingPointIeee754<T> =>
175+
new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)),
176+
new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)),
177+
new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount)));
178+
}
168179
}

sources/Maths/Maths/Matrix3x3I.gen.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ namespace Silk.NET.Maths
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
55

6-
partial struct Matrix3x3I<T> : IEquatable<Matrix3x3I<T>> where T : IBinaryInteger<T>
6+
partial struct Matrix3x3I<T> :
7+
IEquatable<Matrix3x3I<T>>
8+
where T : IBinaryInteger<T>
79
{
810
/// <summary>The multiplicative identity matrix of size 3x3.</summary>
911
public static readonly Matrix3x3I<T> Identity = new(
@@ -45,7 +47,7 @@ public ref Vector3I<T> this[int row]
4547
}
4648

4749
[UnscopedRef]
48-
public ref Vector3I<T> this[int row, int column] => ref this[row][column];
50+
public ref T this[int row, int column] => ref this[row][column];
4951

5052
/// <summary>Gets the element in the 1st row and 1st column of the matrix.</summary>
5153
[UnscopedRef]
@@ -96,7 +98,7 @@ public ref Vector3I<T> this[int row]
9698
public Matrix3x3I<T> Transpose() =>
9799
new(new(M11, M21, M31),
98100
new(M12, M22, M32),
99-
new(M13, M23, M33))
101+
new(M13, M23, M33));
100102

101103
/// <summary>Returns a boolean indicating whether the given two matrices are equal.</summary>
102104
/// <param name="left">The first matrix to compare.</param>
@@ -165,4 +167,5 @@ public Matrix3x3I<T> Transpose() =>
165167
left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3,
166168
left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3);
167169
}
170+
168171
}

0 commit comments

Comments
 (0)