daily update on 20230307 by nitload youmu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array2x3:IEquatable<Array2x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec3D row1;
|
||||
[FieldOffset(12)]
|
||||
public Vec3D row2;
|
||||
|
||||
public Array2x3(Vec3D r1, Vec3D r2)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Array2x3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Vec3D)obj);
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(row1, row2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{row1}\n{row2}";
|
||||
}
|
||||
|
||||
bool IEquatable<Array2x3>.Equals(Array2x3 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
this.row1 == other.row1
|
||||
&& this.row2 == other.row2;
|
||||
}
|
||||
}
|
||||
|
||||
public static Array2x3 operator +(Array2x3 array1, Array2x3 array2)
|
||||
{
|
||||
return new Array2x3(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x3 operator -(Array2x3 array1, Array2x3 array2)
|
||||
{
|
||||
return new Array2x3(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x3 operator *(Array2x3 array, float x)
|
||||
{
|
||||
return new Array2x3(
|
||||
array.row1 * x,
|
||||
array.row2 * x
|
||||
) ;
|
||||
}
|
||||
|
||||
public static Array2x3 operator /(Array2x3 array, float x)
|
||||
{
|
||||
return new Array2x3(
|
||||
array.row1 / x,
|
||||
array.row2 / x
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Array2x2 operator *(Array2x3 array1, Array3x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row2.X;
|
||||
|
||||
return new Array2x2(
|
||||
*(p1 + 0) * *(p2 + 0) + *(p1 + 1) * *(p2 + 2) + *(p1 + 2) * *(p2 + 4),
|
||||
*(p1 + 0) * *(p2 + 1) + *(p1 + 1) * *(p2 + 3) + *(p1 + 2) * *(p2 + 5),
|
||||
*(p1 + 3) * *(p2 + 0) + *(p1 + 4) * *(p2 + 2) + *(p1 + 5) * *(p2 + 4),
|
||||
*(p1 + 3) * *(p2 + 1) + *(p1 + 4) * *(p2 + 3) + *(p1 + 5) * *(p2 + 5)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array2x4 : IEquatable<Array2x4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec4D row1;
|
||||
[FieldOffset(16)]
|
||||
public Vec4D row2;
|
||||
|
||||
public Array2x4(Vec4D r1,Vec4D r2)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool Equals(Array2x4 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.row1 == other.row1
|
||||
&& this.row2 == other.row2;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Array2x4))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Array2x4)obj);
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(this.row1, this.row2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.row1}\n{this.row2}";
|
||||
}
|
||||
|
||||
public static Array2x4 operator +(Array2x4 array1,Array2x4 array2)
|
||||
{
|
||||
return new Array2x4(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2
|
||||
) ;
|
||||
}
|
||||
|
||||
public static Array2x4 operator -(Array2x4 array1, Array2x4 array2)
|
||||
{
|
||||
return new Array2x4(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x4 operator *(Array2x4 array, float x)
|
||||
{
|
||||
return new Array2x4(
|
||||
array.row1 * x,
|
||||
array.row2 * x
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x4 operator /(Array2x4 array, float x)
|
||||
{
|
||||
return new Array2x4(
|
||||
array.row1 / x,
|
||||
array.row2 / x
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Array2x2 operator *(Array2x4 array1, Array4x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row2.X;
|
||||
|
||||
return new Array2x2(
|
||||
*(p1 + 0) * *(p2 + 0)+ *(p1 + 1) * *(p2 + 2)+ *(p1 + 2) * *(p2 + 4)+ *(p1 + 3) * *(p2 + 6),
|
||||
*(p1 + 0) * *(p2 + 1)+ *(p1 + 1) * *(p2 + 3)+ *(p1 + 2) * *(p2 + 5)+ *(p1 + 3) * *(p2 + 7),
|
||||
*(p1 + 4) * *(p2 + 0)+ *(p1 + 5) * *(p2 + 2)+ *(p1 + 6) * *(p2 + 4)+ *(p1 + 7) * *(p2 + 6),
|
||||
*(p1 + 4) * *(p2 + 1)+ *(p1 + 5) * *(p2 + 3)+ *(p1 + 6) * *(p2 + 5)+ *(p1 + 7) * *(p2 + 7)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,9 +73,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x2 operator *(Colum2D colum, Vec2D vec)
|
||||
public static Matrix2x2 operator *(Colum2D colum, Vec2D vec)
|
||||
{
|
||||
return new Array2x2(
|
||||
return new Matrix2x2(
|
||||
colum.X * vec.X, colum.X * vec.Y,
|
||||
colum.Y * vec.X, colum.Y * vec.Y
|
||||
);
|
||||
|
||||
@@ -7,20 +7,20 @@ using System.Text;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array2x2:IEquatable<Array2x2>
|
||||
public struct Matrix2x2:IEquatable<Matrix2x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec2D row1;
|
||||
[FieldOffset(8)]
|
||||
public Vec2D row2;
|
||||
|
||||
public Array2x2(Vec2D c0, Vec2D c1)
|
||||
public Matrix2x2(Vec2D c0, Vec2D c1)
|
||||
{
|
||||
row1 = c0;
|
||||
row2 = c1;
|
||||
}
|
||||
|
||||
public Array2x2(
|
||||
public Matrix2x2(
|
||||
float a11,
|
||||
float a12,
|
||||
float a21,
|
||||
@@ -31,7 +31,7 @@ namespace StgSharp.Math
|
||||
row2 = new Vec2D(a21, a22);
|
||||
}
|
||||
|
||||
bool IEquatable<Array2x2>.Equals(Array2x2 other)
|
||||
bool IEquatable<Matrix2x2>.Equals(Matrix2x2 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Array2x2))
|
||||
else if (obj.GetType() != typeof(Matrix2x2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -71,23 +71,23 @@ namespace StgSharp.Math
|
||||
return $"{row1}\n{row2}";
|
||||
}
|
||||
|
||||
public static Array2x2 operator +(Array2x2 array1, Array2x2 array2)
|
||||
public static Matrix2x2 operator +(Matrix2x2 array1, Matrix2x2 array2)
|
||||
{
|
||||
return new Array2x2(
|
||||
return new Matrix2x2(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Array2x2 operator -(Array2x2 array1, Array2x2 array2)
|
||||
public static Matrix2x2 operator -(Matrix2x2 array1, Matrix2x2 array2)
|
||||
{
|
||||
return new Array2x2(
|
||||
return new Matrix2x2(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Array2x2 operator *(Array2x2 array1, Array2x2 array2)
|
||||
public static unsafe Matrix2x2 operator *(Matrix2x2 array1, Matrix2x2 array2)
|
||||
{
|
||||
float* a11 = &array1.row1.X;
|
||||
float* a12 = a11++ ;
|
||||
@@ -125,7 +125,7 @@ namespace StgSharp.Math
|
||||
var u6 = u3 - m4;
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new Array2x2(u1,u5,u6,u7);
|
||||
return new Matrix2x2(u1,u5,u6,u7);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Matrix2x3:IEquatable<Matrix2x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec3D row1;
|
||||
[FieldOffset(12)]
|
||||
public Vec3D row2;
|
||||
|
||||
public Matrix2x3(Vec3D r1, Vec3D r2)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Matrix2x3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Vec3D)obj);
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(row1, row2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{row1}\n{row2}";
|
||||
}
|
||||
|
||||
bool IEquatable<Matrix2x3>.Equals(Matrix2x3 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
this.row1 == other.row1
|
||||
&& this.row2 == other.row2;
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator +(Matrix2x3 array1, Matrix2x3 array2)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator -(Matrix2x3 array1, Matrix2x3 array2)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator *(Matrix2x3 array, float x)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
array.row1 * x,
|
||||
array.row2 * x
|
||||
) ;
|
||||
}
|
||||
|
||||
public static Matrix2x3 operator /(Matrix2x3 array, float x)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
array.row1 / x,
|
||||
array.row2 / x
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Matrix2x2 operator *(Matrix2x3 array1, Matrix3x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row2.X;
|
||||
|
||||
Vec2D a11 = new Vec2D(*(p1 + 0), *(p1 + 1));
|
||||
Vec2D a12 = new Vec2D(*(p1 + 2), 0);
|
||||
Vec2D a21 = new Vec2D(*(p1 + 3), *(p1 + 4));
|
||||
Vec2D a22 = new Vec2D(*(p1 + 5), 0);
|
||||
|
||||
Colum2D b11 = new Colum2D(*(p2 + 0), *(p2 + 2));
|
||||
Colum2D b12 = new Colum2D(*(p2 + 1), *(p2 + 3));
|
||||
Colum2D b21 = new Colum2D(*(p2 + 4), 0);
|
||||
Colum2D b22 = new Colum2D(*(p2 + 5), 0);
|
||||
|
||||
var s1 = a21 + a22;
|
||||
var s2 = s1 - a11;
|
||||
var s3 = a11 - a21;
|
||||
var s4 = a12 - s2;
|
||||
|
||||
var t1 = b12 - b11;
|
||||
var t2 = b22 - t1;
|
||||
var t3 = b22 - b12;
|
||||
var t4 = t2 - b21;
|
||||
|
||||
var m1 = a11 * b11;
|
||||
var m2 = a12 * b11;
|
||||
var m3 = s4 * b22;
|
||||
var m4 = a22 * t4;
|
||||
var m5 = s1 * t1;
|
||||
var m6 = s2 * t2;
|
||||
var m7 = s3 * t3;
|
||||
|
||||
var u1 = m1 + m2;
|
||||
var u2 = m1 + m6;
|
||||
var u3 = u2 + m7;
|
||||
var u4 = u2 + m5;
|
||||
var u5 = u4 + m3;
|
||||
var u6 = u3 - m4;
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new Matrix2x2(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Matrix2x4 : IEquatable<Matrix2x4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec4D row1;
|
||||
[FieldOffset(16)]
|
||||
public Vec4D row2;
|
||||
|
||||
public Matrix2x4(Vec4D r1,Vec4D r2)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool Equals(Matrix2x4 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.row1 == other.row1
|
||||
&& this.row2 == other.row2;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Matrix2x4))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Matrix2x4)obj);
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(this.row1, this.row2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.row1}\n{this.row2}";
|
||||
}
|
||||
|
||||
public static Matrix2x4 operator +(Matrix2x4 array1,Matrix2x4 array2)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2
|
||||
) ;
|
||||
}
|
||||
|
||||
public static Matrix2x4 operator -(Matrix2x4 array1, Matrix2x4 array2)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x4 operator *(Matrix2x4 array, float x)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
array.row1 * x,
|
||||
array.row2 * x
|
||||
);
|
||||
}
|
||||
|
||||
public static Matrix2x4 operator /(Matrix2x4 array, float x)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
array.row1 / x,
|
||||
array.row2 / x
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Matrix2x2 operator *(Matrix2x4 array1,Matrix4x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row2.X;
|
||||
|
||||
Vec2D a11 = new Vec2D(*(p1 + 0), *(p1 + 2));
|
||||
Vec2D a12 = new Vec2D(*(p1 + 1), *(p1 + 3));
|
||||
Vec2D a21 = new Vec2D(*(p1 + 4), *(p1 + 6));
|
||||
Vec2D a22 = new Vec2D(*(p1 + 5), *(p1 + 7));
|
||||
|
||||
Colum2D b11 = new Colum2D(*(p2 + 0), *(p2 + 1));
|
||||
Colum2D b12 = new Colum2D(*(p2 + 2), *(p2 + 3));
|
||||
Colum2D b21 = new Colum2D(*(p2 + 4), *(p2 + 5));
|
||||
Colum2D b22 = new Colum2D(*(p2 + 6), *(p2 + 7));
|
||||
|
||||
var s1 = a21 + a22;
|
||||
var s2 = s1 - a11;
|
||||
var s3 = a11 - a21;
|
||||
var s4 = a12 - s2;
|
||||
|
||||
var t1 = b12 - b11;
|
||||
var t2 = b22 - t1;
|
||||
var t3 = b22 - b12;
|
||||
var t4 = t2 - b21;
|
||||
|
||||
var m1 = a11 * b11;
|
||||
var m2 = a12 * b11;
|
||||
var m3 = s4 * b22;
|
||||
var m4 = a22 * t4;
|
||||
var m5 = s1 * t1;
|
||||
var m6 = s2 * t2;
|
||||
var m7 = s3 * t3;
|
||||
|
||||
var u1 = m1 + m2;
|
||||
var u2 = m1 + m6;
|
||||
var u3 = u2 + m7;
|
||||
var u4 = u2 + m5;
|
||||
var u5 = u4 + m3;
|
||||
var u6 = u3 - m4;
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new Matrix2x2(u1,u5,u6,u7);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array3x2:IEquatable<Array3x2>
|
||||
public struct Matrix3x2:IEquatable<Matrix3x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec2D row1;
|
||||
@@ -15,13 +15,13 @@ namespace StgSharp.Math
|
||||
[FieldOffset(16)]
|
||||
public Vec2D row3;
|
||||
|
||||
public Array3x2(Vec2D r1,Vec2D r2,Vec2D r3)
|
||||
public Matrix3x2(Vec2D r1,Vec2D r2,Vec2D r3)
|
||||
{
|
||||
row1= r1;
|
||||
row2= r2;
|
||||
row3= r3;
|
||||
}
|
||||
bool IEquatable<Array3x2>.Equals(Array3x2 other)
|
||||
bool IEquatable<Matrix3x2>.Equals(Matrix3x2 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
@@ -43,13 +43,13 @@ namespace StgSharp.Math
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Array3x2))
|
||||
else if (obj.GetType() != typeof(Matrix3x2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Array3x2)obj);
|
||||
return this.Equals((Matrix3x2)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,12 +63,14 @@ namespace StgSharp.Math
|
||||
return $"{row1}\n{row2}\n{row3}";
|
||||
}
|
||||
|
||||
public static unsafe Array3x3 operator *(Array3x2 array1, Array2x3 array2)
|
||||
public static unsafe Matrix3x3 operator *(Matrix3x2 array1, Matrix3x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row2.X;
|
||||
|
||||
return new Array3x3(
|
||||
Matrix2x2 a11 = new Matrix2x2();
|
||||
|
||||
return new Matrix3x3(
|
||||
*(p1 + 0) * *(p2 + 0) + *(p1 + 1) * *(p2 + 3),
|
||||
*(p1 + 0) * *(p2 + 1) + *(p1 + 1) * *(p2 + 4),
|
||||
*(p1 + 0) * *(p2 + 2) + *(p1 + 1) * *(p2 + 5),
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array3x3:IEquatable<Array3x3>
|
||||
public struct Matrix3x3:IEquatable<Matrix3x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec3D row1;
|
||||
@@ -18,14 +18,14 @@ namespace StgSharp.Math
|
||||
[FieldOffset(24)]
|
||||
public Vec3D row3;
|
||||
|
||||
public Array3x3(Vec3D r0,Vec3D r1,Vec3D r2)
|
||||
public Matrix3x3(Vec3D r0,Vec3D r1,Vec3D r2)
|
||||
{
|
||||
row1 = r0;
|
||||
row2 = r1;
|
||||
row3 = r2;
|
||||
}
|
||||
|
||||
public Array3x3(
|
||||
public Matrix3x3(
|
||||
float a11,float a12,float a13,
|
||||
float a21,float a22,float a23,
|
||||
float a31,float a32,float a33
|
||||
@@ -41,7 +41,7 @@ namespace StgSharp.Math
|
||||
return HashCode.Combine(row1,row2,row3);
|
||||
}
|
||||
|
||||
bool IEquatable<Array3x3>.Equals(Array3x3 other)
|
||||
bool IEquatable<Matrix3x3>.Equals(Matrix3x3 other)
|
||||
{
|
||||
if (this.GetHashCode()!=other.GetHashCode())
|
||||
{
|
||||
@@ -62,13 +62,13 @@ namespace StgSharp.Math
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() != typeof(Array3x3))
|
||||
else if (obj.GetType() != typeof(Matrix3x3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Array3x3)obj);
|
||||
return this.Equals((Matrix3x3)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,19 +79,19 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
|
||||
public static bool operator ==(Array3x3 array1, Array3x3 array2)
|
||||
public static bool operator ==(Matrix3x3 array1, Matrix3x3 array2)
|
||||
{
|
||||
return array1.Equals(array2);
|
||||
}
|
||||
|
||||
public static bool operator !=(Array3x3 array1, Array3x3 array2)
|
||||
public static bool operator !=(Matrix3x3 array1, Matrix3x3 array2)
|
||||
{
|
||||
return !array1.Equals(array2);
|
||||
}
|
||||
|
||||
public static Array3x3 operator +(Array3x3 array1, Array3x3 array2)
|
||||
public static Matrix3x3 operator +(Matrix3x3 array1, Matrix3x3 array2)
|
||||
{
|
||||
return new Array3x3(
|
||||
return new Matrix3x3(
|
||||
array1.row1.X + array2.row1.X,
|
||||
array1.row1.Y + array2.row1.Y,
|
||||
array1.row1.Z + array2.row1.Z,
|
||||
@@ -106,9 +106,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static Array3x3 operator -(Array3x3 array1, Array3x3 array2)
|
||||
public static Matrix3x3 operator -(Matrix3x3 array1, Matrix3x3 array2)
|
||||
{
|
||||
return new Array3x3(
|
||||
return new Matrix3x3(
|
||||
array1.row1.X - array2.row1.X,
|
||||
array1.row1.Y - array2.row1.Y,
|
||||
array1.row1.Z - array2.row1.Z,
|
||||
@@ -123,11 +123,14 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Array3x3 operator *(Array3x3 array1,Array3x3 array2)
|
||||
public static unsafe Matrix3x3 operator *(Matrix3x3 array1,Matrix3x3 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row1.X;
|
||||
return new Array3x3(
|
||||
|
||||
|
||||
|
||||
return new Matrix3x3(
|
||||
*(p1 + 0) * *(p2 + 0) + *(p1 + 1) * *(p2 + 3) + *(p1 + 2) * *(p2 + 6),
|
||||
*(p1 + 0) * *(p2 + 1) + *(p1 + 1) * *(p2 + 4) + *(p1 + 2) * *(p2 + 7),
|
||||
*(p1 + 0) * *(p2 + 2) + *(p1 + 1) * *(p2 + 5) + *(p1 + 2) * *(p2 + 8),
|
||||
@@ -140,18 +143,18 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static Array3x3 operator *(Array3x3 array, float x)
|
||||
public static Matrix3x3 operator *(Matrix3x3 array, float x)
|
||||
{
|
||||
return new Array3x3(
|
||||
return new Matrix3x3(
|
||||
array.row1 * x,
|
||||
array.row2 * x,
|
||||
array.row3 * x
|
||||
);
|
||||
}
|
||||
|
||||
public static Array3x3 operator /(Array3x3 array, float x)
|
||||
public static Matrix3x3 operator /(Matrix3x3 array, float x)
|
||||
{
|
||||
return new Array3x3(
|
||||
return new Matrix3x3(
|
||||
array.row1/x,
|
||||
array.row2/x,
|
||||
array.row3/x
|
||||
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array4x2:IEquatable<Array4x2>
|
||||
public struct Matrix4x2:IEquatable<Matrix4x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec2D row1;
|
||||
@@ -18,7 +17,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(24)]
|
||||
public Vec2D row4;
|
||||
|
||||
public Array4x2(Vec2D r1, Vec2D r2, Vec2D r3, Vec2D r4)
|
||||
public Matrix4x2(Vec2D r1, Vec2D r2, Vec2D r3, Vec2D r4)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
@@ -32,13 +31,13 @@ namespace StgSharp.Math
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj.GetType() == typeof(Array4x2))
|
||||
else if (obj.GetType() == typeof(Matrix4x2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Equals((Array4x2)obj);
|
||||
return this.Equals((Matrix4x2)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ namespace StgSharp.Math
|
||||
return $"{row1}\n{row2}\n{row3}\n{row4}";
|
||||
}
|
||||
|
||||
bool IEquatable<Array4x2>.Equals(Array4x2 other)
|
||||
bool IEquatable<Matrix4x2>.Equals(Matrix4x2 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
@@ -67,7 +66,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe Array4x4 operator *(Array4x2 array1, Array2x4 array2)
|
||||
public static unsafe Matrix4x4 operator *(Matrix4x2 array1,Matrix4x2 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row1.X;
|
||||
@@ -108,13 +107,12 @@ namespace StgSharp.Math
|
||||
var u6 = u3 - m4;
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new Array4x4(
|
||||
return new Matrix4x4(
|
||||
new Vec4D(u1.row1, u5.row1),
|
||||
new Vec4D(u1.row2, u5.row2),
|
||||
new Vec4D(u6.row1, u7.row1),
|
||||
new Vec4D(u6.row2, u7.row2)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Array4x4:IEquatable<Array4x4>
|
||||
public struct Matrix4x4:IEquatable<Matrix4x4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public Vec4D row1;
|
||||
@@ -17,7 +17,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(48)]
|
||||
public Vec4D row4;
|
||||
|
||||
public Array4x4(Vec4D r1, Vec4D r2, Vec4D r3, Vec4D r4)
|
||||
public Matrix4x4(Vec4D r1, Vec4D r2, Vec4D r3, Vec4D r4)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
@@ -25,7 +25,7 @@ namespace StgSharp.Math
|
||||
row4 = r4;
|
||||
}
|
||||
|
||||
public Array4x4(
|
||||
public Matrix4x4(
|
||||
float a11, float a12, float a13, float a14,
|
||||
float a21, float a22, float a23, float a24,
|
||||
float a31, float a32, float a33, float a34,
|
||||
@@ -43,7 +43,7 @@ namespace StgSharp.Math
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
bool IEquatable<Array4x4>.Equals(Array4x4 other)
|
||||
bool IEquatable<Matrix4x4>.Equals(Matrix4x4 other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
@@ -68,9 +68,9 @@ namespace StgSharp.Math
|
||||
return $"{this.row1}\n{this.row2}\n{this.row3}\n{this.row4}";
|
||||
}
|
||||
|
||||
public static Array4x4 operator +(Array4x4 array1, Array4x4 array2)
|
||||
public static Matrix4x4 operator +(Matrix4x4 array1, Matrix4x4 array2)
|
||||
{
|
||||
return new Array4x4(
|
||||
return new Matrix4x4(
|
||||
array1.row1 + array2.row1,
|
||||
array1.row2 + array2.row2,
|
||||
array1.row3 + array2.row3,
|
||||
@@ -78,9 +78,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static Array4x4 operator -(Array4x4 array1, Array4x4 array2)
|
||||
public static Matrix4x4 operator -(Matrix4x4 array1, Matrix4x4 array2)
|
||||
{
|
||||
return new Array4x4(
|
||||
return new Matrix4x4(
|
||||
array1.row1 - array2.row1,
|
||||
array1.row2 - array2.row2,
|
||||
array1.row3 - array2.row3,
|
||||
@@ -88,9 +88,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static Array4x4 operator *(Array4x4 array, float x)
|
||||
public static Matrix4x4 operator *(Matrix4x4 array, float x)
|
||||
{
|
||||
return new Array4x4(
|
||||
return new Matrix4x4(
|
||||
array.row1 * x,
|
||||
array.row2 * x,
|
||||
array.row3 * x,
|
||||
@@ -98,20 +98,20 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static unsafe Array4x4 operator *(Array4x4 array1, Array4x4 array2)
|
||||
public static unsafe Matrix4x4 operator *(Matrix4x4 array1, Matrix4x4 array2)
|
||||
{
|
||||
float* p1 = &array1.row1.X;
|
||||
float* p2 = &array2.row1.X;
|
||||
|
||||
Array2x2 a11 = new Array2x2(*p1,*(p1 + 1),*(p1 + 4),*(p1 + 5));
|
||||
Array2x2 a12 = new Array2x2(*(p1 + 2), *(p1 + 3),*(p1 + 6),*(p1 + 7));
|
||||
Array2x2 a21 = new Array2x2(*(p1 + 8), *(p1 + 9),*(p1 + 12),*(p1 + 13));
|
||||
Array2x2 a22 = new Array2x2(*(p1 + 10), *(p1 + 11),*(p1 + 14),*(p1 + 15));
|
||||
Matrix2x2 a11 = new Matrix2x2(*p1,*(p1 + 1),*(p1 + 4),*(p1 + 5));
|
||||
Matrix2x2 a12 = new Matrix2x2(*(p1 + 2), *(p1 + 3),*(p1 + 6),*(p1 + 7));
|
||||
Matrix2x2 a21 = new Matrix2x2(*(p1 + 8), *(p1 + 9),*(p1 + 12),*(p1 + 13));
|
||||
Matrix2x2 a22 = new Matrix2x2(*(p1 + 10), *(p1 + 11),*(p1 + 14),*(p1 + 15));
|
||||
|
||||
Array2x2 b11 = new Array2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
|
||||
Array2x2 b12 = new Array2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
|
||||
Array2x2 b21 = new Array2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
|
||||
Array2x2 b22 = new Array2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
|
||||
Matrix2x2 b11 = new Matrix2x2(*p1, *(p1 + 1), *(p1 + 4), *(p1 + 5));
|
||||
Matrix2x2 b12 = new Matrix2x2(*(p1 + 2), *(p1 + 3), *(p1 + 6), *(p1 + 7));
|
||||
Matrix2x2 b21 = new Matrix2x2(*(p1 + 8), *(p1 + 9), *(p1 + 12), *(p1 + 13));
|
||||
Matrix2x2 b22 = new Matrix2x2(*(p1 + 10), *(p1 + 11), *(p1 + 14), *(p1 + 15));
|
||||
|
||||
var s1 = a21 + a22;
|
||||
var s2 = s1 - a11;
|
||||
@@ -139,7 +139,7 @@ namespace StgSharp.Math
|
||||
var u6 = u3 - m4;
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new Array4x4(
|
||||
return new Matrix4x4(
|
||||
new Vec4D(u1.row1,u5.row1),
|
||||
new Vec4D(u1.row2,u5.row2),
|
||||
new Vec4D(u6.row1,u7.row1),
|
||||
@@ -85,6 +85,11 @@ namespace StgSharp.Math
|
||||
return vec1.X * vec2.X + vec1.Y*vec2.Y;
|
||||
}
|
||||
|
||||
public static float operator *(Vec2D vec, Colum2D colum)
|
||||
{
|
||||
return vec.X * colum.Y + vec.Y * colum.X;
|
||||
}
|
||||
|
||||
public static Vec2D operator *(Vec2D vec, float x)
|
||||
{
|
||||
return new Vec2D(vec.X * x, vec.Y * x);
|
||||
|
||||
@@ -7,24 +7,24 @@ namespace StgSharp.Math
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
|
||||
public static float Det(Array2x2 array)
|
||||
public static float Det(Matrix2x2 array)
|
||||
{
|
||||
return Cross(array.row1,array.row2);
|
||||
}
|
||||
|
||||
public static unsafe float Det(Array3x3 array)
|
||||
public static unsafe float Det(Matrix3x3 array)
|
||||
{
|
||||
float* p = &array.row1.X;
|
||||
|
||||
Array2x2 array1 = new Array2x2(
|
||||
Matrix2x2 array1 = new Matrix2x2(
|
||||
*(p + 4), *(p + 5),
|
||||
*(p + 7), *(p + 8)
|
||||
);
|
||||
Array2x2 array2 = new Array2x2(
|
||||
Matrix2x2 array2 = new Matrix2x2(
|
||||
*(p + 3), *(p + 5),
|
||||
*(p + 6), *(p + 8)
|
||||
);
|
||||
Array2x2 array3 = new Array2x2(
|
||||
Matrix2x2 array3 = new Matrix2x2(
|
||||
*(p + 3), *(p + 4),
|
||||
*(p + 6), *(p + 7)
|
||||
);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user