enmergency update on 20230213 by nitload youmu, fix a file damage
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
//
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
@@ -8,9 +6,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Math
|
||||
public static unsafe partial class Calc
|
||||
{
|
||||
|
||||
private const float
|
||||
@@ -22,7 +21,7 @@ namespace StgSharp
|
||||
/// <summary>
|
||||
/// Reurns the value of ArcSin(x)
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="x">The sine value of the angle</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static float ASin(float x )
|
||||
@@ -86,8 +85,93 @@ namespace StgSharp
|
||||
v = y + y * u;
|
||||
}/**/
|
||||
|
||||
return sign * v * 90 / piby2;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user