Skip to content

Commit

Permalink
v1.1.8 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsznhone committed Jan 14, 2024
1 parent c8cc037 commit 80f917e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ Console.WriteLine("=============================================================
## Change Log
### 2024.01.14 v1.1.8
Fix critical error in ELL to XYZ convertion.
### 2023.12.13 v1.1.7
Bug fix.
Expand Down
6 changes: 3 additions & 3 deletions VSOP2013.NET/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Calculator()
{
//Import Planet Data
var assembly = Assembly.GetExecutingAssembly();
var names = assembly.GetManifestResourceNames();
//var names = assembly.GetManifestResourceNames();
VSOP2013DATA = new List<PlanetTable>(9);
ParallelLoopResult result = Parallel.For(0, 9, ip =>
{
Expand Down Expand Up @@ -116,8 +116,8 @@ private double Calculate(VariableTable Table, double JD2000)
if (Table.iv == 1)
{
xl = result + freqpla[(int)Table.Body] * tj;
xl %= Math.Tau;
if (xl < 0) xl += Math.Tau;
//modulu into [0,tau)
xl = (xl % Math.Tau + Math.Tau) % Math.Tau;
result = xl;
}
return result;
Expand Down
56 changes: 28 additions & 28 deletions VSOP2013.NET/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,17 @@ public static double[] LBRtoXYZ(double[] lbr)

if (Vector256.IsHardwareAccelerated)
{
Vector256<double> v1 = Vector256.Create(Math.Cos(b) * Math.Cos(l), r * Math.Sin(b) * Math.Cos(l), -r * Math.Cos(b) * Math.Sin(l), 0);
Vector256<double> v2 = Vector256.Create(Math.Cos(b) * Math.Sin(l), r * Math.Sin(b) * Math.Sin(l), r * Math.Cos(b) * Math.Cos(l), 0);
Vector256<double> v3 = Vector256.Create(Math.Sin(b), -r * Math.Cos(b), 0, 0);
Vector256<double> m1 = Vector256.Create(Math.Cos(b) * Math.Cos(l), r * Math.Sin(b) * Math.Cos(l), -r * Math.Cos(b) * Math.Sin(l), 0);
Vector256<double> m2 = Vector256.Create(Math.Cos(b) * Math.Sin(l), r * Math.Sin(b) * Math.Sin(l), r * Math.Cos(b) * Math.Cos(l), 0);
Vector256<double> m3 = Vector256.Create(Math.Sin(b), -r * Math.Cos(b), 0, 0);
Vector256<double> vv = Vector256.Create(dr, db, dl, 0);

xyz[0] = x;
xyz[1] = y;
xyz[2] = z;
xyz[3] = Vector256.Sum(vv * v1);
xyz[4] = Vector256.Sum(vv * v2);
xyz[5] = Vector256.Sum(vv * v3);
xyz[3] = Vector256.Sum(vv * m1);
xyz[4] = Vector256.Sum(vv * m2);
xyz[5] = Vector256.Sum(vv * m3);
return xyz.ToArray();
}

Expand Down Expand Up @@ -243,10 +243,10 @@ public static double[] ELLtoXYZ(VSOPBody body, double[] ell)
+ 0.5d * ex2 * Math.Sin(2.0d * gm)
+ 0.375d * ex3 * Math.Sin(3.0d * gm);

z2 = new Complex(0d, e);
zteta = Complex.Exp(z2);
while (true)
{
z2 = new Complex(0d, e);
zteta = Complex.Exp(z2);
z3 = z1 * zteta;
dl = gl - e + z3.Imaginary;
rsa = 1.0d - z3.Real;
Expand Down Expand Up @@ -311,19 +311,19 @@ public static double[] DynamicaltoICRS(double[] dynamical)

if (Vector256.IsHardwareAccelerated)
{
Vector256<double> v1 = Vector256.Create(Cphi, -Sphi * Ceps, Sphi * Seps, 0);
Vector256<double> v2 = Vector256.Create(Sphi, Cphi * Ceps, -Cphi * Seps, 0);
Vector256<double> v3 = Vector256.Create(0, Seps, Ceps, 0);
Vector256<double> m1 = Vector256.Create(Cphi, -Sphi * Ceps, Sphi * Seps, 0);
Vector256<double> m2 = Vector256.Create(Sphi, Cphi * Ceps, -Cphi * Seps, 0);
Vector256<double> m3 = Vector256.Create(0, Seps, Ceps, 0);
Vector256<double> vv = Vector256.Create(dynamical[0], dynamical[1], dynamical[2], 0);
Vector256<double> vv2 = Vector256.Create(dynamical[3], dynamical[4], dynamical[5], 0);
Vector256<double> vdv = Vector256.Create(dynamical[3], dynamical[4], dynamical[5], 0);

icrs[0] = Vector256.Sum(vv * v1);
icrs[1] = Vector256.Sum(vv * v2);
icrs[2] = Vector256.Sum(vv * v3);
icrs[0] = Vector256.Sum(vv * m1);
icrs[1] = Vector256.Sum(vv * m2);
icrs[2] = Vector256.Sum(vv * m3);

icrs[3] = Vector256.Sum(vv2 * v1);
icrs[4] = Vector256.Sum(vv2 * v2);
icrs[5] = Vector256.Sum(vv2 * v3);
icrs[3] = Vector256.Sum(vdv * m1);
icrs[4] = Vector256.Sum(vdv * m2);
icrs[5] = Vector256.Sum(vdv * m3);
return icrs.ToArray();
}

Expand Down Expand Up @@ -385,19 +385,19 @@ public static double[] ICRStoDynamical(double[] icrs)

if (Vector256.IsHardwareAccelerated)
{
Vector256<double> v1 = Vector256.Create(Cphi, Sphi, 0, 0);
Vector256<double> v2 = Vector256.Create(-Sphi * Ceps, Cphi * Ceps, Seps, 0);
Vector256<double> v3 = Vector256.Create(Sphi * Seps, -Cphi * Seps, Ceps, 0);
Vector256<double> m1 = Vector256.Create(Cphi, Sphi, 0, 0);
Vector256<double> m2 = Vector256.Create(-Sphi * Ceps, Cphi * Ceps, Seps, 0);
Vector256<double> m3 = Vector256.Create(Sphi * Seps, -Cphi * Seps, Ceps, 0);
Vector256<double> vv = Vector256.Create(icrs[0], icrs[1], icrs[2], 0);
Vector256<double> vv2 = Vector256.Create(icrs[3], icrs[4], icrs[5], 0);
Vector256<double> vdv = Vector256.Create(icrs[3], icrs[4], icrs[5], 0);

dynamical[0] = Vector256.Sum(vv * v1);
dynamical[1] = Vector256.Sum(vv * v2);
dynamical[2] = Vector256.Sum(vv * v3);
dynamical[0] = Vector256.Sum(vv * m1);
dynamical[1] = Vector256.Sum(vv * m2);
dynamical[2] = Vector256.Sum(vv * m3);

dynamical[3] = Vector256.Sum(vv2 * v1);
dynamical[4] = Vector256.Sum(vv2 * v2);
dynamical[5] = Vector256.Sum(vv2 * v3);
dynamical[3] = Vector256.Sum(vdv * m1);
dynamical[4] = Vector256.Sum(vdv * m2);
dynamical[5] = Vector256.Sum(vdv * m3);
return dynamical.ToArray();
}

Expand Down
2 changes: 1 addition & 1 deletion VSOP2013.NET/VSOP2013.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PlatformTarget>x64</PlatformTarget>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>x64</Platforms>
<Version>1.1.7</Version>
<Version>1.1.8</Version>
<Title>VSOP2013.NET</Title>
<Authors>KingsZNHONE</Authors>
<Description>VSOP was developed and is maintained (updated with the latest data) by the scientists at the Bureau des Longitudes in Paris.
Expand Down

0 comments on commit 80f917e

Please sign in to comment.