Skip to content

Commit 80f917e

Browse files
committed
v1.1.8 bug fix
1 parent c8cc037 commit 80f917e

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ Console.WriteLine("=============================================================
100100
101101
## Change Log
102102
103+
### 2024.01.14 v1.1.8
104+
105+
Fix critical error in ELL to XYZ convertion.
106+
103107
### 2023.12.13 v1.1.7
104108
105109
Bug fix.

VSOP2013.NET/Calculator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Calculator()
3030
{
3131
//Import Planet Data
3232
var assembly = Assembly.GetExecutingAssembly();
33-
var names = assembly.GetManifestResourceNames();
33+
//var names = assembly.GetManifestResourceNames();
3434
VSOP2013DATA = new List<PlanetTable>(9);
3535
ParallelLoopResult result = Parallel.For(0, 9, ip =>
3636
{
@@ -116,8 +116,8 @@ private double Calculate(VariableTable Table, double JD2000)
116116
if (Table.iv == 1)
117117
{
118118
xl = result + freqpla[(int)Table.Body] * tj;
119-
xl %= Math.Tau;
120-
if (xl < 0) xl += Math.Tau;
119+
//modulu into [0,tau)
120+
xl = (xl % Math.Tau + Math.Tau) % Math.Tau;
121121
result = xl;
122122
}
123123
return result;

VSOP2013.NET/Utility.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,17 @@ public static double[] LBRtoXYZ(double[] lbr)
164164

165165
if (Vector256.IsHardwareAccelerated)
166166
{
167-
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);
168-
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);
169-
Vector256<double> v3 = Vector256.Create(Math.Sin(b), -r * Math.Cos(b), 0, 0);
167+
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);
168+
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);
169+
Vector256<double> m3 = Vector256.Create(Math.Sin(b), -r * Math.Cos(b), 0, 0);
170170
Vector256<double> vv = Vector256.Create(dr, db, dl, 0);
171171

172172
xyz[0] = x;
173173
xyz[1] = y;
174174
xyz[2] = z;
175-
xyz[3] = Vector256.Sum(vv * v1);
176-
xyz[4] = Vector256.Sum(vv * v2);
177-
xyz[5] = Vector256.Sum(vv * v3);
175+
xyz[3] = Vector256.Sum(vv * m1);
176+
xyz[4] = Vector256.Sum(vv * m2);
177+
xyz[5] = Vector256.Sum(vv * m3);
178178
return xyz.ToArray();
179179
}
180180

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

246-
z2 = new Complex(0d, e);
247-
zteta = Complex.Exp(z2);
248246
while (true)
249247
{
248+
z2 = new Complex(0d, e);
249+
zteta = Complex.Exp(z2);
250250
z3 = z1 * zteta;
251251
dl = gl - e + z3.Imaginary;
252252
rsa = 1.0d - z3.Real;
@@ -311,19 +311,19 @@ public static double[] DynamicaltoICRS(double[] dynamical)
311311

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

320-
icrs[0] = Vector256.Sum(vv * v1);
321-
icrs[1] = Vector256.Sum(vv * v2);
322-
icrs[2] = Vector256.Sum(vv * v3);
320+
icrs[0] = Vector256.Sum(vv * m1);
321+
icrs[1] = Vector256.Sum(vv * m2);
322+
icrs[2] = Vector256.Sum(vv * m3);
323323

324-
icrs[3] = Vector256.Sum(vv2 * v1);
325-
icrs[4] = Vector256.Sum(vv2 * v2);
326-
icrs[5] = Vector256.Sum(vv2 * v3);
324+
icrs[3] = Vector256.Sum(vdv * m1);
325+
icrs[4] = Vector256.Sum(vdv * m2);
326+
icrs[5] = Vector256.Sum(vdv * m3);
327327
return icrs.ToArray();
328328
}
329329

@@ -385,19 +385,19 @@ public static double[] ICRStoDynamical(double[] icrs)
385385

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

394-
dynamical[0] = Vector256.Sum(vv * v1);
395-
dynamical[1] = Vector256.Sum(vv * v2);
396-
dynamical[2] = Vector256.Sum(vv * v3);
394+
dynamical[0] = Vector256.Sum(vv * m1);
395+
dynamical[1] = Vector256.Sum(vv * m2);
396+
dynamical[2] = Vector256.Sum(vv * m3);
397397

398-
dynamical[3] = Vector256.Sum(vv2 * v1);
399-
dynamical[4] = Vector256.Sum(vv2 * v2);
400-
dynamical[5] = Vector256.Sum(vv2 * v3);
398+
dynamical[3] = Vector256.Sum(vdv * m1);
399+
dynamical[4] = Vector256.Sum(vdv * m2);
400+
dynamical[5] = Vector256.Sum(vdv * m3);
401401
return dynamical.ToArray();
402402
}
403403

VSOP2013.NET/VSOP2013.NET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PlatformTarget>x64</PlatformTarget>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Platforms>x64</Platforms>
8-
<Version>1.1.7</Version>
8+
<Version>1.1.8</Version>
99
<Title>VSOP2013.NET</Title>
1010
<Authors>KingsZNHONE</Authors>
1111
<Description>VSOP was developed and is maintained (updated with the latest data) by the scientists at the Bureau des Longitudes in Paris.

0 commit comments

Comments
 (0)