daily update on 2024.03.18 by itload youmu

This commit is contained in:
YoumuLiu
2024-03-19 02:41:04 +08:00
parent 15bf989285
commit 0c50c6282e
200 changed files with 7663 additions and 3455 deletions
+32 -1
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ACos.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Runtime.CompilerServices;
namespace StgSharp.Math
@@ -75,5 +105,6 @@ namespace StgSharp.Math
return piby2 - v;
*/
}
}
}
+32 -1
View File
@@ -1,4 +1,34 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ASin.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//
//
// some of the code is rewritten from the AMD code:
// https://github.com/amd/aocl-libm-ose/blob/a43e092b03213eb0e129a1cc129900e6e4475778/src/ref/asinf.c
@@ -89,5 +119,6 @@ namespace StgSharp.Math
return sign * v;
*/
}
}
}
+32 -1
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ATan.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Runtime.CompilerServices;
namespace StgSharp.Math
@@ -84,5 +114,6 @@ namespace StgSharp.Math
return v;
*/
}
}
}
+33 -1
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="BasicOps.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
@@ -6,6 +36,7 @@ namespace StgSharp.Math
{
public static unsafe partial class Scaler
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe float Abs(float x)
{
@@ -36,5 +67,6 @@ namespace StgSharp.Math
return CultureInfo.CurrentCulture.TextInfo.ListSeparator;
}
}
}
+34 -3
View File
@@ -1,4 +1,34 @@
namespace StgSharp.Math
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Cos.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Math
{
public static partial class Scaler
{
@@ -15,8 +45,9 @@
float refer2 = refer * refer;
return -sinData[a] * (0.1570796327f * refer - 6.459640975e-4f * refer * refer2)
+ cosData[a] * (1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2);
return ((-sinData[a]) * ((0.1570796327f * refer) - (6.459640975e-4f * refer * refer2)))
+ (cosData[a] * ((1 - (0.0123370055f * refer2)) + (2.536695709e-5f * refer2 * refer2)));
}
}
}
+41 -9
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Ctor.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace StgSharp.Math
@@ -7,18 +37,20 @@ namespace StgSharp.Math
public static unsafe partial class Scaler
{
const uint MEM_COMMIT = 0x1000;
const uint MEM_RELEASE = 0x8000;
const uint MEM_RESERVE = 0x2000;
const uint PAGE_EXECUTE_READWRITE = 0x40;
static Scaler()
{
}
[DllImport("Kernel32.dll", EntryPoint = "VirtualAlloc")]
private static extern IntPtr VirtualAlloc(IntPtr address, int size, uint allocType, uint protect);
[DllImport("Kernel32.dll", EntryPoint = "VirtualFree")]
private static extern bool VirtualFree(IntPtr address, int size, uint freeType);
const uint MEM_COMMIT = 0x1000;
const uint MEM_RESERVE = 0x2000;
const uint PAGE_EXECUTE_READWRITE = 0x40;
const uint MEM_RELEASE = 0x8000;
static Scaler()
{
}
}
}
+47 -15
View File
@@ -1,9 +1,40 @@
namespace StgSharp.Math
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Exp.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Math
{
public static unsafe partial class Scaler
{
public const float E = 2.718281828f;
/// <summary>
/// Get the value of E ^ x;
/// </summary>
@@ -30,12 +61,12 @@
float z = x, t;
if (x < 0.5f)
{
t = 1.0f + x * (
1.0f + x * (
0.5f + x * (
0.1666666667f + x * (
0.0416666666667f + x *
8.333333333e-3f))));
t = 1.0f + (x * (
1.0f + (x * (
0.5f + (x * (
0.1666666667f + (x * (
0.0416666666667f + (x *
8.333333333e-3f)))))))));
}
else
{
@@ -45,20 +76,20 @@
*/
uint zBit = *(uint*)&z;
uint zBitAbs = zBit & 0b_0111_1111_1111_1111_1111_1111_1111_1111;
uint uintm = (zBitAbs >> 23);
uint uintm = zBitAbs >> 23;
int m = (*(int*)&uintm) - 126;
uint nBit = (zBitAbs & 0b_0000_0000_0111_1111_1111_1111_1111_1111)
+ 0b_0011_1111_0000_0000_0000_0000_0000_0000;
float n = *(float*)&nBit - 1;
float n = (*(float*)&nBit) - 1;
t = 2.718281828f + n * (
2.718281828f + n * (
1.359140914f + n * (
0.4530469714f + n * (
0.1132617429f + n *
0.02265234857f))));
t = 2.718281828f + (n * (
2.718281828f + (n * (
1.359140914f + (n * (
0.4530469714f + (n * (
0.1132617429f + (n *
0.02265234857f)))))))));
for (int i = 0; i < m; i++)
{
@@ -72,5 +103,6 @@
}
return t;
}
}
}
+31 -1
View File
@@ -1,4 +1,34 @@
namespace StgSharp.Math
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Function.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Math
{
public class Function
{
+38 -8
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Log.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
namespace StgSharp.Math
{
@@ -41,16 +71,16 @@ namespace StgSharp.Math
input >>= 9;
input += 0b_0011_1111_1000_0000_0000_0000_0000_0000;
float result = *(float*)&input;
uint order = (uint)(result * 100) - 100;
float cache = (result) / (1f + 0.01f * order) - 1;
result = cache * -0.25f + 0.3333333333333f;
result = result * cache - 0.5f;
result = result * cache + 1.0f;
uint order = ((uint)(result * 100)) - 100;
float cache = (result / (1f + (0.01f * order))) - 1;
result = (cache * (-0.25f)) + 0.3333333333333f;
result = (result * cache) - 0.5f;
result = (result * cache) + 1.0f;
result *= cache;
return
f * 0.6931471806f +
(f * 0.6931471806f) +
result +
logArray[order];
}
+50 -18
View File
@@ -1,7 +1,38 @@
namespace StgSharp.Math
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Pow.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Math
{
public static unsafe partial class Scaler
{
/// <summary>
/// calculate the value of x^y
/// </summary>
@@ -23,15 +54,15 @@
*
*/
float z, t;
if (x == 1 || y == 0)
if ((x == 1) || (y == 0))
{
return 1;
}
if (x == 1 && y == 0)
if ((x == 1) && (y == 0))
{
return float.PositiveInfinity;
}
if (x==0&&y!=0)
if ((x == 0) && (y != 0))
{
return 0;
}
@@ -47,31 +78,31 @@
if (z < 0.5f)
{
t = 1.0f + z * (
1.0f + z * (
0.5f + z * (
0.1666666667f + z * (
0.0416666666667f + z *
8.333333333e-3f))));
t = 1.0f + (z * (
1.0f + (z * (
0.5f + (z * (
0.1666666667f + (z * (
0.0416666666667f + (z *
8.333333333e-3f)))))))));
}
else
{
uint zBit = *(uint*)&z;
uint zBitAbs = zBit & 0b_0111_1111_1111_1111_1111_1111_1111_1111;
uint uintm = (zBitAbs >> 23);
uint uintm = zBitAbs >> 23;
int m = (*(int*)&uintm) - 126;
uint nBit = (zBitAbs & 0b_0000_0000_0111_1111_1111_1111_1111_1111)
+ 0b_0011_1111_0000_0000_0000_0000_0000_0000;
float n = *(float*)&nBit - 1;
float n = (*(float*)&nBit) - 1;
t = 2.718281828f + n * (
2.718281828f + n * (
1.359140914f + n * (
0.4530469714f + n * (
0.1132617429f + n *
0.02265234857f))));
t = 2.718281828f + (n * (
2.718281828f + (n * (
1.359140914f + (n * (
0.4530469714f + (n * (
0.1132617429f + (n *
0.02265234857f)))))))));
for (int i = 0; i < m; i++)
{
@@ -87,5 +118,6 @@
return t;
}
}
}
+43 -11
View File
@@ -1,4 +1,35 @@
using StgSharp.Controlling;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Random.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@@ -16,15 +47,6 @@ namespace StgSharp.Math
= Abs(System.DateTime.UtcNow.GetHashCode());
#endif
/// <summary>
///
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Random()
{
throw new NotImplementedException();
}
/// <summary>
/// returns a random float number between 0 and 1.
@@ -46,7 +68,7 @@ namespace StgSharp.Math
currentSeed = sample;
sample2 *= 1000000;
float result = sample2 - (int)sample2;
float result = sample2 - ((int)sample2);
if (result == 0)
{
currentSeed = sample2 + 0.1f;
@@ -55,6 +77,15 @@ namespace StgSharp.Math
return result;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Random()
{
throw new NotImplementedException();
}
/// <summary>
/// Generates a random seed in int value.
@@ -70,5 +101,6 @@ namespace StgSharp.Math
return *(int*)&seedValue;
}
}
}
+49 -16
View File
@@ -1,11 +1,56 @@
using System.Net.NetworkInformation;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Sin.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System.Net.NetworkInformation;
namespace StgSharp.Math
{
public static partial class Scaler
{
public const float Pi = 3.1415926f;
private static readonly float[] cosData =
{
1f, 0.987688341014302f, 0.951056517951169f, 0.891006527837756f, 0.809017000674805f,
0.707106790659974f, 0.587785265298989f, 0.453990516451646f, 0.309017014761716f, 0.156434488858737f,
2.67948965850537E-08f, -0.156434435928723f, -0.309016963794794f, -0.453990468702791f, -0.587785221943935f,
-0.707106752766267f, -0.809016969175515f, -0.891006503508499f, -0.951056501391011f, -0.98768833263101f,
-0.999999999999999f, -0.987688349397591f, -0.951056534511324f, -0.891006552167012f, -0.809017032174094f,
-0.707106828553679f, -0.587785308654041f, -0.4539905642005f, -0.309017065728638f, -0.156434541788751f,
-8.03846893110719E-08f, 0.156434382998709f, 0.309016912827872f, 0.453990420953934f, 0.58778517858888f,
0.707106714872559f, 0.809016937676222f, 0.891006479179238f, 0.951056484830851f, 0.987688324247716f,
};
private static readonly float[] sinData =
{
0f, 0.15643446239373f, 0.309016989278255f, 0.453990492577218f, 0.587785243621462f,
@@ -18,19 +63,6 @@ namespace StgSharp.Math
-0.70710684750053f, -0.587785330331566f, -0.453990588074927f, -0.309017091212098f, -0.156434568253757f,
};
private static readonly float[] cosData =
{
1f, 0.987688341014302f, 0.951056517951169f, 0.891006527837756f, 0.809017000674805f,
0.707106790659974f, 0.587785265298989f, 0.453990516451646f, 0.309017014761716f, 0.156434488858737f,
2.67948965850537E-08f, -0.156434435928723f, -0.309016963794794f, -0.453990468702791f, -0.587785221943935f,
-0.707106752766267f, -0.809016969175515f, -0.891006503508499f, -0.951056501391011f, -0.98768833263101f,
-0.999999999999999f, -0.987688349397591f, -0.951056534511324f, -0.891006552167012f, -0.809017032174094f,
-0.707106828553679f, -0.587785308654041f, -0.4539905642005f, -0.309017065728638f, -0.156434541788751f,
-8.03846893110719E-08f, 0.156434382998709f, 0.309016912827872f, 0.453990420953934f, 0.58778517858888f,
0.707106714872559f, 0.809016937676222f, 0.891006479179238f, 0.951056484830851f, 0.987688324247716f,
};
public static unsafe float Sin(float x)
@@ -45,8 +77,9 @@ namespace StgSharp.Math
float refer2 = refer * refer;
return sinData[a] * (1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2)
+ cosData[a] * (0.1570796327f * refer - 6.459640975e-4f * refer * refer2);
return (sinData[a] * ((1 - (0.0123370055f * refer2)) + (2.536695709e-5f * refer2 * refer2)))
+ (cosData[a] * ((0.1570796327f * refer) - (6.459640975e-4f * refer * refer2)));
}
}
}
+40 -9
View File
@@ -1,16 +1,40 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Sqrt.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Runtime.CompilerServices;
namespace StgSharp.Math
{
public static partial class Scaler
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sqrt(float x)
{
return MathF.Sqrt(x);
/**/
}
public static unsafe float SeedSqrt(float x)
{
@@ -73,8 +97,15 @@ namespace StgSharp.Math
e += f;
float result = *(float*)&e;
result = (result + x / result) / 2;
return (result + x / result) / 2;
result = (result + (x / result)) / 2;
return (result + (x / result)) / 2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sqrt(float x)
{
return MathF.Sqrt(x);
/**/
}
}
}
+36 -5
View File
@@ -1,4 +1,34 @@
namespace StgSharp.Math
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="Tan.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Math
{
public static partial class Scaler
{
@@ -14,11 +44,12 @@
float refer2 = refer * refer;
float sin = (0.1570796327f * refer - 6.459640975e-4f * refer * refer2);
float cos = (1 - 0.0123370055f * refer2 + 2.536695709e-5f * refer2 * refer2);
float sin = (0.1570796327f * refer) - (6.459640975e-4f * refer * refer2);
float cos = (1 - (0.0123370055f * refer2)) + (2.536695709e-5f * refer2 * refer2);
return (sinData[a] * cos + cosData[a] * sin)
/ (cosData[a] * cos - sinData[a] * sin);
return ((sinData[a] * cos) + (cosData[a] * sin))
/ ((cosData[a] * cos) - (sinData[a] * sin));
}
}
}