Skip to content

Commit

Permalink
Merge branch 'decimaljs-removal'
Browse files Browse the repository at this point in the history
  • Loading branch information
onekiloparsec committed Apr 24, 2024
2 parents c4e8f34 + e48714d commit f0a6b1a
Show file tree
Hide file tree
Showing 144 changed files with 5,194 additions and 14,364 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ aa-js

The most comprehensive collection of accurate astronomical algorithms (AA) in JavaScript (TypeScript).

**The new v3+ offers arbitrary-precision computations, thanks to [decimal.js](https://github.com/MikeMcl/decimal.js).**

**The new v3.2 offers in various places the choice between the low-precision standard Javascript Math
implementation and the new arbitrary-precision but a lot slower implementation.** The speed between the two
implementation can vary with a factor of 10 to 1000 times! See benchmark tests included in the project.

**Whatever precision is chosen, the outputs will always contain `Decimal` (not `number`).**
The v3 offered arbitrary-precision computations, thanks to [decimal.js](https://github.com/MikeMcl/decimal.js).
But it was thousands (if not millions) of times slower than the original implementation, making its usage in a browser
very difficult. After some nightly hours to optimise it and having most of both implementations side-by-side, we decided
to remove decimal.js entirely.

Other AA
implementations: [Swift (SwiftAA)](https://github.com/onekiloparsec/SwiftAA), [C# (AASharp)](https://github.com/jsauve/AASharp).
Expand All @@ -27,16 +24,26 @@ in AA+.
`aa-js` is the backbone of scientific algorithms used
in [Arcsecond.io](https://www.arcsecond.io).

Main Changes in V4
================

No big API changes, except there are no more Decimal.js at all, and thus no `highPrecision` parameter. The method
signatures have not changed, but all return types are based on `number`.

Small changes:

- The return type of `getJulianDay` is now always `JulianDay` and not `JulianDay | undefined`. If really the build of a
JD is not correct, `J2000` is returned with a warning.

Main Changes in V3
================

- **All algorithms based on arbitrary-precision operations thanks
to [decimal.js](https://github.com/MikeMcl/decimal.js).**
- ~~All algorithms based on arbitrary-precision operations thanks
to [decimal.js](https://github.com/MikeMcl/decimal.js).~~
- **BREAKING** (since v3.2) Equatorial coordinates uses right ascension expressed in `Degree` not `Hour`.
- **BREAKING** (since v3.2) Input parameters of the `coordinates` modules now use complete coordinates objects, rather
than individual members to reduce the number of parameters in the functions.
- **BREAKING** (since v3.4) The precision of Decimal.js is not set to a default value. It is left to the consumer.
- ~~**BREAKING** (since v3.4) The precision of Decimal.js is not set to a default value. It is left to the consumer.~~
- Moved all (non-Earth) planets modules inside a `planets` folder.
- **Addition of numerous orbital getters for planets** (mean longitude, semi-major axis, inclination, eccentricity...)
- Much easier and cleaner distinction between *heliocentric* and *geocentric* coordinates of planets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDecimalValue } from '@/sexagesimal'

const ra = getDecimalValue(16, 54, 0.14) // in hours
const dec = getDecimalValue(-39, 50, 44.9)
const equCoords = { rightAscension: ra.hoursToDegrees(), declination: dec }
const equCoords = { rightAscension: ra* H2DEG, declination: dec }

export default b.suite(
'Earth aberration getAccurateAnnualEquatorialAberration',
Expand Down
2 changes: 1 addition & 1 deletion benchmark/earth/aberration/annual-ecliptic-aberration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Earth, sexagesimal, coordinates } from '@'

const ra = sexagesimal.getDecimalValue(16, 54, 0.14) // in hours
const dec = sexagesimal.getDecimalValue(-39, 50, 44.9)
const equCoords = { rightAscension: ra.hoursToDegrees(), declination: dec }
const equCoords = { rightAscension: ra* H2DEG, declination: dec }
const eclCoords = coordinates.transformEquatorialToEcliptic(equCoords)

export default b.suite(
Expand Down
2 changes: 1 addition & 1 deletion benchmark/earth/aberration/annual-equatorial-aberration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Earth, sexagesimal } from '@'

const ra = sexagesimal.getDecimalValue(16, 54, 0.14) // in hours
const dec = sexagesimal.getDecimalValue(-39, 50, 44.9)
const equCoords = { rightAscension: ra.hoursToDegrees(), declination: dec }
const equCoords = { rightAscension: ra* H2DEG, declination: dec }

export default b.suite(
'Earth aberration getAnnualEquatorialAberration',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDecimalValue } from '@/sexagesimal'

const ra = getDecimalValue(16, 54, 0.14) // in hours
const dec = getDecimalValue(-39, 50, 44.9)
const equCoords = { rightAscension: ra.hoursToDegrees(), declination: dec }
const equCoords = { rightAscension: ra* H2DEG, declination: dec }

export default b.suite(
'Earth aberration getNutationEquatorialAberration',
Expand Down
4 changes: 2 additions & 2 deletions benchmark/trigonometrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export default b.suite(
value.degreesToRadians().toNumber()
}),
b.add('value toNumber then deg2rad num', () => {
value.toNumber() * deg2rad
value.toNumber() * DEG2RAD
}),
b.add('valueNum deg2rad', () => {
valueNum * deg2rad
valueNum * DEG2RAD
}),

b.cycle(),
Expand Down
Loading

0 comments on commit f0a6b1a

Please sign in to comment.