Skip to content

Commit

Permalink
Fixed doc typos. JS HelioState user-defined stars.
Browse files Browse the repository at this point in the history
I had a copy-n-paste typo in the `dec` parameters
for all of the DefineStar functions. Fixed it.

The TypeScript version of HelioState did not handle
user-defined stars. Added support there.
  • Loading branch information
cosinekitty committed Nov 23, 2022
1 parent 098eb3a commit 1725c77
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 71 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ of complexity. So I decided to create Astronomy Engine with the following engine
- Support JavaScript, C, C#, and Python with the same algorithms, and verify them to produce identical results.
(Kotlin support was added in 2022.)
- No external dependencies! The code must not require anything outside the standard library for each language.
- Minified JavaScript code less than 120K. (The current size is <!--MINIFIED_SIZE-->119438 bytes.)
- Minified JavaScript code less than 120K. (The current size is <!--MINIFIED_SIZE-->119491 bytes.)
- Accuracy always within 1 arcminute of results from NOVAS.
- It would be well documented, relatively easy to use, and support a wide variety of common use cases.

Expand Down
7 changes: 6 additions & 1 deletion demo/browser/astronomy.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function UserDefinedStar(body) {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param {number} dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down Expand Up @@ -4021,6 +4021,7 @@ exports.BaryState = BaryState;
* Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets:
* `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`,
* `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`.
* Also allowed to be a user-defined star created by {@link DefineStar}.
*
* @param {FlexibleDateTime} date
* The date and time for which to calculate position and velocity.
Expand Down Expand Up @@ -4057,6 +4058,10 @@ function HelioState(body, date) {
const state = (body == Body.Moon) ? GeoMoonState(time) : GeoEmbState(time);
return new StateVector(state.x + earth.r.x, state.y + earth.r.y, state.z + earth.r.z, state.vx + earth.v.x, state.vy + earth.v.y, state.vz + earth.v.z, time);
default:
if (UserDefinedStar(body)) {
const vec = HelioVector(body, time);
return new StateVector(vec.x, vec.y, vec.z, 0, 0, 0, time);
}
throw `HelioState: Unsupported body "${body}"`;
}
}
Expand Down
7 changes: 6 additions & 1 deletion demo/nodejs/astronomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function UserDefinedStar(body) {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param {number} dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down Expand Up @@ -4020,6 +4020,7 @@ exports.BaryState = BaryState;
* Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets:
* `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`,
* `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`.
* Also allowed to be a user-defined star created by {@link DefineStar}.
*
* @param {FlexibleDateTime} date
* The date and time for which to calculate position and velocity.
Expand Down Expand Up @@ -4056,6 +4057,10 @@ function HelioState(body, date) {
const state = (body == Body.Moon) ? GeoMoonState(time) : GeoEmbState(time);
return new StateVector(state.x + earth.r.x, state.y + earth.r.y, state.z + earth.r.z, state.vx + earth.v.x, state.vy + earth.v.y, state.vz + earth.v.z, time);
default:
if (UserDefinedStar(body)) {
const vec = HelioVector(body, time);
return new StateVector(vec.x, vec.y, vec.z, 0, 0, 0, time);
}
throw `HelioState: Unsupported body "${body}"`;
}
}
Expand Down
7 changes: 6 additions & 1 deletion demo/nodejs/calendar/astronomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function UserDefinedStar(body: Body): StarDef | null {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param {number} dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down Expand Up @@ -4500,6 +4500,7 @@ export function BaryState(body: Body, date: FlexibleDateTime): StateVector {
* Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets:
* `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`,
* `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`.
* Also allowed to be a user-defined star created by {@link DefineStar}.
*
* @param {FlexibleDateTime} date
* The date and time for which to calculate position and velocity.
Expand Down Expand Up @@ -4557,6 +4558,10 @@ export function HelioState(body: Body, date: FlexibleDateTime): StateVector {
);

default:
if (UserDefinedStar(body)) {
const vec = HelioVector(body, time);
return new StateVector(vec.x, vec.y, vec.z, 0, 0, 0, time);
}
throw `HelioState: Unsupported body "${body}"`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion demo/python/astronomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def DefineStar(body, ra, dec, distanceLightYears):
The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The value is in units of sidereal hours, and must be within the half-open range [0, 24).
dec: float
The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
and must be within the closed range [-90, +90].
distanceLightYears: float
Expand Down
2 changes: 1 addition & 1 deletion generate/template/astronomy.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static stardef_t *UserDefinedStar(astro_body_t body)
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down
2 changes: 1 addition & 1 deletion generate/template/astronomy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ private static StarDef UserDefinedStar(Body body)
/// The value is in units of sidereal hours, and must be within the half-open range [0, 24).
/// </param>
/// <param name="dec">
/// The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
/// The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
/// The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
/// and must be within the closed range [-90, +90].
/// </param>
Expand Down
2 changes: 1 addition & 1 deletion generate/template/astronomy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private fun userDefinedStar(body: Body): StarDef? {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down
2 changes: 1 addition & 1 deletion generate/template/astronomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def DefineStar(body, ra, dec, distanceLightYears):
The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The value is in units of sidereal hours, and must be within the half-open range [0, 24).
dec: float
The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
and must be within the closed range [-90, +90].
distanceLightYears: float
Expand Down
7 changes: 6 additions & 1 deletion generate/template/astronomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function UserDefinedStar(body: Body): StarDef | null {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param {number} dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down Expand Up @@ -3494,6 +3494,7 @@ export function BaryState(body: Body, date: FlexibleDateTime): StateVector {
* Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets:
* `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`,
* `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`.
* Also allowed to be a user-defined star created by {@link DefineStar}.
*
* @param {FlexibleDateTime} date
* The date and time for which to calculate position and velocity.
Expand Down Expand Up @@ -3551,6 +3552,10 @@ export function HelioState(body: Body, date: FlexibleDateTime): StateVector {
);

default:
if (UserDefinedStar(body)) {
const vec = HelioVector(body, time);
return new StateVector(vec.x, vec.y, vec.z, 0, 0, 0, time);
}
throw `HelioState: Unsupported body "${body}"`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ Stars are not valid until defined. Once defined, they retain their definition un
| --- | --- | --- |
| [`astro_body_t`](#astro_body_t) | `body` | One of the eight user-defined star identifiers: `BODY_STAR1` .. `BODY_STAR8`. |
| `double` | `ra` | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of sidereal hours, and must be within the half-open range [0, 24). |
| `double` | `dec` | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| `double` | `dec` | The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| `double` | `distanceLightYears` | The distance between the star and the Sun, expressed in light-years. This value is used to calculate the tiny parallax shift as seen by an observer on Earth. If you don't know the distance to the star, using a large value like 1000 will generally work well. The minimum allowed distance is 1 light-year, which is required to provide certain internal optimizations. |


Expand Down
2 changes: 1 addition & 1 deletion source/c/astronomy.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static stardef_t *UserDefinedStar(astro_body_t body)
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down
2 changes: 1 addition & 1 deletion source/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ definition until re-defined by another call to `DefineStar`.
| --- | --- | --- |
| [`Body`](#Body) | `body` | One of the eight user-defined star identifiers: `Body.Star1`, `Body.Star2`, ..., `Body.Star8`. |
| `double` | `ra` | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of sidereal hours, and must be within the half-open range [0, 24). |
| `double` | `dec` | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| `double` | `dec` | The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| `double` | `distanceLightYears` | The distance between the star and the Sun, expressed in light-years. This value is used to calculate the tiny parallax shift as seen by an observer on Earth. If you don't know the distance to the star, using a large value like 1000 will generally work well. The minimum allowed distance is 1 light-year, which is required to provide certain internal optimizations. |

<a name="Astronomy.DeltaT_EspenakMeeus"></a>
Expand Down
2 changes: 1 addition & 1 deletion source/csharp/astronomy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,7 @@ private static StarDef UserDefinedStar(Body body)
/// The value is in units of sidereal hours, and must be within the half-open range [0, 24).
/// </param>
/// <param name="dec">
/// The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
/// The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
/// The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
/// and must be within the closed range [-90, +90].
/// </param>
Expand Down
4 changes: 2 additions & 2 deletions source/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ definition until re-defined by another call to `DefineStar`.
| --- | --- | --- |
| body | [<code>Body</code>](#Body) | One of the eight user-defined star identifiers: `Star1`, `Star2`, `Star3`, `Star4`, `Star5`, `Star6`, `Star7`, or `Star8`. |
| ra | <code>number</code> | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of sidereal hours, and must be within the half-open range [0, 24). |
| dec | <code>number</code> | The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| dec | <code>number</code> | The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ). The value is in units of degrees north (positive) or south (negative) of the J2000 equator, and must be within the closed range [-90, +90]. |
| distanceLightYears | <code>number</code> | The distance between the star and the Sun, expressed in light-years. This value is used to calculate the tiny parallax shift as seen by an observer on Earth. If you don't know the distance to the star, using a large value like 1000 will generally work well. The minimum allowed distance is 1 light-year, which is required to provide certain internal optimizations. |


Expand Down Expand Up @@ -1613,7 +1613,7 @@ of reference, consider using [BaryState](#BaryState) instead.

| Param | Type | Description |
| --- | --- | --- |
| body | [<code>Body</code>](#Body) | The celestial body whose heliocentric state vector is to be calculated. Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets: `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`, `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`. |
| body | [<code>Body</code>](#Body) | The celestial body whose heliocentric state vector is to be calculated. Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets: `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`, `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`. Also allowed to be a user-defined star created by [DefineStar](#DefineStar). |
| date | [<code>FlexibleDateTime</code>](#FlexibleDateTime) | The date and time for which to calculate position and velocity. |


Expand Down
7 changes: 6 additions & 1 deletion source/js/astronomy.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function UserDefinedStar(body) {
* The value is in units of sidereal hours, and must be within the half-open range [0, 24).
*
* @param {number} dec
* The right ascension to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The declination to be assigned to the star, expressed in J2000 equatorial coordinates (EQJ).
* The value is in units of degrees north (positive) or south (negative) of the J2000 equator,
* and must be within the closed range [-90, +90].
*
Expand Down Expand Up @@ -4021,6 +4021,7 @@ exports.BaryState = BaryState;
* Supported values are `Body.Sun`, `Body.Moon`, `Body.EMB`, `Body.SSB`, and all planets:
* `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`,
* `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`.
* Also allowed to be a user-defined star created by {@link DefineStar}.
*
* @param {FlexibleDateTime} date
* The date and time for which to calculate position and velocity.
Expand Down Expand Up @@ -4057,6 +4058,10 @@ function HelioState(body, date) {
const state = (body == Body.Moon) ? GeoMoonState(time) : GeoEmbState(time);
return new StateVector(state.x + earth.r.x, state.y + earth.r.y, state.z + earth.r.z, state.vx + earth.v.x, state.vy + earth.v.y, state.vz + earth.v.z, time);
default:
if (UserDefinedStar(body)) {
const vec = HelioVector(body, time);
return new StateVector(vec.x, vec.y, vec.z, 0, 0, 0, time);
}
throw `HelioState: Unsupported body "${body}"`;
}
}
Expand Down
Loading

0 comments on commit 1725c77

Please sign in to comment.