Исправления в матрицах 2x3 и 3x2 / Several fixes in 2x3 and 3x2 matrixes
This commit is contained in:
parent
3ba55c7524
commit
301cabe8de
22 changed files with 3805 additions and 3744 deletions
|
|
@ -28,7 +28,8 @@ namespace Geometry
|
||||||
public double r2c1, r2c2;
|
public double r2c1, r2c2;
|
||||||
public double r3c1, r3c2;
|
public double r3c1, r3c2;
|
||||||
|
|
||||||
public DPMatrix2x3() {
|
public DPMatrix2x3()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0;
|
this.r1c1 = 0.0;
|
||||||
this.r1c2 = 0.0;
|
this.r1c2 = 0.0;
|
||||||
|
|
||||||
|
|
@ -39,7 +40,8 @@ namespace Geometry
|
||||||
this.r3c2 = 0.0;
|
this.r3c2 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPMatrix2x3(in DPMatrix2x3 matrix) {
|
public DPMatrix2x3(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -50,7 +52,8 @@ namespace Geometry
|
||||||
this.r3c2 = matrix.r3c2;
|
this.r3c2 = matrix.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPMatrix2x3(in SPMatrix2x3 matrix) {
|
public DPMatrix2x3(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -351,22 +354,15 @@ namespace Geometry
|
||||||
|
|
||||||
public static void GetRightProduct(in DPMatrix2x3 matrix, in DPVector2 vector, out DPVector3 result)
|
public static void GetRightProduct(in DPMatrix2x3 matrix, in DPVector2 vector, out DPVector3 result)
|
||||||
{
|
{
|
||||||
double x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||||
double x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||||
double x3 = matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2;
|
result.x3 = matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2;
|
||||||
|
|
||||||
result.x1 = x1;
|
|
||||||
result.x2 = x2;
|
|
||||||
result.x3 = x3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetLeftProduct(in DPVector3 vector, in DPMatrix2x3 matrix, out DPVector2 result)
|
public static void GetLeftProduct(in DPVector3 vector, in DPMatrix2x3 matrix, out DPVector2 result)
|
||||||
{
|
{
|
||||||
double x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||||
double x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||||
|
|
||||||
result.x1 = x1;
|
|
||||||
result.x2 = x2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,9 @@ using System;
|
||||||
*/
|
*/
|
||||||
namespace Geometry
|
namespace Geometry
|
||||||
{
|
{
|
||||||
public struct DPMatrix3x2
|
public struct DPMatrix3x2
|
||||||
{
|
{
|
||||||
|
|
||||||
public double r1c1, r1c2, r1c3;
|
public double r1c1, r1c2, r1c3;
|
||||||
|
|
||||||
public double r2c1, r2c2, r2c3;
|
public double r2c1, r2c2, r2c3;
|
||||||
|
|
||||||
public DPMatrix3x2()
|
public DPMatrix3x2()
|
||||||
|
|
@ -73,7 +71,8 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c2;
|
this.r2c3 = matrix.r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DPMatrix3x2(in SPMatrix2x3 matrix) {
|
public DPMatrix3x2(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r2c1;
|
this.r1c2 = matrix.r2c1;
|
||||||
this.r1c3 = matrix.r3c1;
|
this.r1c3 = matrix.r3c1;
|
||||||
|
|
@ -83,7 +82,8 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c2;
|
this.r2c3 = matrix.r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset() {
|
public void Reset()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0;
|
this.r1c1 = 0.0;
|
||||||
this.r1c2 = 0.0;
|
this.r1c2 = 0.0;
|
||||||
this.r1c3 = 0.0;
|
this.r1c3 = 0.0;
|
||||||
|
|
@ -94,7 +94,8 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetValues(in DPMatrix3x2 matrix) {
|
public void SetValues(in DPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
this.r1c3 = matrix.r1c3;
|
this.r1c3 = matrix.r1c3;
|
||||||
|
|
@ -104,7 +105,8 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c3;
|
this.r2c3 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValues(SPMatrix3x2 matrix) {
|
public void SetValues(in SPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
this.r1c3 = matrix.r1c3;
|
this.r1c3 = matrix.r1c3;
|
||||||
|
|
@ -114,7 +116,8 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c3;
|
this.r2c3 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTransposed(DPMatrix2x3 matrix) {
|
public void SetTransposed(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r2c1;
|
this.r1c2 = matrix.r2c1;
|
||||||
this.r1c3 = matrix.r3c1;
|
this.r1c3 = matrix.r3c1;
|
||||||
|
|
@ -124,7 +127,8 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c2;
|
this.r2c3 = matrix.r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTransposed(SPMatrix2x3 matrix) {
|
public void SetTransposed(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r2c1;
|
this.r1c2 = matrix.r2c1;
|
||||||
this.r1c3 = matrix.r3c1;
|
this.r1c3 = matrix.r3c1;
|
||||||
|
|
@ -134,34 +138,40 @@ public struct DPMatrix3x2
|
||||||
this.r2c3 = matrix.r2c2;
|
this.r2c3 = matrix.r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow1(double c1, double c2, double c3) {
|
public void SetRow1(double c1, double c2, double c3)
|
||||||
|
{
|
||||||
this.r1c1 = c1;
|
this.r1c1 = c1;
|
||||||
this.r1c2 = c2;
|
this.r1c2 = c2;
|
||||||
this.r1c3 = c3;
|
this.r1c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow2(double c1, double c2, double c3) {
|
public void SetRow2(double c1, double c2, double c3)
|
||||||
|
{
|
||||||
this.r2c1 = c1;
|
this.r2c1 = c1;
|
||||||
this.r2c2 = c2;
|
this.r2c2 = c2;
|
||||||
this.r2c3 = c3;
|
this.r2c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn1(double r1, double r2) {
|
public void SetColumn1(double r1, double r2)
|
||||||
|
{
|
||||||
this.r1c1 = r1;
|
this.r1c1 = r1;
|
||||||
this.r2c1 = r2;
|
this.r2c1 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn2(double r1, double r2) {
|
public void SetColumn2(double r1, double r2)
|
||||||
|
{
|
||||||
this.r1c3 = r1;
|
this.r1c3 = r1;
|
||||||
this.r2c3 = r2;
|
this.r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn3(double r1, double r2) {
|
public void SetColumn3(double r1, double r2)
|
||||||
|
{
|
||||||
this.r1c3 = r1;
|
this.r1c3 = r1;
|
||||||
this.r2c3 = r2;
|
this.r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add(DPMatrix3x2 matrix1, DPMatrix3x2 matrix2, DPMatrix3x2 sum) {
|
public static void Add(in DPMatrix3x2 matrix1, in DPMatrix3x2 matrix2, out DPMatrix3x2 sum)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||||
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3;
|
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3;
|
||||||
|
|
@ -172,11 +182,12 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add3(
|
public static void Add3(
|
||||||
DPMatrix3x2 matrix1,
|
in DPMatrix3x2 matrix1,
|
||||||
DPMatrix3x2 matrix2,
|
in DPMatrix3x2 matrix2,
|
||||||
DPMatrix3x2 matrix3,
|
in DPMatrix3x2 matrix3,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
||||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
||||||
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3 + matrix3.r1c3;
|
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3 + matrix3.r1c3;
|
||||||
|
|
@ -187,12 +198,13 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add4(
|
public static void Add4(
|
||||||
DPMatrix3x2 matrix1,
|
in DPMatrix3x2 matrix1,
|
||||||
DPMatrix3x2 matrix2,
|
in DPMatrix3x2 matrix2,
|
||||||
DPMatrix3x2 matrix3,
|
in DPMatrix3x2 matrix3,
|
||||||
DPMatrix3x2 matrix4,
|
in DPMatrix3x2 matrix4,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
||||||
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3);
|
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3);
|
||||||
|
|
@ -203,13 +215,14 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add5(
|
public static void Add5(
|
||||||
DPMatrix3x2 matrix1,
|
in DPMatrix3x2 matrix1,
|
||||||
DPMatrix3x2 matrix2,
|
in DPMatrix3x2 matrix2,
|
||||||
DPMatrix3x2 matrix3,
|
in DPMatrix3x2 matrix3,
|
||||||
DPMatrix3x2 matrix4,
|
in DPMatrix3x2 matrix4,
|
||||||
DPMatrix3x2 matrix5,
|
in DPMatrix3x2 matrix5,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
||||||
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3) + matrix5.r1c3;
|
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3) + matrix5.r1c3;
|
||||||
|
|
@ -219,7 +232,8 @@ public struct DPMatrix3x2
|
||||||
sum.r2c3 = (matrix1.r2c3 + matrix2.r2c3) + (matrix3.r2c3 + matrix4.r2c3) + matrix5.r2c3;
|
sum.r2c3 = (matrix1.r2c3 + matrix2.r2c3) + (matrix3.r2c3 + matrix4.r2c3) + matrix5.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Subtract(DPMatrix3x2 minuend, DPMatrix3x2 subtrahend, DPMatrix3x2 difference) {
|
public static void Subtract(in DPMatrix3x2 minuend, in DPMatrix3x2 subtrahend, out DPMatrix3x2 difference)
|
||||||
|
{
|
||||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||||
difference.r1c3 = minuend.r1c3 - subtrahend.r1c3;
|
difference.r1c3 = minuend.r1c3 - subtrahend.r1c3;
|
||||||
|
|
@ -230,10 +244,11 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum2(
|
public static void GetWeightedSum2(
|
||||||
double weight1, DPMatrix3x2 matrix1,
|
double weight1, in DPMatrix3x2 matrix1,
|
||||||
double weight2, DPMatrix3x2 matrix2,
|
double weight2, in DPMatrix3x2 matrix2,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
||||||
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2;
|
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2;
|
||||||
|
|
@ -244,11 +259,12 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum3(
|
public static void GetWeightedSum3(
|
||||||
double weight1, DPMatrix3x2 matrix1,
|
double weight1, in DPMatrix3x2 matrix1,
|
||||||
double weight2, DPMatrix3x2 matrix2,
|
double weight2, in DPMatrix3x2 matrix2,
|
||||||
double weight3, DPMatrix3x2 matrix3,
|
double weight3, in DPMatrix3x2 matrix3,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
||||||
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2 + matrix3.r1c3 * weight3;
|
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2 + matrix3.r1c3 * weight3;
|
||||||
|
|
@ -259,12 +275,13 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum4(
|
public static void GetWeightedSum4(
|
||||||
double weight1, DPMatrix3x2 matrix1,
|
double weight1, in DPMatrix3x2 matrix1,
|
||||||
double weight2, DPMatrix3x2 matrix2,
|
double weight2, in DPMatrix3x2 matrix2,
|
||||||
double weight3, DPMatrix3x2 matrix3,
|
double weight3, in DPMatrix3x2 matrix3,
|
||||||
double weight4, DPMatrix3x2 matrix4,
|
double weight4, in DPMatrix3x2 matrix4,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
||||||
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4);
|
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4);
|
||||||
|
|
@ -275,13 +292,14 @@ public struct DPMatrix3x2
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum5(
|
public static void GetWeightedSum5(
|
||||||
double weight1, DPMatrix3x2 matrix1,
|
double weight1, in DPMatrix3x2 matrix1,
|
||||||
double weight2, DPMatrix3x2 matrix2,
|
double weight2, in DPMatrix3x2 matrix2,
|
||||||
double weight3, DPMatrix3x2 matrix3,
|
double weight3, in DPMatrix3x2 matrix3,
|
||||||
double weight4, DPMatrix3x2 matrix4,
|
double weight4, in DPMatrix3x2 matrix4,
|
||||||
double weight5, DPMatrix3x2 matrix5,
|
double weight5, in DPMatrix3x2 matrix5,
|
||||||
DPMatrix3x2 sum
|
out DPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
||||||
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4) + matrix5.r1c3 * weight5;
|
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4) + matrix5.r1c3 * weight5;
|
||||||
|
|
@ -291,7 +309,8 @@ public struct DPMatrix3x2
|
||||||
sum.r2c3 = (matrix1.r2c3 * weight1 + matrix2.r2c3 * weight2) + (matrix3.r2c3 * weight3 + matrix4.r2c3 * weight4) + matrix5.r2c3 * weight5;
|
sum.r2c3 = (matrix1.r2c3 * weight1 + matrix2.r2c3 * weight2) + (matrix3.r2c3 * weight3 + matrix4.r2c3 * weight4) + matrix5.r2c3 * weight5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Multiply(DPMatrix3x2 multiplicand, double multiplier, DPMatrix3x2 product) {
|
public static void Multiply(in DPMatrix3x2 multiplicand, double multiplier, out DPMatrix3x2 product)
|
||||||
|
{
|
||||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||||
product.r1c3 = multiplicand.r1c3 * multiplier;
|
product.r1c3 = multiplicand.r1c3 * multiplier;
|
||||||
|
|
@ -301,7 +320,8 @@ public struct DPMatrix3x2
|
||||||
product.r2c3 = multiplicand.r2c3 * multiplier;
|
product.r2c3 = multiplicand.r2c3 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Divide(DPMatrix3x2 dividend, double divisor, DPMatrix3x2 quotient) {
|
public static void Divide(in DPMatrix3x2 dividend, double divisor, out DPMatrix3x2 quotient)
|
||||||
|
{
|
||||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||||
quotient.r1c3 = dividend.r1c3 / divisor;
|
quotient.r1c3 = dividend.r1c3 / divisor;
|
||||||
|
|
@ -311,19 +331,17 @@ public struct DPMatrix3x2
|
||||||
quotient.r2c3 = dividend.r2c3 / divisor;
|
quotient.r2c3 = dividend.r2c3 / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRightProduct(DPMatrix3x2 matrix, DPVector3 vector, DPVector2 result) {
|
public static void GetRightProduct(in DPMatrix3x2 matrix, in DPVector3 vector, out DPVector2 result)
|
||||||
result.SetValues(
|
{
|
||||||
matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3,
|
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||||
matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3
|
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetLeftProduct(DPVector2 vector, DPMatrix3x2 matrix, DPVector3 result) {
|
public static void GetLeftProduct(in DPVector2 vector, in DPMatrix3x2 matrix, out DPVector3 result)
|
||||||
result.SetValues(
|
{
|
||||||
vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1,
|
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||||
vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2,
|
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||||
vector.x1 * matrix.r1c3 + vector.x2 * matrix.r2c3
|
result.x3 = vector.x1 * matrix.r1c3 + vector.x2 * matrix.r2c3;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -81,29 +81,17 @@ namespace Geometry
|
||||||
|
|
||||||
public static void Get2x3At3x2(in DPMatrix2x3 left, in DPMatrix3x2 right, out DPMatrix3x3 product)
|
public static void Get2x3At3x2(in DPMatrix2x3 left, in DPMatrix3x2 right, out DPMatrix3x3 product)
|
||||||
{
|
{
|
||||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||||
double r1c3 = left.r1c1 * right.r1c3 + left.r1c2 * right.r2c3;
|
product.r1c3 = left.r1c1 * right.r1c3 + left.r1c2 * right.r2c3;
|
||||||
|
|
||||||
double r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1;
|
product.r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1;
|
||||||
double r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2;
|
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2;
|
||||||
double r2c3 = left.r2c1 * right.r1c3 + left.r2c2 * right.r2c3;
|
product.r2c3 = left.r2c1 * right.r1c3 + left.r2c2 * right.r2c3;
|
||||||
|
|
||||||
double r3c1 = left.r3c1 * right.r1c1 + left.r3c2 * right.r2c1;
|
product.r3c1 = left.r3c1 * right.r1c1 + left.r3c2 * right.r2c1;
|
||||||
double r3c2 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c2;
|
product.r3c2 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c2;
|
||||||
double r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
product.r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
||||||
|
|
||||||
product.r1c1 = r1c1;
|
|
||||||
product.r1c2 = r1c2;
|
|
||||||
product.r1c3 = r1c3;
|
|
||||||
|
|
||||||
product.r2c1 = r2c1;
|
|
||||||
product.r2c2 = r2c2;
|
|
||||||
product.r2c3 = r2c3;
|
|
||||||
|
|
||||||
product.r3c1 = r3c1;
|
|
||||||
product.r3c2 = r3c2;
|
|
||||||
product.r3c3 = r3c3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Get3x2At3x3(in DPMatrix3x2 left, in DPMatrix3x3 right, out DPMatrix3x2 product)
|
public static void Get3x2At3x3(in DPMatrix3x2 left, in DPMatrix3x3 right, out DPMatrix3x2 product)
|
||||||
|
|
@ -127,17 +115,11 @@ namespace Geometry
|
||||||
|
|
||||||
public static void Get3x2At2x3(in DPMatrix3x2 left, in DPMatrix2x3 right, out DPMatrix2x2 product)
|
public static void Get3x2At2x3(in DPMatrix3x2 left, in DPMatrix2x3 right, out DPMatrix2x2 product)
|
||||||
{
|
{
|
||||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||||
|
|
||||||
double r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1 + left.r2c3 * right.r3c1;
|
product.r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1 + left.r2c3 * right.r3c1;
|
||||||
double r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
||||||
|
|
||||||
product.r1c1 = r1c1;
|
|
||||||
product.r1c2 = r1c2;
|
|
||||||
|
|
||||||
product.r2c1 = r2c1;
|
|
||||||
product.r2c2 = r2c2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Get3x3At2x3(in DPMatrix3x3 left, in DPMatrix2x3 right, out DPMatrix2x3 product)
|
public static void Get3x3At2x3(in DPMatrix3x3 left, in DPMatrix2x3 right, out DPMatrix2x3 product)
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,14 @@ using System;
|
||||||
*/
|
*/
|
||||||
namespace Geometry
|
namespace Geometry
|
||||||
{
|
{
|
||||||
public struct SPMatrix2x3 {
|
public struct SPMatrix2x3
|
||||||
|
{
|
||||||
public float r1c1, r1c2;
|
public float r1c1, r1c2;
|
||||||
public float r2c1, r2c2;
|
public float r2c1, r2c2;
|
||||||
public float r3c1, r3c2;
|
public float r3c1, r3c2;
|
||||||
|
|
||||||
public SPMatrix2x3() {
|
public SPMatrix2x3()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0f;
|
this.r1c1 = 0.0f;
|
||||||
this.r1c2 = 0.0f;
|
this.r1c2 = 0.0f;
|
||||||
|
|
||||||
|
|
@ -39,7 +40,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = 0.0f;
|
this.r3c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix2x3(SPMatrix2x3 matrix) {
|
public SPMatrix2x3(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -50,7 +52,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = matrix.r3c2;
|
this.r3c2 = matrix.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix2x3(DPMatrix2x3 matrix) {
|
public SPMatrix2x3(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r1c2;
|
this.r1c2 = (float) matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -61,7 +64,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = (float) matrix.r3c2;
|
this.r3c2 = (float) matrix.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix2x3(SPMatrix3x2 matrix) {
|
public SPMatrix2x3(in SPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r2c1;
|
this.r1c2 = matrix.r2c1;
|
||||||
|
|
||||||
|
|
@ -72,7 +76,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = matrix.r2c3;
|
this.r3c2 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix2x3(DPMatrix3x2 matrix) {
|
public SPMatrix2x3(in DPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r2c1;
|
this.r1c2 = (float) matrix.r2c1;
|
||||||
|
|
||||||
|
|
@ -83,7 +88,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = (float) matrix.r2c3;
|
this.r3c2 = (float) matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset() {
|
public void Reset()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0f;
|
this.r1c1 = 0.0f;
|
||||||
this.r1c2 = 0.0f;
|
this.r1c2 = 0.0f;
|
||||||
|
|
||||||
|
|
@ -94,7 +100,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = 0.0f;
|
this.r3c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValues(SPMatrix2x3 matrix) {
|
public void SetValues(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -105,7 +112,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = matrix.r3c2;
|
this.r3c2 = matrix.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValues(DPMatrix2x3 matrix) {
|
public void SetValues(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r1c2;
|
this.r1c2 = (float) matrix.r1c2;
|
||||||
|
|
||||||
|
|
@ -116,7 +124,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = (float) matrix.r3c2;
|
this.r3c2 = (float) matrix.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTransposed(SPMatrix3x2 matrix) {
|
public void SetTransposed(in SPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r2c1;
|
this.r1c2 = matrix.r2c1;
|
||||||
|
|
||||||
|
|
@ -127,7 +136,8 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = matrix.r2c3;
|
this.r3c2 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTransposed(DPMatrix3x2 matrix) {
|
public void SetTransposed(in DPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r2c1;
|
this.r1c2 = (float) matrix.r2c1;
|
||||||
|
|
||||||
|
|
@ -138,50 +148,57 @@ public struct SPMatrix2x3 {
|
||||||
this.r3c2 = (float) matrix.r2c3;
|
this.r3c2 = (float) matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow1(float c1, float c2) {
|
public void SetRow1(float c1, float c2)
|
||||||
|
{
|
||||||
this.r1c1 = c1;
|
this.r1c1 = c1;
|
||||||
this.r1c2 = c2;
|
this.r1c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow2(float c1, float c2) {
|
public void SetRow2(float c1, float c2)
|
||||||
|
{
|
||||||
this.r2c1 = c1;
|
this.r2c1 = c1;
|
||||||
this.r2c2 = c2;
|
this.r2c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow3(float c1, float c2) {
|
public void SetRow3(float c1, float c2)
|
||||||
|
{
|
||||||
this.r3c1 = c1;
|
this.r3c1 = c1;
|
||||||
this.r3c2 = c2;
|
this.r3c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn1(float r1, float r2, float r3) {
|
public void SetColumn1(float r1, float r2, float r3)
|
||||||
|
{
|
||||||
this.r1c1 = r1;
|
this.r1c1 = r1;
|
||||||
this.r2c1 = r2;
|
this.r2c1 = r2;
|
||||||
this.r3c1 = r3;
|
this.r3c1 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn2(float r1, float r2, float r3) {
|
public void SetColumn2(float r1, float r2, float r3)
|
||||||
|
{
|
||||||
this.r1c2 = r1;
|
this.r1c2 = r1;
|
||||||
this.r2c2 = r2;
|
this.r2c2 = r2;
|
||||||
this.r3c2 = r3;
|
this.r3c2 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add(SPMatrix2x3 matrix1, SPMatrix2x3 matrix2, SPMatrix2x3 result) {
|
public static void Add(in SPMatrix2x3 matrix1, in SPMatrix2x3 matrix2, out SPMatrix2x3 sum)
|
||||||
result.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
{
|
||||||
result.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||||
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||||
|
|
||||||
result.r2c1 = matrix1.r2c1 + matrix2.r2c1;
|
sum.r2c1 = matrix1.r2c1 + matrix2.r2c1;
|
||||||
result.r2c2 = matrix1.r2c2 + matrix2.r2c2;
|
sum.r2c2 = matrix1.r2c2 + matrix2.r2c2;
|
||||||
|
|
||||||
result.r3c1 = matrix1.r3c1 + matrix2.r3c1;
|
sum.r3c1 = matrix1.r3c1 + matrix2.r3c1;
|
||||||
result.r3c2 = matrix1.r3c2 + matrix2.r3c2;
|
sum.r3c2 = matrix1.r3c2 + matrix2.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add3(
|
public static void Add3(
|
||||||
SPMatrix2x3 matrix1,
|
in SPMatrix2x3 matrix1,
|
||||||
SPMatrix2x3 matrix2,
|
in SPMatrix2x3 matrix2,
|
||||||
SPMatrix2x3 matrix3,
|
in SPMatrix2x3 matrix3,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
||||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
||||||
|
|
||||||
|
|
@ -193,12 +210,13 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add4(
|
public static void Add4(
|
||||||
SPMatrix2x3 matrix1,
|
in SPMatrix2x3 matrix1,
|
||||||
SPMatrix2x3 matrix2,
|
in SPMatrix2x3 matrix2,
|
||||||
SPMatrix2x3 matrix3,
|
in SPMatrix2x3 matrix3,
|
||||||
SPMatrix2x3 matrix4,
|
in SPMatrix2x3 matrix4,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
||||||
|
|
||||||
|
|
@ -210,13 +228,14 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add5(
|
public static void Add5(
|
||||||
SPMatrix2x3 matrix1,
|
in SPMatrix2x3 matrix1,
|
||||||
SPMatrix2x3 matrix2,
|
in SPMatrix2x3 matrix2,
|
||||||
SPMatrix2x3 matrix3,
|
in SPMatrix2x3 matrix3,
|
||||||
SPMatrix2x3 matrix4,
|
in SPMatrix2x3 matrix4,
|
||||||
SPMatrix2x3 matrix5,
|
in SPMatrix2x3 matrix5,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
||||||
|
|
||||||
|
|
@ -227,7 +246,8 @@ public struct SPMatrix2x3 {
|
||||||
sum.r3c2 = (matrix1.r3c2 + matrix2.r3c2) + (matrix3.r3c2 + matrix4.r3c2) + matrix5.r3c2;
|
sum.r3c2 = (matrix1.r3c2 + matrix2.r3c2) + (matrix3.r3c2 + matrix4.r3c2) + matrix5.r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Subtract(SPMatrix2x3 minuend, SPMatrix2x3 subtrahend, SPMatrix2x3 difference) {
|
public static void Subtract(in SPMatrix2x3 minuend, in SPMatrix2x3 subtrahend, out SPMatrix2x3 difference)
|
||||||
|
{
|
||||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||||
|
|
||||||
|
|
@ -239,10 +259,11 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum2(
|
public static void GetWeightedSum2(
|
||||||
float weight1, SPMatrix2x3 matrix1,
|
float weight1, in SPMatrix2x3 matrix1,
|
||||||
float weight2, SPMatrix2x3 matrix2,
|
float weight2, in SPMatrix2x3 matrix2,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
||||||
|
|
||||||
|
|
@ -254,11 +275,12 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum3(
|
public static void GetWeightedSum3(
|
||||||
float weight1, SPMatrix2x3 matrix1,
|
float weight1, in SPMatrix2x3 matrix1,
|
||||||
float weight2, SPMatrix2x3 matrix2,
|
float weight2, in SPMatrix2x3 matrix2,
|
||||||
float weight3, SPMatrix2x3 matrix3,
|
float weight3, in SPMatrix2x3 matrix3,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
||||||
|
|
||||||
|
|
@ -270,12 +292,13 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum4(
|
public static void GetWeightedSum4(
|
||||||
float weight1, SPMatrix2x3 matrix1,
|
float weight1, in SPMatrix2x3 matrix1,
|
||||||
float weight2, SPMatrix2x3 matrix2,
|
float weight2, in SPMatrix2x3 matrix2,
|
||||||
float weight3, SPMatrix2x3 matrix3,
|
float weight3, in SPMatrix2x3 matrix3,
|
||||||
float weight4, SPMatrix2x3 matrix4,
|
float weight4, in SPMatrix2x3 matrix4,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
||||||
|
|
||||||
|
|
@ -287,13 +310,14 @@ public struct SPMatrix2x3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum5(
|
public static void GetWeightedSum5(
|
||||||
float weight1, SPMatrix2x3 matrix1,
|
float weight1, in SPMatrix2x3 matrix1,
|
||||||
float weight2, SPMatrix2x3 matrix2,
|
float weight2, in SPMatrix2x3 matrix2,
|
||||||
float weight3, SPMatrix2x3 matrix3,
|
float weight3, in SPMatrix2x3 matrix3,
|
||||||
float weight4, SPMatrix2x3 matrix4,
|
float weight4, in SPMatrix2x3 matrix4,
|
||||||
float weight5, SPMatrix2x3 matrix5,
|
float weight5, in SPMatrix2x3 matrix5,
|
||||||
SPMatrix2x3 sum
|
out SPMatrix2x3 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
||||||
|
|
||||||
|
|
@ -304,7 +328,8 @@ public struct SPMatrix2x3 {
|
||||||
sum.r3c2 = (matrix1.r3c2 * weight1 + matrix2.r3c2 * weight2) + (matrix3.r3c2 * weight3 + matrix4.r3c2 * weight4) + matrix5.r3c2 * weight5;
|
sum.r3c2 = (matrix1.r3c2 * weight1 + matrix2.r3c2 * weight2) + (matrix3.r3c2 * weight3 + matrix4.r3c2 * weight4) + matrix5.r3c2 * weight5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Multiply(SPMatrix2x3 multiplicand, float multiplier, SPMatrix2x3 product) {
|
public static void Multiply(in SPMatrix2x3 multiplicand, float multiplier, out SPMatrix2x3 product)
|
||||||
|
{
|
||||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||||
|
|
||||||
|
|
@ -315,7 +340,8 @@ public struct SPMatrix2x3 {
|
||||||
product.r3c2 = multiplicand.r3c2 * multiplier;
|
product.r3c2 = multiplicand.r3c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Divide(SPMatrix2x3 dividend, float divisor, SPMatrix2x3 quotient) {
|
public static void Divide(in SPMatrix2x3 dividend, float divisor, out SPMatrix2x3 quotient)
|
||||||
|
{
|
||||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||||
|
|
||||||
|
|
@ -326,20 +352,17 @@ public struct SPMatrix2x3 {
|
||||||
quotient.r3c2 = dividend.r3c2 / divisor;
|
quotient.r3c2 = dividend.r3c2 / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRightProduct(SPMatrix2x3 matrix, SPVector2 vector, SPVector3 result) {
|
public static void GetRightProduct(in SPMatrix2x3 matrix, in SPVector2 vector, out SPVector3 result)
|
||||||
result.SetValues(
|
{
|
||||||
matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2,
|
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||||
matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2,
|
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||||
matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2
|
result.x3 = matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2;
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetLeftProduct(SPVector3 vector, SPMatrix2x3 matrix, SPVector2 result) {
|
public static void GetLeftProduct(in SPVector3 vector, in SPMatrix2x3 matrix, out SPVector2 result)
|
||||||
result.SetValues(
|
{
|
||||||
vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1,
|
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||||
vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2
|
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -20,13 +20,13 @@
|
||||||
*/
|
*/
|
||||||
namespace Geometry
|
namespace Geometry
|
||||||
{
|
{
|
||||||
public class SPMatrix3x2 {
|
public struct SPMatrix3x2
|
||||||
|
{
|
||||||
public float r1c1, r1c2, r1c3;
|
public float r1c1, r1c2, r1c3;
|
||||||
|
|
||||||
public float r2c1, r2c2, r2c3;
|
public float r2c1, r2c2, r2c3;
|
||||||
|
|
||||||
public SPMatrix3x2() {
|
public SPMatrix3x2()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0f;
|
this.r1c1 = 0.0f;
|
||||||
this.r1c2 = 0.0f;
|
this.r1c2 = 0.0f;
|
||||||
this.r1c3 = 0.0f;
|
this.r1c3 = 0.0f;
|
||||||
|
|
@ -36,7 +36,8 @@ public class SPMatrix3x2 {
|
||||||
this.r2c3 = 0.0f;
|
this.r2c3 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix3x2(SPMatrix3x2 matrix) {
|
public SPMatrix3x2(in SPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
this.r1c3 = matrix.r1c3;
|
this.r1c3 = matrix.r1c3;
|
||||||
|
|
@ -46,7 +47,8 @@ public class SPMatrix3x2 {
|
||||||
this.r2c3 = matrix.r2c3;
|
this.r2c3 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPMatrix3x2(DPMatrix3x2 matrix) {
|
public SPMatrix3x2(in DPMatrix3x2 matrix)
|
||||||
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r1c2;
|
this.r1c2 = (float) matrix.r1c2;
|
||||||
this.r1c3 = (float) matrix.r1c3;
|
this.r1c3 = (float) matrix.r1c3;
|
||||||
|
|
@ -56,7 +58,30 @@ public class SPMatrix3x2 {
|
||||||
this.r2c3 = (float) matrix.r2c3;
|
this.r2c3 = (float) matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset() {
|
public SPMatrix3x2(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
|
this.r1c1 = matrix.r1c1;
|
||||||
|
this.r1c2 = matrix.r2c1;
|
||||||
|
this.r1c3 = matrix.r3c1;
|
||||||
|
|
||||||
|
this.r2c1 = matrix.r1c2;
|
||||||
|
this.r2c2 = matrix.r2c2;
|
||||||
|
this.r2c3 = matrix.r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SPMatrix3x2(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
|
this.r1c2 = (float) matrix.r2c1;
|
||||||
|
this.r1c3 = (float) matrix.r3c1;
|
||||||
|
|
||||||
|
this.r2c1 = (float) matrix.r1c2;
|
||||||
|
this.r2c2 = (float) matrix.r2c2;
|
||||||
|
this.r2c3 = (float) matrix.r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
this.r1c1 = 0.0f;
|
this.r1c1 = 0.0f;
|
||||||
this.r1c2 = 0.0f;
|
this.r1c2 = 0.0f;
|
||||||
this.r1c3 = 0.0f;
|
this.r1c3 = 0.0f;
|
||||||
|
|
@ -66,8 +91,8 @@ public class SPMatrix3x2 {
|
||||||
this.r2c3 = 0.0f;
|
this.r2c3 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetValues(in SPMatrix3x2 matrix)
|
||||||
public void SetValues(SPMatrix3x2 matrix) {
|
{
|
||||||
this.r1c1 = matrix.r1c1;
|
this.r1c1 = matrix.r1c1;
|
||||||
this.r1c2 = matrix.r1c2;
|
this.r1c2 = matrix.r1c2;
|
||||||
this.r1c3 = matrix.r1c3;
|
this.r1c3 = matrix.r1c3;
|
||||||
|
|
@ -77,8 +102,8 @@ public class SPMatrix3x2 {
|
||||||
this.r2c3 = matrix.r2c3;
|
this.r2c3 = matrix.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public void SetValues(in DPMatrix3x2 matrix)
|
||||||
public void SetValues(DPMatrix3x2 matrix) {
|
{
|
||||||
this.r1c1 = (float) matrix.r1c1;
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
this.r1c2 = (float) matrix.r1c2;
|
this.r1c2 = (float) matrix.r1c2;
|
||||||
this.r1c3 = (float) matrix.r1c3;
|
this.r1c3 = (float) matrix.r1c3;
|
||||||
|
|
@ -87,36 +112,63 @@ public class SPMatrix3x2 {
|
||||||
this.r2c2 = (float) matrix.r2c2;
|
this.r2c2 = (float) matrix.r2c2;
|
||||||
this.r2c3 = (float) matrix.r2c3;
|
this.r2c3 = (float) matrix.r2c3;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public void SetRow1(float c1, float c2, float c3) {
|
public void SetTransposed(in SPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
|
this.r1c1 = matrix.r1c1;
|
||||||
|
this.r1c2 = matrix.r2c1;
|
||||||
|
this.r1c3 = matrix.r3c1;
|
||||||
|
|
||||||
|
this.r2c1 = matrix.r1c2;
|
||||||
|
this.r2c2 = matrix.r2c2;
|
||||||
|
this.r2c3 = matrix.r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTransposed(in DPMatrix2x3 matrix)
|
||||||
|
{
|
||||||
|
this.r1c1 = (float) matrix.r1c1;
|
||||||
|
this.r1c2 = (float) matrix.r2c1;
|
||||||
|
this.r1c3 = (float) matrix.r3c1;
|
||||||
|
|
||||||
|
this.r2c1 = (float) matrix.r1c2;
|
||||||
|
this.r2c2 = (float) matrix.r2c2;
|
||||||
|
this.r2c3 = (float) matrix.r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetRow1(float c1, float c2, float c3)
|
||||||
|
{
|
||||||
this.r1c1 = c1;
|
this.r1c1 = c1;
|
||||||
this.r1c2 = c2;
|
this.r1c2 = c2;
|
||||||
this.r1c3 = c3;
|
this.r1c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRow2(float c1, float c2, float c3) {
|
public void SetRow2(float c1, float c2, float c3)
|
||||||
|
{
|
||||||
this.r2c1 = c1;
|
this.r2c1 = c1;
|
||||||
this.r2c2 = c2;
|
this.r2c2 = c2;
|
||||||
this.r2c3 = c3;
|
this.r2c3 = c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn1(float r1, float r2) {
|
public void SetColumn1(float r1, float r2)
|
||||||
|
{
|
||||||
this.r1c1 = r1;
|
this.r1c1 = r1;
|
||||||
this.r2c1 = r2;
|
this.r2c1 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn2(float r1, float r2) {
|
public void SetColumn2(float r1, float r2)
|
||||||
|
{
|
||||||
this.r1c3 = r1;
|
this.r1c3 = r1;
|
||||||
this.r2c3 = r2;
|
this.r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumn3(float r1, float r2) {
|
public void SetColumn3(float r1, float r2)
|
||||||
|
{
|
||||||
this.r1c3 = r1;
|
this.r1c3 = r1;
|
||||||
this.r2c3 = r2;
|
this.r2c3 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add(SPMatrix3x2 matrix1, SPMatrix3x2 matrix2, SPMatrix3x2 sum) {
|
public static void Add(in SPMatrix3x2 matrix1, in SPMatrix3x2 matrix2, out SPMatrix3x2 sum)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||||
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3;
|
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3;
|
||||||
|
|
@ -127,11 +179,12 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add3(
|
public static void Add3(
|
||||||
SPMatrix3x2 matrix1,
|
in SPMatrix3x2 matrix1,
|
||||||
SPMatrix3x2 matrix2,
|
in SPMatrix3x2 matrix2,
|
||||||
SPMatrix3x2 matrix3,
|
in SPMatrix3x2 matrix3,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1 + matrix3.r1c1;
|
||||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2 + matrix3.r1c2;
|
||||||
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3 + matrix3.r1c3;
|
sum.r1c3 = matrix1.r1c3 + matrix2.r1c3 + matrix3.r1c3;
|
||||||
|
|
@ -142,12 +195,13 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add4(
|
public static void Add4(
|
||||||
SPMatrix3x2 matrix1,
|
in SPMatrix3x2 matrix1,
|
||||||
SPMatrix3x2 matrix2,
|
in SPMatrix3x2 matrix2,
|
||||||
SPMatrix3x2 matrix3,
|
in SPMatrix3x2 matrix3,
|
||||||
SPMatrix3x2 matrix4,
|
in SPMatrix3x2 matrix4,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1);
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2);
|
||||||
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3);
|
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3);
|
||||||
|
|
@ -158,13 +212,14 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add5(
|
public static void Add5(
|
||||||
SPMatrix3x2 matrix1,
|
in SPMatrix3x2 matrix1,
|
||||||
SPMatrix3x2 matrix2,
|
in SPMatrix3x2 matrix2,
|
||||||
SPMatrix3x2 matrix3,
|
in SPMatrix3x2 matrix3,
|
||||||
SPMatrix3x2 matrix4,
|
in SPMatrix3x2 matrix4,
|
||||||
SPMatrix3x2 matrix5,
|
in SPMatrix3x2 matrix5,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
sum.r1c1 = (matrix1.r1c1 + matrix2.r1c1) + (matrix3.r1c1 + matrix4.r1c1) + matrix5.r1c1;
|
||||||
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
sum.r1c2 = (matrix1.r1c2 + matrix2.r1c2) + (matrix3.r1c2 + matrix4.r1c2) + matrix5.r1c2;
|
||||||
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3) + matrix5.r1c3;
|
sum.r1c3 = (matrix1.r1c3 + matrix2.r1c3) + (matrix3.r1c3 + matrix4.r1c3) + matrix5.r1c3;
|
||||||
|
|
@ -174,7 +229,8 @@ public class SPMatrix3x2 {
|
||||||
sum.r2c3 = (matrix1.r2c3 + matrix2.r2c3) + (matrix3.r2c3 + matrix4.r2c3) + matrix5.r2c3;
|
sum.r2c3 = (matrix1.r2c3 + matrix2.r2c3) + (matrix3.r2c3 + matrix4.r2c3) + matrix5.r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Subtract(SPMatrix3x2 minuend, SPMatrix3x2 subtrahend, SPMatrix3x2 difference) {
|
public static void Subtract(in SPMatrix3x2 minuend, in SPMatrix3x2 subtrahend, out SPMatrix3x2 difference)
|
||||||
|
{
|
||||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||||
difference.r1c3 = minuend.r1c3 - subtrahend.r1c3;
|
difference.r1c3 = minuend.r1c3 - subtrahend.r1c3;
|
||||||
|
|
@ -185,10 +241,11 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum2(
|
public static void GetWeightedSum2(
|
||||||
float weight1, SPMatrix3x2 matrix1,
|
float weight1, in SPMatrix3x2 matrix1,
|
||||||
float weight2, SPMatrix3x2 matrix2,
|
float weight2, in SPMatrix3x2 matrix2,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2;
|
||||||
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2;
|
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2;
|
||||||
|
|
@ -199,11 +256,12 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum3(
|
public static void GetWeightedSum3(
|
||||||
float weight1, SPMatrix3x2 matrix1,
|
float weight1, in SPMatrix3x2 matrix1,
|
||||||
float weight2, SPMatrix3x2 matrix2,
|
float weight2, in SPMatrix3x2 matrix2,
|
||||||
float weight3, SPMatrix3x2 matrix3,
|
float weight3, in SPMatrix3x2 matrix3,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
sum.r1c1 = matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2 + matrix3.r1c1 * weight3;
|
||||||
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
sum.r1c2 = matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2 + matrix3.r1c2 * weight3;
|
||||||
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2 + matrix3.r1c3 * weight3;
|
sum.r1c3 = matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2 + matrix3.r1c3 * weight3;
|
||||||
|
|
@ -214,12 +272,13 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum4(
|
public static void GetWeightedSum4(
|
||||||
float weight1, SPMatrix3x2 matrix1,
|
float weight1, in SPMatrix3x2 matrix1,
|
||||||
float weight2, SPMatrix3x2 matrix2,
|
float weight2, in SPMatrix3x2 matrix2,
|
||||||
float weight3, SPMatrix3x2 matrix3,
|
float weight3, in SPMatrix3x2 matrix3,
|
||||||
float weight4, SPMatrix3x2 matrix4,
|
float weight4, in SPMatrix3x2 matrix4,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4);
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4);
|
||||||
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4);
|
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4);
|
||||||
|
|
@ -230,13 +289,14 @@ public class SPMatrix3x2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetWeightedSum5(
|
public static void GetWeightedSum5(
|
||||||
float weight1, SPMatrix3x2 matrix1,
|
float weight1, in SPMatrix3x2 matrix1,
|
||||||
float weight2, SPMatrix3x2 matrix2,
|
float weight2, in SPMatrix3x2 matrix2,
|
||||||
float weight3, SPMatrix3x2 matrix3,
|
float weight3, in SPMatrix3x2 matrix3,
|
||||||
float weight4, SPMatrix3x2 matrix4,
|
float weight4, in SPMatrix3x2 matrix4,
|
||||||
float weight5, SPMatrix3x2 matrix5,
|
float weight5, in SPMatrix3x2 matrix5,
|
||||||
SPMatrix3x2 sum
|
out SPMatrix3x2 sum
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
sum.r1c1 = (matrix1.r1c1 * weight1 + matrix2.r1c1 * weight2) + (matrix3.r1c1 * weight3 + matrix4.r1c1 * weight4) + matrix5.r1c1 * weight5;
|
||||||
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
sum.r1c2 = (matrix1.r1c2 * weight1 + matrix2.r1c2 * weight2) + (matrix3.r1c2 * weight3 + matrix4.r1c2 * weight4) + matrix5.r1c2 * weight5;
|
||||||
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4) + matrix5.r1c3 * weight5;
|
sum.r1c3 = (matrix1.r1c3 * weight1 + matrix2.r1c3 * weight2) + (matrix3.r1c3 * weight3 + matrix4.r1c3 * weight4) + matrix5.r1c3 * weight5;
|
||||||
|
|
@ -246,7 +306,8 @@ public class SPMatrix3x2 {
|
||||||
sum.r2c3 = (matrix1.r2c3 * weight1 + matrix2.r2c3 * weight2) + (matrix3.r2c3 * weight3 + matrix4.r2c3 * weight4) + matrix5.r2c3 * weight5;
|
sum.r2c3 = (matrix1.r2c3 * weight1 + matrix2.r2c3 * weight2) + (matrix3.r2c3 * weight3 + matrix4.r2c3 * weight4) + matrix5.r2c3 * weight5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Multiply(SPMatrix3x2 multiplicand, float multiplier, SPMatrix3x2 product) {
|
public static void Multiply(in SPMatrix3x2 multiplicand, float multiplier, out SPMatrix3x2 product)
|
||||||
|
{
|
||||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||||
product.r1c3 = multiplicand.r1c3 * multiplier;
|
product.r1c3 = multiplicand.r1c3 * multiplier;
|
||||||
|
|
@ -256,7 +317,8 @@ public class SPMatrix3x2 {
|
||||||
product.r2c3 = multiplicand.r2c3 * multiplier;
|
product.r2c3 = multiplicand.r2c3 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Divide(SPMatrix3x2 dividend, float divisor, SPMatrix3x2 quotient) {
|
public static void Divide(in SPMatrix3x2 dividend, float divisor, out SPMatrix3x2 quotient)
|
||||||
|
{
|
||||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||||
quotient.r1c3 = dividend.r1c3 / divisor;
|
quotient.r1c3 = dividend.r1c3 / divisor;
|
||||||
|
|
@ -266,19 +328,17 @@ public class SPMatrix3x2 {
|
||||||
quotient.r2c3 = dividend.r2c3 / divisor;
|
quotient.r2c3 = dividend.r2c3 / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRightProduct(SPMatrix3x2 matrix, SPVector3 vector, SPVector2 result) {
|
public static void GetRightProduct(in SPMatrix3x2 matrix, in SPVector3 vector, out SPVector2 result)
|
||||||
result.SetValues(
|
{
|
||||||
matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3,
|
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||||
matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3
|
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetLeftProduct(SPVector2 vector, SPMatrix3x2 matrix, SPVector3 result) {
|
public static void GetLeftProduct(in SPVector2 vector, in SPMatrix3x2 matrix, out SPVector3 result)
|
||||||
result.SetValues(
|
{
|
||||||
vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1,
|
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||||
vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2,
|
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||||
vector.x1 * matrix.r1c3 + vector.x2 * matrix.r2c3
|
result.x3 = vector.x1 * matrix.r1c3 + vector.x2 * matrix.r2c3;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -81,29 +81,17 @@ namespace Geometry
|
||||||
|
|
||||||
public static void Get2x3At3x2(in SPMatrix2x3 left, in SPMatrix3x2 right, out SPMatrix3x3 product)
|
public static void Get2x3At3x2(in SPMatrix2x3 left, in SPMatrix3x2 right, out SPMatrix3x3 product)
|
||||||
{
|
{
|
||||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||||
float r1c3 = left.r1c1 * right.r1c3 + left.r1c2 * right.r2c3;
|
product.r1c3 = left.r1c1 * right.r1c3 + left.r1c2 * right.r2c3;
|
||||||
|
|
||||||
float r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1;
|
product.r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1;
|
||||||
float r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2;
|
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2;
|
||||||
float r2c3 = left.r2c1 * right.r1c3 + left.r2c2 * right.r2c3;
|
product.r2c3 = left.r2c1 * right.r1c3 + left.r2c2 * right.r2c3;
|
||||||
|
|
||||||
float r3c1 = left.r3c1 * right.r1c1 + left.r3c2 * right.r2c1;
|
product.r3c1 = left.r3c1 * right.r1c1 + left.r3c2 * right.r2c1;
|
||||||
float r3c2 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c2;
|
product.r3c2 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c2;
|
||||||
float r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
product.r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
||||||
|
|
||||||
product.r1c1 = r1c1;
|
|
||||||
product.r1c2 = r1c2;
|
|
||||||
product.r1c3 = r1c3;
|
|
||||||
|
|
||||||
product.r2c1 = r2c1;
|
|
||||||
product.r2c2 = r2c2;
|
|
||||||
product.r2c3 = r2c3;
|
|
||||||
|
|
||||||
product.r3c1 = r3c1;
|
|
||||||
product.r3c2 = r3c2;
|
|
||||||
product.r3c3 = r3c3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Get3x2At3x3(in SPMatrix3x2 left, in SPMatrix3x3 right, out SPMatrix3x2 product)
|
public static void Get3x2At3x3(in SPMatrix3x2 left, in SPMatrix3x3 right, out SPMatrix3x2 product)
|
||||||
|
|
@ -127,17 +115,11 @@ namespace Geometry
|
||||||
|
|
||||||
public static void Get3x2At2x3(in SPMatrix3x2 left, in SPMatrix2x3 right, out SPMatrix2x2 product)
|
public static void Get3x2At2x3(in SPMatrix3x2 left, in SPMatrix2x3 right, out SPMatrix2x2 product)
|
||||||
{
|
{
|
||||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||||
|
|
||||||
float r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1 + left.r2c3 * right.r3c1;
|
product.r2c1 = left.r2c1 * right.r1c1 + left.r2c2 * right.r2c1 + left.r2c3 * right.r3c1;
|
||||||
float r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
||||||
|
|
||||||
product.r1c1 = r1c1;
|
|
||||||
product.r1c2 = r1c2;
|
|
||||||
|
|
||||||
product.r2c1 = r2c1;
|
|
||||||
product.r2c2 = r2c2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Get3x3At2x3(in SPMatrix3x3 left, in SPMatrix2x3 right, out SPMatrix2x3 product)
|
public static void Get3x3At2x3(in SPMatrix3x3 left, in SPMatrix2x3 right, out SPMatrix2x3 product)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue