Open ynvgib opened 7 months ago
Thanks for reporting this. I will look into it and get back.
@ynvgib I do see some difference in my setup, but not as much as you, especially for example 2. Android Studio version should not matter as Android isn't being tested. Having said that, presently WASM is 32-bit, whereas FFI is 64-bit. That may affect some floating point calculations.
Here is the code I added to the example: // var time = DateTime(2024, 01, 16, 7, 30); // 2024-01-16 07:30:00.000 // var time = DateTime(1983, 10, 3, 13, 15); // 1983-10-03 13:15:00.000 var time = DateTime(1978, 05, 21, 00, 30); // 1978-05-21 00:30:00.000 double jd = Sweph.swe_julday(time.year, time.month, time.day, time.hour + time.minute / 60, CalendarType.SE_GREG_CAL);
CoordinatesWithSpeed posSun, posNorthnode;
posSun = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_SUN, SwephFlag.SEFLG_SWIEPH);
posNorthnode =
Sweph.swe_calc_ut(jd, HeavenlyBody.SE_TRUE_NODE, SwephFlag.SEFLG_SWIEPH);
double printNorthNode = posNorthnode.longitude;
double printSun = posSun.longitude;
debugPrint("time is $time");
debugPrint("jd time is $jd");
debugPrint("Sun: $printSun");
debugPrint("North Node is: $printNorthNode");
my result:
CHROME
time is 2024-01-16 07:30:00.000
jd time is 2460325.8125
Sun: 295.6463757021934
North Node is: 19.581430913105162
Windows
flutter: time is 2024-01-16 07:30:00.000
flutter: jd time is 2460325.8125
flutter: Sun: 295.6463757021932
flutter: North Node is: 19.581430913105162
CHROME
time is 1983-10-03 13:15:00.000
jd time is 2445611.0520833335
Sun: 189.75635745500242
North Node is: 78.61301401943668
Windows
flutter: time is 1983-10-03 13:15:00.000
flutter: jd time is 2445611.0520833335
flutter: Sun: 189.75635745500242
flutter: North Node is: 78.61301401943668
CHROME
time is 1978-05-21 00:30:00.000
jd time is 2443649.5208333335
Sun: 59.61371667811282
North Node is: 184.55327434949876
Windows
flutter: time is 1978-05-21 00:30:00.000
flutter: jd time is 2443649.5208333335
flutter: Sun: 59.61371667811284
flutter: North Node is: 184.5532743488916
Strange bug flies in the room then. For now I'll keep it at that... Don't know what to do.
Thanks
On Sun, Jan 21, 2024, 17:19 vm75 @.***> wrote:
I do see some difference in my setup, but not as much as you, especially for example 2. Android Studio version should not matter as Android isn't being tested. Having said that, presently WASM is 32-bit, whereas FFI is 64-bit. That may affect some floating point calculations.
Here is the code I added to the example: // var time = DateTime(2024, 01, 16, 7, 30); // 2024-01-16 07:30:00.000 // var time = DateTime(1983, 10, 3, 13, 15); // 1983-10-03 13:15:00.000 var time = DateTime(1978, 05, 21, 00, 30); // 1978-05-21 00:30:00.000 double jd = Sweph.swe_julday(time.year, time.month, time.day, time.hour + time.minute / 60, CalendarType.SE_GREG_CAL);
CoordinatesWithSpeed posSun, posNorthnode; posSun = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_SUN, SwephFlag.SEFLG_SWIEPH); posNorthnode = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_TRUE_NODE, SwephFlag.SEFLG_SWIEPH); double printNorthNode = posNorthnode.longitude; double printSun = posSun.longitude; debugPrint("time is $time"); debugPrint("jd time is $jd"); debugPrint("Sun: $printSun"); debugPrint("North Node is: $printNorthNode");
my result: CHROME time is 2024-01-16 07:30:00.000 jd time is 2460325.8125 Sun: 295.6463757021934 North Node is: 19.581430913105162
Windows flutter: time is 2024-01-16 07:30:00.000 flutter: jd time is 2460325.8125 flutter: Sun: 295.6463757021932 flutter: North Node is: 19.581430913105162
CHROME time is 1983-10-03 13:15:00.000 jd time is 2445611.0520833335 Sun: 189.75635745500242 North Node is: 78.61301401943668
Windows flutter: time is 1983-10-03 13:15:00.000 flutter: jd time is 2445611.0520833335 flutter: Sun: 189.75635745500242 flutter: North Node is: 78.61301401943668
CHROME time is 1978-05-21 00:30:00.000 jd time is 2443649.5208333335 Sun: 59.61371667811282 North Node is: 184.55327434949876
Windows flutter: time is 1978-05-21 00:30:00.000 flutter: jd time is 2443649.5208333335 flutter: Sun: 59.61371667811284 flutter: North Node is: 184.5532743488916
— Reply to this email directly, view it on GitHub https://github.com/vm75/sweph.dart/issues/13#issuecomment-1902700792, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOHVI5JJM2BJLWJQTIMHX3YPVE3BAVCNFSM6AAAAABB4LDJMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSG4YDANZZGI . You are receiving this because you authored the thread.Message ID: @.***>
I created a clean project with minimal code just to check:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Sweph.init(epheAssets: [
"packages/sweph/assets/ephe/seas_18.se1",
]);
DateTime now = DateTime.now();
//now = DateTime(1983, 10, 3, 13, 15);
now = DateTime(1978, 5, 21, 00, 30);
final CoordinatesWithSpeed posSun, posNorthnode;
final secondsInMinutes = now.second / 60;
final minutesInHours = (now.minute + secondsInMinutes) / 60;
final hours = now.hour + minutesInHours;
final jd = Sweph.swe_julday(
now.year, now.month, now.day, hours, CalendarType.SE_GREG_CAL);
print("time is $now");
print("jd time is $jd");
posSun = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_SUN, SwephFlag.SEFLG_SWIEPH);
posNorthnode =
Sweph.swe_calc_ut(jd, HeavenlyBody.SE_TRUE_NODE, SwephFlag.SEFLG_SWIEPH);
//idk
double printNorthNode = posNorthnode.longitude;
double printSun = posSun.longitude;
print ("Sun: $printSun");
print ("North Node is: $printNorthNode");
runApp(const MyApp());
}
and the result were:
_chrome 1 time is 1983-10-03 13:15:00.000 jd time is 2445611.0520833335 Sun: 189.75635745500242 North Node is: 78.61301401943668
=== 2 windows
flutter: time is 1983-10-03 13:15:00.000 flutter: jd time is 2445611.0520833335 flutter: Sun: 189.75635745500242 flutter: North Node is: 78.61301401943668
============== 1 chrome
time is 1978-05-21 00:30:00.000 jd time is 2443649.5208333335 Sun: 59.61371667811282 North Node is: 184.55327434949876
2 win
flutter: time is 1978-05-21 00:30:00.000 flutter: jd time is 2443649.5208333335 flutter: Sun: 59.61371667811284 flutter: North Node is: 184.5532743488916
====_
so the "glitch" on the northnode turns minor to none 1: North Node is: 78.61301401943668 2: North Node is: 78.61301401943668
1: North Node is: 184.55327434 then 949876 2: North Node is: 184.55327434 then 88916
Sun is pretty much equal.
I don't really know where that bug comes from. Maybe some memory glitch in the "complex" code which seems not to happen on the "simple" code. I don't know.
It could well be to do with with javascript floating-point precision limitations? I had a similar issue years ago with a game related project.
Perhaps you could make use of decimal.js or scale the high precision values to integers for calculations and then scale back down to original units?
I don't know.
It is in flutter so I found this flutter (dart) package https://pub.dev/packages/decimal
However, the calculation right on Windows but false on Web and Android.
I'm not sure about the 32bit or 64 bit difference, or the web/android vs windows calculation.
@ynvgib I do see some difference in my setup, but not as much as you, especially for example 2. Android Studio version should not matter as Android isn't being tested. Having said that, presently WASM is 32-bit, whereas FFI is 64-bit. That may affect some floating point calculations.
Here is the code I added to the example: // var time = DateTime(2024, 01, 16, 7, 30); // 2024-01-16 07:30:00.000 // var time = DateTime(1983, 10, 3, 13, 15); // 1983-10-03 13:15:00.000 var time = DateTime(1978, 05, 21, 00, 30); // 1978-05-21 00:30:00.000 double jd = Sweph.swe_julday(time.year, time.month, time.day, time.hour + time.minute / 60, CalendarType.SE_GREG_CAL);
CoordinatesWithSpeed posSun, posNorthnode; posSun = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_SUN, SwephFlag.SEFLG_SWIEPH); posNorthnode = Sweph.swe_calc_ut(jd, HeavenlyBody.SE_TRUE_NODE, SwephFlag.SEFLG_SWIEPH); double printNorthNode = posNorthnode.longitude; double printSun = posSun.longitude; debugPrint("time is $time"); debugPrint("jd time is $jd"); debugPrint("Sun: $printSun"); debugPrint("North Node is: $printNorthNode");
my result:
CHROME time is 2024-01-16 07:30:00.000 jd time is 2460325.8125 Sun: 295.6463757021934 North Node is: 19.581430913105162 Windows flutter: time is 2024-01-16 07:30:00.000 flutter: jd time is 2460325.8125 flutter: Sun: 295.6463757021932 flutter: North Node is: 19.581430913105162 CHROME time is 1983-10-03 13:15:00.000 jd time is 2445611.0520833335 Sun: 189.75635745500242 North Node is: 78.61301401943668 Windows flutter: time is 1983-10-03 13:15:00.000 flutter: jd time is 2445611.0520833335 flutter: Sun: 189.75635745500242 flutter: North Node is: 78.61301401943668 CHROME time is 1978-05-21 00:30:00.000 jd time is 2443649.5208333335 Sun: 59.61371667811282 North Node is: 184.55327434949876 Windows flutter: time is 1978-05-21 00:30:00.000 flutter: jd time is 2443649.5208333335 flutter: Sun: 59.61371667811284 flutter: North Node is: 184.5532743488916
@vm75 I don't know if you checked both 32bit and 64bit for the difference, and if I can "force" either 64bit (FFI) or 32bit (WASM) calculation, within the code
North Node is the main issue I encounter with A LARGE DIFFRENCE as mentioned North Node is: 78.61301401943668 (time = DateTime(1983, 10, 3, 13, 15))
North Node1 : 78.61301401943668 North Node2 : 78.6187508762073
As I wrote, The New FLUTTER app I created for test returns quite similar result: North Node1 : 78.61301401943668 (time = DateTime(1983, 10, 3, 13, 15))
so perhaps the old Project uses only 32bit for WINDOWS, but 64bit for CHROME (WEB), and I'm not sure how to:
I am using these functions in the code to return the SUN and TRUE_NODE (north node):
I am using this ephemeris:
There is a CLEAR DIFFERENCE in the TRUE_NODE, but also a slight one in the SUN.
these are the printed times and data:
=== EXAMPLE 1: CHROME:
time is 2024-01-16 07:30:00.000 jd time is 2460325.8125 Sun: 295.6463757021934 North Node is: 19.581430913105162
WINDOWS:
flutter: time is 2024-01-16 07:30:00.000 flutter: jd time is 2460325.8125 flutter: Sun: 295.6463757021932 flutter: North Node is: 19.582942888102373
============== EX.2 CHROME:
time is 1983-10-03 13:15:00.000 jd time is 2445611.0520833335 Sun: 189.75635745500242 North Node is: 78.61301401943668
WINDOWS:
flutter: time is 1983-10-03 13:15:00.000 flutter: jd time is 2445611.0520833335 flutter: Sun: 189.75635745500242 flutter: North Node is: 78.61875087620729
Ex. 3
CHROME: time is 1978-05-21 00:30:00.000 jd time is 2443649.5208333335 Sun: 59.61371667811282 North Node is: 184.55327434949876
WINDOWS: flutter: time is 1978-05-21 00:30:00.000 flutter: jd time is 2443649.5208333335 flutter: Sun: 59.61371667811284 flutter: North Node is: 184.54967016401204
=====
I am using Android Studio Flamingo | 2022.2.1 Patch 2 and flutter: PS C:\Users\val\projects\flutter\finallyicanlearn> flutter --version Flutter 3.16.0-10.0.pre • channel master • https://github.com/flutter/flutter.git Framework • revision c0d19ca561 (3 months ago) • 2023-10-11 23:33:07 -0400 Engine • revision d00fabf0b9 Tools • Dart 3.3.0 (build 3.3.0-14.0.dev) • DevTools 2.28.1
SWEPH: sweph 2.10.3+16