diff --git a/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 b/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 index da6d6604..07c91685 100644 Binary files a/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 and b/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 differ diff --git a/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 b/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 index 0de57473..1c8b5134 100644 Binary files a/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 and b/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 differ diff --git a/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 b/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 index 1c45c3ea..9587aa0e 100644 Binary files a/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 and b/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/02e605d8-8bb4-4fa5-a768-47173fe610fc.vsidx b/源代码/.vs/StgSharp/FileContentIndex/02e605d8-8bb4-4fa5-a768-47173fe610fc.vsidx deleted file mode 100644 index 772fb4f7..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/02e605d8-8bb4-4fa5-a768-47173fe610fc.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/1caf3308-b470-4bbd-bd51-e724ffc37f30.vsidx b/源代码/.vs/StgSharp/FileContentIndex/1caf3308-b470-4bbd-bd51-e724ffc37f30.vsidx new file mode 100644 index 00000000..9c076162 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/1caf3308-b470-4bbd-bd51-e724ffc37f30.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/32cc1b37-1421-4222-a9bb-831184eb9b84.vsidx b/源代码/.vs/StgSharp/FileContentIndex/32cc1b37-1421-4222-a9bb-831184eb9b84.vsidx new file mode 100644 index 00000000..f04e9cf6 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/32cc1b37-1421-4222-a9bb-831184eb9b84.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/38a68dbb-54c1-4c57-b638-8c3ecf565224.vsidx b/源代码/.vs/StgSharp/FileContentIndex/38a68dbb-54c1-4c57-b638-8c3ecf565224.vsidx deleted file mode 100644 index 00e16596..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/38a68dbb-54c1-4c57-b638-8c3ecf565224.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/59b03b5a-ef58-42cf-9d71-d515c78cd50d.vsidx b/源代码/.vs/StgSharp/FileContentIndex/59b03b5a-ef58-42cf-9d71-d515c78cd50d.vsidx new file mode 100644 index 00000000..a227bce9 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/59b03b5a-ef58-42cf-9d71-d515c78cd50d.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/957be48a-aaba-47ac-a4cf-c44e24507de9.vsidx b/源代码/.vs/StgSharp/FileContentIndex/957be48a-aaba-47ac-a4cf-c44e24507de9.vsidx deleted file mode 100644 index 907d985b..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/957be48a-aaba-47ac-a4cf-c44e24507de9.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/b7cf57c0-098e-43a9-b7e8-f5ea0a164fb6.vsidx b/源代码/.vs/StgSharp/FileContentIndex/b7cf57c0-098e-43a9-b7e8-f5ea0a164fb6.vsidx deleted file mode 100644 index d7d32529..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/b7cf57c0-098e-43a9-b7e8-f5ea0a164fb6.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/f2091ccd-a003-4a43-8dd2-c027e5602dfc.vsidx b/源代码/.vs/StgSharp/FileContentIndex/f2091ccd-a003-4a43-8dd2-c027e5602dfc.vsidx new file mode 100644 index 00000000..c7c13973 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/f2091ccd-a003-4a43-8dd2-c027e5602dfc.vsidx differ diff --git a/源代码/.vs/StgSharp/v17/.futdcache.v2 b/源代码/.vs/StgSharp/v17/.futdcache.v2 index fff7f7de..4679572d 100644 Binary files a/源代码/.vs/StgSharp/v17/.futdcache.v2 and b/源代码/.vs/StgSharp/v17/.futdcache.v2 differ diff --git a/源代码/.vs/StgSharp/v17/.suo b/源代码/.vs/StgSharp/v17/.suo index 5b69acd6..6664a0a3 100644 Binary files a/源代码/.vs/StgSharp/v17/.suo and b/源代码/.vs/StgSharp/v17/.suo differ diff --git a/源代码/StgSharp/Vector/Array2x3.cs b/源代码/StgSharp/Vector/Array2x3.cs deleted file mode 100644 index e1ec6183..00000000 --- a/源代码/StgSharp/Vector/Array2x3.cs +++ /dev/null @@ -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 - { - [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.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) - ); - } - - } -} diff --git a/源代码/StgSharp/Vector/Array2x4.cs b/源代码/StgSharp/Vector/Array2x4.cs deleted file mode 100644 index 7de331bb..00000000 --- a/源代码/StgSharp/Vector/Array2x4.cs +++ /dev/null @@ -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 - { - [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) - ); - } - } -} diff --git a/源代码/StgSharp/Vector/Colum2D.cs b/源代码/StgSharp/Vector/Colum2D.cs index 90fba978..d62d1106 100644 --- a/源代码/StgSharp/Vector/Colum2D.cs +++ b/源代码/StgSharp/Vector/Colum2D.cs @@ -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 ); diff --git a/源代码/StgSharp/Vector/Array2x2.cs b/源代码/StgSharp/Vector/Matrix2x2.cs similarity index 81% rename from 源代码/StgSharp/Vector/Array2x2.cs rename to 源代码/StgSharp/Vector/Matrix2x2.cs index 22dd69d9..1c20f0a2 100644 --- a/源代码/StgSharp/Vector/Array2x2.cs +++ b/源代码/StgSharp/Vector/Matrix2x2.cs @@ -7,20 +7,20 @@ using System.Text; namespace StgSharp.Math { [StructLayout(LayoutKind.Explicit)] - public struct Array2x2:IEquatable + public struct Matrix2x2:IEquatable { [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.Equals(Array2x2 other) + bool IEquatable.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); } diff --git a/源代码/StgSharp/Vector/Matrix2x3.cs b/源代码/StgSharp/Vector/Matrix2x3.cs new file mode 100644 index 00000000..0b6cbb08 --- /dev/null +++ b/源代码/StgSharp/Vector/Matrix2x3.cs @@ -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 + { + [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.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( + + ); + } + + } +} diff --git a/源代码/StgSharp/Vector/Matrix2x4.cs b/源代码/StgSharp/Vector/Matrix2x4.cs new file mode 100644 index 00000000..709d15e6 --- /dev/null +++ b/源代码/StgSharp/Vector/Matrix2x4.cs @@ -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 + { + [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); + } + } +} diff --git a/源代码/StgSharp/Vector/Array3x2.cs b/源代码/StgSharp/Vector/Matrix3x2.cs similarity index 81% rename from 源代码/StgSharp/Vector/Array3x2.cs rename to 源代码/StgSharp/Vector/Matrix3x2.cs index b495e86c..2fa546dc 100644 --- a/源代码/StgSharp/Vector/Array3x2.cs +++ b/源代码/StgSharp/Vector/Matrix3x2.cs @@ -6,7 +6,7 @@ using System.Text; namespace StgSharp.Math { [StructLayout(LayoutKind.Explicit)] - public struct Array3x2:IEquatable + public struct Matrix3x2:IEquatable { [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.Equals(Array3x2 other) + bool IEquatable.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), diff --git a/源代码/StgSharp/Vector/Array3x3.cs b/源代码/StgSharp/Vector/Matrix3x3.cs similarity index 79% rename from 源代码/StgSharp/Vector/Array3x3.cs rename to 源代码/StgSharp/Vector/Matrix3x3.cs index a5b4f9ad..2774abbd 100644 --- a/源代码/StgSharp/Vector/Array3x3.cs +++ b/源代码/StgSharp/Vector/Matrix3x3.cs @@ -9,7 +9,7 @@ using System.Text; namespace StgSharp.Math { [StructLayout(LayoutKind.Explicit)] - public struct Array3x3:IEquatable + public struct Matrix3x3:IEquatable { [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.Equals(Array3x3 other) + bool IEquatable.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 diff --git a/源代码/StgSharp/Vector/Array4x2.cs b/源代码/StgSharp/Vector/Matrix4x2.cs similarity index 86% rename from 源代码/StgSharp/Vector/Array4x2.cs rename to 源代码/StgSharp/Vector/Matrix4x2.cs index f75ce298..a5497f7e 100644 --- a/源代码/StgSharp/Vector/Array4x2.cs +++ b/源代码/StgSharp/Vector/Matrix4x2.cs @@ -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 + public struct Matrix4x2:IEquatable { [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.Equals(Array4x2 other) + bool IEquatable.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) ); } - } } diff --git a/源代码/StgSharp/Vector/Array4x4.cs b/源代码/StgSharp/Vector/Matrix4x4.cs similarity index 71% rename from 源代码/StgSharp/Vector/Array4x4.cs rename to 源代码/StgSharp/Vector/Matrix4x4.cs index a6ce9d20..0b953df3 100644 --- a/源代码/StgSharp/Vector/Array4x4.cs +++ b/源代码/StgSharp/Vector/Matrix4x4.cs @@ -6,7 +6,7 @@ using System.Text; namespace StgSharp.Math { [StructLayout(LayoutKind.Explicit)] - public struct Array4x4:IEquatable + public struct Matrix4x4:IEquatable { [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.Equals(Array4x4 other) + bool IEquatable.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), diff --git a/源代码/StgSharp/Vector/Vec2D.cs b/源代码/StgSharp/Vector/Vec2D.cs index be2d6e79..3de30756 100644 --- a/源代码/StgSharp/Vector/Vec2D.cs +++ b/源代码/StgSharp/Vector/Vec2D.cs @@ -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); diff --git a/源代码/StgSharp/Vector/Vector.Det.cs b/源代码/StgSharp/Vector/Vector.Det.cs index a832f6e1..980e07ad 100644 --- a/源代码/StgSharp/Vector/Vector.Det.cs +++ b/源代码/StgSharp/Vector/Vector.Det.cs @@ -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) ); diff --git a/组织工作/算法实现统计表.xlsx b/组织工作/算法实现统计表.xlsx new file mode 100644 index 00000000..0070b4c9 Binary files /dev/null and b/组织工作/算法实现统计表.xlsx differ