daily update on 20230227 by nitload youmu

This commit is contained in:
Nitload
2023-02-27 16:56:31 +08:00
parent 770150767b
commit 035fb9a432
25 changed files with 268 additions and 96 deletions
Binary file not shown.
Binary file not shown.
+1 -86
View File
@@ -53,7 +53,7 @@ namespace StgSharp.Math
if (transform)
{
r = 0.5f * (1.0f - y);
s = StgSharp.Math.Sqrt(r);
s = Calc.Sqrt(r);
y = s;
}
else
@@ -90,90 +90,5 @@ namespace StgSharp.Math
return sign * v;
}
/// <summary>
/// Returns the angle whose sine is the quotient of two specified numbers.
/// </summary>
/// <param name="x">The x coordinate of a point.</param>
/// <param name="y">The y coordinate of a point.</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static unsafe float ASin(float x, float y)
{
bool isXNeg = (x < 0);
if (isXNeg)
{
x = -x;
}
float z = y /StgSharp.Math.Sqrt(x * x + y * y);
int sign = 1;
float t;
if (z < 0)
{
sign = -1;
t = -z;
}
else
{
t = z;
}
if (z > 1)
{
throw new ArgumentException();
}
float r, s, u, v = 0.0f;
bool transform = (t >= 0.5f);
if (transform)
{
r = 0.5f * (1.0f - t);
s = StgSharp.Math.Sqrt(r);
t = s;
}
else
{
r = t * t;
}
u = r * (0.184161606965100694821398249421F +
(-0.0565298683201845211985026327361F +
(-0.0133819288943925804214011424456F -
0.00396137437848476485201154797087F * r) * r) * r) /
(1.10496961524520294485512696706F -
0.836411276854206731913362287293F * r);
/**/
if (transform)
{
float c, s1, p, q;
uint us;
us = *(uint*)&s;
uint uss = us & 0xffff0000;
s1 = *(float*)&uss;
c = (r - s1 * s1) / (s + s1);
p = 2.0F * s * u - (piby2_tail - 2.0F * c);
q = hpiby2_head - 2.0F * s1;
v = hpiby2_head - (p - q);
}
else
{
v = t + t * u;
}/**/
if (isXNeg)
{
v = piby2 - x;
}
return sign * v;
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class calc
public static unsafe partial class Calc
{
/// <summary>
+1 -1
View File
@@ -6,7 +6,7 @@ using static System.Net.WebRequestMethods;
namespace StgSharp.Math
{
public static partial class calc
public static partial class Calc
{
static private readonly float[] logArray =
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public struct Array2x2
{
public Vec2D row0;
public Vec2D row1;
public Vec2D colum0;
public Vec2D colum1;
public Array2x2(Vec2D c0, Vec2D c1)
{
row0 = c0;
row1 = c1;
colum0 = new Vec2D(c0.X,c1.X);
colum1 = new Vec2D(c0.Y,c1.Y);
}
public Array2x2(
float a11,
float a12,
float a21,
float a22
)
{
row0 = new Vec2D(a11, a12);
row1 = new Vec2D(a21, a22);
colum0 = new Vec2D(a11, a21);
colum1 = new Vec2D(a21, a22);
}
public static Array2x2 operator *(Array2x2 array1, Array2x2 array2)
{
return new Array2x2(
array1.colum0 * array2.row0,
array1.colum1 * array2.row0,
array1.colum0 * array2.row1,
array1.colum1 * array2.row1
);
}
public static Array2x2 operator +(Array2x2 array1, Array2x2 array2)
{
return new Array2x2(
array1.row0 + array2.row0,
array1.row1 + array2.row1
);
}
public static Array2x2 operator -(Array2x2 array1, Array2x2 array2)
{
return new Array2x2(
array1.row0 - array2.row0,
array1.row1 - array2.row1
);
}
}
}
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace StgSharp.Math
{
public struct Array3x3
{
public Vec3D row0;
public Vec3D row1;
public Vec3D row2;
public Vec3D colum0;
public Vec3D colum1;
public Vec3D colum2;
public Array3x3(Vec3D r0,Vec3D r1,Vec3D r2)
{
row0 = r0;
row1 = r1;
row2 = r2;
colum0 = new Vec3D(r0.X, r1.X, r2.X);
colum1 = new Vec3D(r0.Y, r1.Y, r2.Y);
colum2 = new Vec3D(r0.Z, r1.Z, r2.Z);
}
public Array3x3(
float a11,float a12,float a13,
float a21,float a22,float a23,
float a31,float a32,float a33
)
{
row0 = new Vec3D(a11, a12, a13);
row1 = new Vec3D(a21, a22, a23);
row2 = new Vec3D(a31, a32, a33);
colum0 = new Vec3D(a11,a21,a31);
colum1 = new Vec3D(a12,a22,a32);
colum2 = new Vec3D(a13,a23,a33);
}
public static Array3x3 operator +(Array3x3 array1, Array3x3 array2)
{
return new Array3x3(
array1.row0.X + array2.row0.X,
array1.row0.Y + array2.row0.Y,
array1.row0.Z + array2.row0.Z,
array1.row1.X + array2.row1.X,
array1.row1.Y + array2.row1.Y,
array1.row1.Z + array2.row1.Z,
array1.row2.X + array2.row2.X,
array1.row2.Y + array2.row2.Y,
array1.row2.Z + array2.row2.Z
);
}
public static Array3x3 operator -(Array3x3 array1, Array3x3 array2)
{
return new Array3x3(
array1.row0.X - array2.row0.X,
array1.row0.Y - array2.row0.Y,
array1.row0.Z - array2.row0.Z,
array1.row1.X - array2.row1.X,
array1.row1.Y - array2.row1.Y,
array1.row1.Z - array2.row1.Z,
array1.row2.X - array2.row2.X,
array1.row2.Y - array2.row2.Y,
array1.row2.Z - array2.row2.Z
);
}
}
}
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static float Cross(Vec2D vec1, Vec2D vec2)
{
return vec1.X * vec2.Y - vec1.Y * vec2.X;
}
public static Vec3D Cross(Vec3D vec1, Vec3D vec2)
{
return new Vec3D(
vec1.Y * vec2.Z - vec1.Z * vec2.Y,
vec1.X * vec2.Z - vec1.Z * vec2.X,
vec1.X * vec2.Y - vec1.Y * vec2.X
);
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static float Det(Array2x2 array)
{
return Cross(array.row0,array.row1);
}
public static float Det(Array3x3 array)
{
return 0;
}
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static float GetAngle(Vec2D vec1, Vec2D vec2)
{
return Calc.ACos(
vec1 * vec2
/ (vec1.GetLength() * vec2.GetLength())
);
}
public static float GetAngle(Vec3D vec1, Vec3D vec2)
{
return Calc.ACos(
vec1 * vec2
/ (vec1.GetLength() * vec2.GetLength())
);
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static float GetLength(this Vec3D vec)
{
return Calc.Sqrt(
vec.X * vec.X +
vec.Y * vec.Y +
vec.Z * vec.Z
);
}
public static float GetLength(this Vec2D vec)
{
return Calc.Sqrt(
vec.X * vec.X +
vec.Y * vec.Y
);
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static Array2x2
}
}
+3 -7
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Math
@@ -9,15 +10,11 @@ namespace StgSharp.Math
{
public float X;
public float Y;
public float Direction;
public float Length;
public Vec2D(float x,float y)
{
X = x;
Y = y;
Direction = Calc.ATan(X,Y);
Length = Calc.Sqrt(X * X + Y * Y);
}
public bool Equals(Vec2D other)
@@ -93,10 +90,9 @@ namespace StgSharp.Math
return new Vec2D(vec.X/x, vec.Y/x);
}
public float x(Vec2D others)
public Vec3D to3D()
{
return this.X * others.Y - this.Y * others.X;
return new Vec3D(this.X, this.Y, 0.0f);
}
}
}
+8 -1
View File
@@ -90,6 +90,14 @@ namespace StgSharp.Math
);
}
public static float operator *(Vec3D vec1, Vec3D vec2)
{
return
vec1.X * vec2.X
+ vec1.Y + vec2.Y
+ vec1.Z + vec2.Z;
}
public static Vec3D operator *(Vec3D vec, float x)
{
return new Vec3D(
@@ -107,6 +115,5 @@ namespace StgSharp.Math
vec.Z / x
);
}
}
}