Added row-wise constructor to matrix types

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-02 12:53:16 +01:00
1 親 c4908ba85b
コミット 9dd4023f4a
2ファイル変更
+207 -1

検索条件に一致するファイルはありません

+171
ファイルの表示
@@ -474,6 +474,19 @@ namespace ComputeSharp
this.m22 = m22;
}
/// <summary>
/// Creates a new <see cref="Float2x2"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
public Float2x2(Float2 row1, Float2 row2)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m21 = row2.X;
this.m22 = row2.Y;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float2x2"/> instance.
/// </summary>
@@ -580,6 +593,21 @@ namespace ComputeSharp
this.m23 = m23;
}
/// <summary>
/// Creates a new <see cref="Float2x3"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
public Float2x3(Float3 row1, Float3 row2)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float2x3"/> instance.
/// </summary>
@@ -696,6 +724,23 @@ namespace ComputeSharp
this.m24 = m24;
}
/// <summary>
/// Creates a new <see cref="Float2x4"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
public Float2x4(Float4 row1, Float4 row2)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m14 = row1.W;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
this.m24 = row2.W;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float2x4"/> instance.
/// </summary>
@@ -893,6 +938,22 @@ namespace ComputeSharp
this.m32 = m32;
}
/// <summary>
/// Creates a new <see cref="Float3x2"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
public Float3x2(Float2 row1, Float2 row2, Float2 row3)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m31 = row3.X;
this.m32 = row3.Y;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float3x2"/> instance.
/// </summary>
@@ -1014,6 +1075,25 @@ namespace ComputeSharp
this.m33 = m33;
}
/// <summary>
/// Creates a new <see cref="Float3x3"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
public Float3x3(Float3 row1, Float3 row2, Float3 row3)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
this.m31 = row3.X;
this.m32 = row3.Y;
this.m33 = row3.Z;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float3x3"/> instance.
/// </summary>
@@ -1150,6 +1230,28 @@ namespace ComputeSharp
this.m34 = m34;
}
/// <summary>
/// Creates a new <see cref="Float3x4"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
public Float3x4(Float4 row1, Float4 row2, Float4 row3)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m14 = row1.W;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
this.m24 = row2.W;
this.m31 = row3.X;
this.m32 = row3.Y;
this.m33 = row3.Z;
this.m34 = row3.W;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float3x4"/> instance.
/// </summary>
@@ -1362,6 +1464,25 @@ namespace ComputeSharp
this.m42 = m42;
}
/// <summary>
/// Creates a new <see cref="Float4x2"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
/// <param name="row4">The value to assign to the row at position [4].</param>
public Float4x2(Float2 row1, Float2 row2, Float2 row3, Float2 row4)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m31 = row3.X;
this.m32 = row3.Y;
this.m41 = row4.X;
this.m42 = row4.Y;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float4x2"/> instance.
/// </summary>
@@ -1498,6 +1619,29 @@ namespace ComputeSharp
this.m43 = m43;
}
/// <summary>
/// Creates a new <see cref="Float4x3"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
/// <param name="row4">The value to assign to the row at position [4].</param>
public Float4x3(Float3 row1, Float3 row2, Float3 row3, Float3 row4)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
this.m31 = row3.X;
this.m32 = row3.Y;
this.m33 = row3.Z;
this.m41 = row4.X;
this.m42 = row4.Y;
this.m43 = row4.Z;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float4x3"/> instance.
/// </summary>
@@ -1654,6 +1798,33 @@ namespace ComputeSharp
this.m44 = m44;
}
/// <summary>
/// Creates a new <see cref="Float4x4"/> instance with the specified parameters.
/// </summary>
/// <param name="row1">The value to assign to the row at position [1].</param>
/// <param name="row2">The value to assign to the row at position [2].</param>
/// <param name="row3">The value to assign to the row at position [3].</param>
/// <param name="row4">The value to assign to the row at position [4].</param>
public Float4x4(Float4 row1, Float4 row2, Float4 row3, Float4 row4)
{
this.m11 = row1.X;
this.m12 = row1.Y;
this.m13 = row1.Z;
this.m14 = row1.W;
this.m21 = row2.X;
this.m22 = row2.Y;
this.m23 = row2.Z;
this.m24 = row2.W;
this.m31 = row3.X;
this.m32 = row3.Y;
this.m33 = row3.Z;
this.m34 = row3.W;
this.m41 = row4.X;
this.m42 = row4.Y;
this.m43 = row4.Z;
this.m44 = row4.W;
}
/// <summary>
/// Gets a reference to a specific row in the current <see cref="Float4x4"/> instance.
/// </summary>
+36 -1
ファイルの表示
@@ -55,7 +55,7 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
fieldNames.Add($"m{i}{j}");
}
// Generate the constructors
// Generate the elementwise constructor
WriteLine("/// <summary>");
WriteLine($"/// Creates a new <see cref=\"{fullTypeName}\"/> instance with the specified parameters.");
WriteLine("/// </summary>");
@@ -79,6 +79,41 @@ void GenerateMatrixProperties(string typeName, int rows, int columns, int elemen
WriteLine("}");
WriteLine("");
// Generate the row-wise constructor, if needed
if (rows > 1 && columns > 1)
{
WriteLine("/// <summary>");
WriteLine($"/// Creates a new <see cref=\"{fullTypeName}\"/> instance with the specified parameters.");
WriteLine("/// </summary>");
for (int i = 1; i <= rows; i++)
{
WriteLine($"/// <param name=\"row{i}\">The value to assign to the row at position [{i}].</param>");
}
Write($"public {fullTypeName}(");
for (int i = 1; i <= rows; i++)
{
if (i > 1) Write(", ");
Write($"{rowTypeName} row{i}");
}
WriteLine(")");
WriteLine("{");
PushIndent(" ");
for (int i = 1; i <= rows; i++)
for (int j = 1; j <= columns; j++)
{
WriteLine($"this.m{i}{j} = row{i}.{"XYZW"[j - 1]};");
}
PopIndent();
WriteLine("}");
WriteLine("");
}
PopIndent();
PopIndent();
#>