diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/3f80c49f-9ff1-4ff8-910f-3929b682bc8e.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/3f80c49f-9ff1-4ff8-910f-3929b682bc8e.vsidx deleted file mode 100644 index 52659fa1..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/3f80c49f-9ff1-4ff8-910f-3929b682bc8e.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/9767babd-b24b-4233-91a4-9644e0d2d644.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx similarity index 76% rename from 源代码/.Net/.vs/StgSharp/FileContentIndex/9767babd-b24b-4233-91a4-9644e0d2d644.vsidx rename to 源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx index 6a504d60..c71ca17e 100644 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/9767babd-b24b-4233-91a4-9644e0d2d644.vsidx and b/源代码/.Net/.vs/StgSharp/FileContentIndex/4d486994-9111-43bd-bd68-fbb0688a435f.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/963a0646-af8f-4b53-8a7d-931faac5ec1e.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/963a0646-af8f-4b53-8a7d-931faac5ec1e.vsidx deleted file mode 100644 index ee1e8375..00000000 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/963a0646-af8f-4b53-8a7d-931faac5ec1e.vsidx and /dev/null differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/ca84bfd9-ee94-4446-855d-d40cb3987226.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/ca84bfd9-ee94-4446-855d-d40cb3987226.vsidx new file mode 100644 index 00000000..3ad56a69 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/ca84bfd9-ee94-4446-855d-d40cb3987226.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/d47b1dd6-e5fc-4d4a-af67-061e60bce51b.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/d47b1dd6-e5fc-4d4a-af67-061e60bce51b.vsidx new file mode 100644 index 00000000..e885cd11 Binary files /dev/null and b/源代码/.Net/.vs/StgSharp/FileContentIndex/d47b1dd6-e5fc-4d4a-af67-061e60bce51b.vsidx differ diff --git a/源代码/.Net/.vs/StgSharp/FileContentIndex/4b7aac9c-a92f-42c1-bd0c-924d92beaf29.vsidx b/源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx similarity index 75% rename from 源代码/.Net/.vs/StgSharp/FileContentIndex/4b7aac9c-a92f-42c1-bd0c-924d92beaf29.vsidx rename to 源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx index 1dbcd9e8..aba7ca38 100644 Binary files a/源代码/.Net/.vs/StgSharp/FileContentIndex/4b7aac9c-a92f-42c1-bd0c-924d92beaf29.vsidx and b/源代码/.Net/.vs/StgSharp/FileContentIndex/f912e19e-ea74-4103-88aa-083bf7feb61a.vsidx differ diff --git a/源代码/.Net/StgSharp/Math/ACos.cs b/源代码/.Net/StgSharp/Math/ACos.cs index 1bb31d21..5993110d 100644 --- a/源代码/.Net/StgSharp/Math/ACos.cs +++ b/源代码/.Net/StgSharp/Math/ACos.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static unsafe partial class Calc + public static unsafe partial class Math { diff --git a/源代码/.Net/StgSharp/Math/ASin.cs b/源代码/.Net/StgSharp/Math/ASin.cs index 9ed261d6..b7b5b464 100644 --- a/源代码/.Net/StgSharp/Math/ASin.cs +++ b/源代码/.Net/StgSharp/Math/ASin.cs @@ -1,4 +1,6 @@ -// some of the code is rewritten from the AMD code: +// +// +// some of the code is rewritten from the AMD code: // https://github.com/amd/aocl-libm-ose/blob/a43e092b03213eb0e129a1cc129900e6e4475778/src/ref/asinf.c @@ -7,9 +9,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static unsafe partial class Calc + public static unsafe partial class Math { private const float diff --git a/源代码/.Net/StgSharp/Math/ATan.cs b/源代码/.Net/StgSharp/Math/ATan.cs new file mode 100644 index 00000000..4407e164 --- /dev/null +++ b/源代码/.Net/StgSharp/Math/ATan.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace StgSharp +{ + public static unsafe partial class Math + { + public static unsafe float ATan(float x) + { + float sign = 1, angle = 0; + if (x < 0) + { + sign = -1; + x = -x; + } + uint xBit = *(uint*)&x; + int xExp = (int)(xBit >> 23) - 127; + if (xExp >= 26) + { + return 1; + } + if (xExp <= -15) + { + return x; + } + if (xExp >= 0) + { + x = (x - 1) / (x + 1); + angle = 0.7853981634f; + } + + float v = 0.7853981634f * x + x * (1 - x) * (0.2447f+0.0663f * x); + v += angle; + v *= sign; + + return v; + + + } + + + public static unsafe float ATan(float x, float y) + { + + + float z = y / x; + + float sign = 1, angle = 0,angle2 = 0; + if (x<0) + { + angle = -3.1415926535f ; + } + if (z < 0) + { + sign = -1; + z = -z; + } + uint zBit = *(uint*)&z; + int zExp = (int)(zBit >> 23) - 127; + if (zExp >= 26) + { + return 1; + } + if (zExp <= -15) + { + return z; + } + if (zExp >= 0) + { + z = (z - 1) / (z + 1); + angle2 = 0.7853981634f; + } + + float v = 0.7853981634f * z + z * (1 - z) * (0.2447f + 0.0663f * z); + v *= 57.29577951f; + v += angle2; + v += angle; + v *= sign; + + return v; + + } + } +} diff --git a/源代码/.Net/StgSharp/Math/Cos.cs b/源代码/.Net/StgSharp/Math/Cos.cs index c0360ecc..0ea99d07 100644 --- a/源代码/.Net/StgSharp/Math/Cos.cs +++ b/源代码/.Net/StgSharp/Math/Cos.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static partial class Calc + public static partial class Math { public static float Cos(float x) diff --git a/源代码/.Net/StgSharp/Math/Exp.cs b/源代码/.Net/StgSharp/Math/Exp.cs index 1e4323d1..340b37e7 100644 --- a/源代码/.Net/StgSharp/Math/Exp.cs +++ b/源代码/.Net/StgSharp/Math/Exp.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static unsafe partial class Calc + public static unsafe partial class Math { public const float E = 2.718281828f; diff --git a/源代码/.Net/StgSharp/Math/GetBits32.cs b/源代码/.Net/StgSharp/Math/GetBits32.cs index 2673c8c0..edba6467 100644 --- a/源代码/.Net/StgSharp/Math/GetBits32.cs +++ b/源代码/.Net/StgSharp/Math/GetBits32.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static unsafe partial class Calc + + + public static unsafe partial class Math { /// diff --git a/源代码/.Net/StgSharp/Math/Log.cs b/源代码/.Net/StgSharp/Math/Log.cs index 50b5505e..5a38f96c 100644 --- a/源代码/.Net/StgSharp/Math/Log.cs +++ b/源代码/.Net/StgSharp/Math/Log.cs @@ -4,9 +4,12 @@ using System.Net.Sockets; using System.Text; using static System.Net.WebRequestMethods; -namespace StgSharp.Math +namespace StgSharp { - public static partial class Calc + + + + public static partial class Math { static private readonly float[] logArray = diff --git a/源代码/.Net/StgSharp/Math/Pow.cs b/源代码/.Net/StgSharp/Math/Pow.cs index 54ce270f..a88b9159 100644 --- a/源代码/.Net/StgSharp/Math/Pow.cs +++ b/源代码/.Net/StgSharp/Math/Pow.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static unsafe partial class Calc + public static unsafe partial class Math { /// /// calculate the value of x^y @@ -35,7 +35,7 @@ namespace StgSharp.Math { return 1.0f / 0; } - z = StgSharp.Math.Calc.Log(x) * y; + z = StgSharp.Math.Log(x) * y; bool sign = false; if (z < 0) diff --git a/源代码/.Net/StgSharp/Math/Sin.cs b/源代码/.Net/StgSharp/Math/Sin.cs index 6bbc6b19..24753133 100644 --- a/源代码/.Net/StgSharp/Math/Sin.cs +++ b/源代码/.Net/StgSharp/Math/Sin.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static partial class Calc + public static partial class Math { private static readonly float[] sinData = { diff --git a/源代码/.Net/StgSharp/Math/Sqrt.cs b/源代码/.Net/StgSharp/Math/Sqrt.cs index fa41e7c1..740fa82b 100644 --- a/源代码/.Net/StgSharp/Math/Sqrt.cs +++ b/源代码/.Net/StgSharp/Math/Sqrt.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static partial class Clac + public static partial class Math { /*本方法将小数部分统一提升至2^16处后进行线性近似 const uint sqmov = 0b_0100_0111_1000_0000_0000_0000_0000_0000; diff --git a/源代码/.Net/StgSharp/Math/Tan.cs b/源代码/.Net/StgSharp/Math/Tan.cs index 8cefd2b5..ccea7a1b 100644 --- a/源代码/.Net/StgSharp/Math/Tan.cs +++ b/源代码/.Net/StgSharp/Math/Tan.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace StgSharp.Math +namespace StgSharp { - public static partial class Calc + public static partial class Math { public static float Tan(float x) diff --git a/源代码/.Net/StgSharp/Vector/Vec2x1.cs b/源代码/.Net/StgSharp/Vector/Vec2x1.cs index ee5f3fb8..e94b0be8 100644 --- a/源代码/.Net/StgSharp/Vector/Vec2x1.cs +++ b/源代码/.Net/StgSharp/Vector/Vec2x1.cs @@ -1,34 +1,82 @@ -using System; +using StgSharp.Math; +using System; using System.Collections.Generic; using System.Text; namespace StgSharp.Vector { - public struct Vec2x1:IEquatable + public struct Vec2D:IEquatable { - float a1; - float a2; + float X; + float Y; + float Direction; + float Length; - public Vec2x1(float x,float y) + public Vec2D(float x,float y) { - a1 = x; - a2 = y; + X = x; + Y = y; + Direction = 0; } - public bool Equals(Vec2x1 other) + public bool Equals(Vec2D other) { - return true; + if (this.GetHashCode() != other.GetHashCode()) + { + return false; + } + else + { + return this.X == other.X && this.Y == other.Y; + } } - - public static bool operator ==(Vec2x1 vec1, Vec2x1 vec2) + public override bool Equals(object obj) { - return true; + if (obj == null) + { + return false; + } + else if (obj.GetType() != typeof(Vec2D)) + { + return false; + } + else + { + return this.Equals((Vec2D)obj); + } } - public static bool operator !=(Vec2x1 vec1, Vec2x1 vec2) + public override int GetHashCode() { - return false; + return HashCode.Combine(X, Y); } + + public override string ToString() + { + return $"{this.X},{this.Y}"; + } + + public static bool operator ==(Vec2D vec1, Vec2D vec2) + { + return vec1.X==vec2.X && vec1.Y==vec2.Y; + } + + public static bool operator !=(Vec2D vec1, Vec2D vec2) + { + return !(vec1.X == vec2.X && vec1.Y == vec2.Y); + } + + public static Vec2D operator +(Vec2D vec1, Vec2D vec2) + { + return new Vec2D(vec1.X + vec2.X, vec1.Y + vec2.Y); + } + + public static Vec2D operator -(Vec2D vec1, Vec2D vec2) + { + return new Vec2D(vec1.X + vec2.X, vec1.Y + vec2.Y); + } + + public static } }