diff --git a/demo/python/astronomy.py b/demo/python/astronomy.py
index 6b8568fe..960fcfd6 100644
--- a/demo/python/astronomy.py
+++ b/demo/python/astronomy.py
@@ -4503,6 +4503,7 @@ def HelioVector(body, time):
body : Body
The celestial body whose heliocentric position is to be calculated:
The Sun, Moon, EMB, SSB, or any of the planets.
+ Also allowed to be a user-defined star created by #DefineStar.
time : Time
The time at which to calculate the heliocentric position.
@@ -4910,6 +4911,7 @@ def HelioState(body, time):
Supported values are `Body.Sun`, `Body.SSB`, `Body.Moon`, `Body.EMB`, 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.
time : Time
The date and time for which to calculate position and velocity.
@@ -4956,6 +4958,10 @@ def HelioState(body, time):
time
)
+ if _IsUserDefinedStar(body):
+ vec = HelioVector(body, time)
+ return StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time)
+
raise InvalidBodyError(body)
diff --git a/generate/template/astronomy.c b/generate/template/astronomy.c
index 874e2a3c..e3d004e0 100644
--- a/generate/template/astronomy.c
+++ b/generate/template/astronomy.c
@@ -4294,6 +4294,7 @@ astro_state_vector_t Astronomy_BaryState(astro_body_t body, astro_time_t time)
* 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 #Astronomy_DefineStar.
* @param time
* The date and time for which to calculate position and velocity.
* @return
@@ -4306,6 +4307,17 @@ astro_state_vector_t Astronomy_HelioState(astro_body_t body, astro_time_t time)
major_bodies_t bary;
body_state_t planet, earth;
+ if (IsUserDefinedStar(body))
+ {
+ astro_vector_t vec = Astronomy_HelioVector(body, time);
+ state.x = vec.x;
+ state.y = vec.y;
+ state.z = vec.z;
+ state.vx = state.vy = state.vz = 0.0;
+ state.status = vec.status;
+ return state;
+ }
+
switch (body)
{
case BODY_SUN:
diff --git a/generate/template/astronomy.cs b/generate/template/astronomy.cs
index 3f4f1c59..19610afb 100644
--- a/generate/template/astronomy.cs
+++ b/generate/template/astronomy.cs
@@ -4414,6 +4414,7 @@ $ASTRO_IAU_DATA()
///
/// A body for which to calculate a heliocentric position:
/// the Sun, Moon, EMB, SSB, or any of the planets.
+ /// Also allowed to be a user-defined star created by #Astronomy.DefineStar.
///
/// The date and time for which to calculate the position.
/// A heliocentric position vector of the center of the given body.
@@ -4855,6 +4856,7 @@ $ASTRO_IAU_DATA()
/// 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 #Astronomy.DefineStar.
///
///
/// The date and time for which to calculate position and velocity.
@@ -4913,6 +4915,11 @@ $ASTRO_IAU_DATA()
);
default:
+ if (IsUserDefinedStar(body))
+ {
+ AstroVector vec = HelioVector(body, time);
+ return new StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time);
+ }
throw new InvalidBodyException(body);
}
}
diff --git a/generate/template/astronomy.kt b/generate/template/astronomy.kt
index 285ec154..4a479306 100644
--- a/generate/template/astronomy.kt
+++ b/generate/template/astronomy.kt
@@ -4827,6 +4827,7 @@ private fun solarSystemBarycenterState(time: Time): StateVector {
* @param body
* A body for which to calculate a heliocentric position:
* the Sun, Moon, EMB, SSB, or any of the planets.
+ * Also allowed to be a user-defined star created by [defineStar].
*
* @param time
* The date and time for which to calculate the position.
@@ -4894,6 +4895,7 @@ fun helioDistance(body: Body, time: Time): Double {
* 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].
*
* @param time
* The date and time for which to calculate position and velocity.
@@ -4903,8 +4905,13 @@ fun helioDistance(body: Body, time: Time): Double {
* The positions are expressed in AU.
* The velocities are expressed in AU/day.
*/
-fun helioState(body: Body, time: Time): StateVector =
- when (body) {
+fun helioState(body: Body, time: Time): StateVector {
+ if (isUserDefinedStar(body)) {
+ val vec = helioVector(body, time)
+ return StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time)
+ }
+
+ return when (body) {
Body.Sun -> StateVector(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, time)
Body.Pluto -> calcPluto(time, true)
Body.Moon -> helioEarthState(time) + geoMoonState(time)
@@ -4912,6 +4919,7 @@ fun helioState(body: Body, time: Time): StateVector =
Body.SSB -> solarSystemBarycenterState(time)
else -> StateVector(calcVsopPosVel(vsopModel(body), time.tt), time)
}
+}
/**
diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py
index cd4544e9..887aea47 100644
--- a/generate/template/astronomy.py
+++ b/generate/template/astronomy.py
@@ -2461,6 +2461,7 @@ def HelioVector(body, time):
body : Body
The celestial body whose heliocentric position is to be calculated:
The Sun, Moon, EMB, SSB, or any of the planets.
+ Also allowed to be a user-defined star created by #DefineStar.
time : Time
The time at which to calculate the heliocentric position.
@@ -2868,6 +2869,7 @@ def HelioState(body, time):
Supported values are `Body.Sun`, `Body.SSB`, `Body.Moon`, `Body.EMB`, 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.
time : Time
The date and time for which to calculate position and velocity.
@@ -2914,6 +2916,10 @@ def HelioState(body, time):
time
)
+ if _IsUserDefinedStar(body):
+ vec = HelioVector(body, time)
+ return StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time)
+
raise InvalidBodyError(body)
diff --git a/source/c/README.md b/source/c/README.md
index 9fd99f58..a575e777 100644
--- a/source/c/README.md
+++ b/source/c/README.md
@@ -1090,7 +1090,7 @@ Given a body and a time, calculates the position and velocity vectors for the ce
| Type | Parameter | Description |
| --- | --- | --- |
-| [`astro_body_t`](#astro_body_t) | `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`. |
+| [`astro_body_t`](#astro_body_t) | `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 [`Astronomy_DefineStar`](#Astronomy_DefineStar). |
| [`astro_time_t`](#astro_time_t) | `time` | The date and time for which to calculate position and velocity. |
diff --git a/source/c/astronomy.c b/source/c/astronomy.c
index 496f2fe7..4b44a6a1 100644
--- a/source/c/astronomy.c
+++ b/source/c/astronomy.c
@@ -5533,6 +5533,7 @@ astro_state_vector_t Astronomy_BaryState(astro_body_t body, astro_time_t time)
* 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 #Astronomy_DefineStar.
* @param time
* The date and time for which to calculate position and velocity.
* @return
@@ -5545,6 +5546,17 @@ astro_state_vector_t Astronomy_HelioState(astro_body_t body, astro_time_t time)
major_bodies_t bary;
body_state_t planet, earth;
+ if (IsUserDefinedStar(body))
+ {
+ astro_vector_t vec = Astronomy_HelioVector(body, time);
+ state.x = vec.x;
+ state.y = vec.y;
+ state.z = vec.z;
+ state.vx = state.vy = state.vz = 0.0;
+ state.status = vec.status;
+ return state;
+ }
+
switch (body)
{
case BODY_SUN:
diff --git a/source/csharp/README.md b/source/csharp/README.md
index 8bbb1bbd..d35e8d87 100644
--- a/source/csharp/README.md
+++ b/source/csharp/README.md
@@ -724,7 +724,7 @@ of reference, consider using [`Astronomy.BaryState`](#Astronomy.BaryState) inste
| Type | Parameter | Description |
| --- | --- | --- |
-| [`Body`](#Body) | `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`](#Body) | `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 [`Astronomy.DefineStar`](#Astronomy.DefineStar). |
| [`AstroTime`](#AstroTime) | `time` | The date and time for which to calculate position and velocity. |
**Returns:** A structure that contains heliocentric position and velocity vectors.
@@ -746,7 +746,7 @@ If given an invalid value for `body`, this function will throw an [`InvalidBodyE
| Type | Parameter | Description |
| --- | --- | --- |
-| [`Body`](#Body) | `body` | A body for which to calculate a heliocentric position: the Sun, Moon, EMB, SSB, or any of the planets. |
+| [`Body`](#Body) | `body` | A body for which to calculate a heliocentric position: the Sun, Moon, EMB, SSB, or any of the planets. Also allowed to be a user-defined star created by [`Astronomy.DefineStar`](#Astronomy.DefineStar). |
| [`AstroTime`](#AstroTime) | `time` | The date and time for which to calculate the position. |
**Returns:** A heliocentric position vector of the center of the given body.
diff --git a/source/csharp/astronomy.cs b/source/csharp/astronomy.cs
index c9a7d41e..f39b5c05 100644
--- a/source/csharp/astronomy.cs
+++ b/source/csharp/astronomy.cs
@@ -5626,6 +5626,7 @@ namespace CosineKitty
///
/// A body for which to calculate a heliocentric position:
/// the Sun, Moon, EMB, SSB, or any of the planets.
+ /// Also allowed to be a user-defined star created by #Astronomy.DefineStar.
///
/// The date and time for which to calculate the position.
/// A heliocentric position vector of the center of the given body.
@@ -6067,6 +6068,7 @@ namespace CosineKitty
/// 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 #Astronomy.DefineStar.
///
///
/// The date and time for which to calculate position and velocity.
@@ -6125,6 +6127,11 @@ namespace CosineKitty
);
default:
+ if (IsUserDefinedStar(body))
+ {
+ AstroVector vec = HelioVector(body, time);
+ return new StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time);
+ }
throw new InvalidBodyException(body);
}
}
diff --git a/source/kotlin/doc/helio-state.md b/source/kotlin/doc/helio-state.md
index f2797d7f..fd1e8fd5 100644
--- a/source/kotlin/doc/helio-state.md
+++ b/source/kotlin/doc/helio-state.md
@@ -16,5 +16,5 @@ A state vector that contains heliocentric position and velocity vectors. The pos
| | |
|---|---|
-| body | The celestial body whose heliocentric state vector is to be calculated. Supported values are [Body.Sun](-body/-sun/index.md), [Body.Moon](-body/-moon/index.md), [Body.EMB](-body/-e-m-b/index.md), [Body.SSB](-body/-s-s-b/index.md), and all planets: [Body.Mercury](-body/-mercury/index.md), [Body.Venus](-body/-venus/index.md), [Body.Earth](-body/-earth/index.md), [Body.Mars](-body/-mars/index.md), [Body.Jupiter](-body/-jupiter/index.md), [Body.Saturn](-body/-saturn/index.md), [Body.Uranus](-body/-uranus/index.md), [Body.Neptune](-body/-neptune/index.md), [Body.Pluto](-body/-pluto/index.md). |
+| body | The celestial body whose heliocentric state vector is to be calculated. Supported values are [Body.Sun](-body/-sun/index.md), [Body.Moon](-body/-moon/index.md), [Body.EMB](-body/-e-m-b/index.md), [Body.SSB](-body/-s-s-b/index.md), and all planets: [Body.Mercury](-body/-mercury/index.md), [Body.Venus](-body/-venus/index.md), [Body.Earth](-body/-earth/index.md), [Body.Mars](-body/-mars/index.md), [Body.Jupiter](-body/-jupiter/index.md), [Body.Saturn](-body/-saturn/index.md), [Body.Uranus](-body/-uranus/index.md), [Body.Neptune](-body/-neptune/index.md), [Body.Pluto](-body/-pluto/index.md). Also allowed to be a user-defined star created by [defineStar](define-star.md). |
| time | The date and time for which to calculate position and velocity. |
diff --git a/source/kotlin/doc/helio-vector.md b/source/kotlin/doc/helio-vector.md
index be2b6acc..3b9daffa 100644
--- a/source/kotlin/doc/helio-vector.md
+++ b/source/kotlin/doc/helio-vector.md
@@ -20,5 +20,5 @@ The heliocentric position vector of the center of the given body.
| | |
|---|---|
-| body | A body for which to calculate a heliocentric position: the Sun, Moon, EMB, SSB, or any of the planets. |
+| body | A body for which to calculate a heliocentric position: the Sun, Moon, EMB, SSB, or any of the planets. Also allowed to be a user-defined star created by [defineStar](define-star.md). |
| time | The date and time for which to calculate the position. |
diff --git a/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/astronomy.kt b/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/astronomy.kt
index eefce652..5b787a12 100644
--- a/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/astronomy.kt
+++ b/source/kotlin/src/main/kotlin/io/github/cosinekitty/astronomy/astronomy.kt
@@ -4827,6 +4827,7 @@ private fun solarSystemBarycenterState(time: Time): StateVector {
* @param body
* A body for which to calculate a heliocentric position:
* the Sun, Moon, EMB, SSB, or any of the planets.
+ * Also allowed to be a user-defined star created by [defineStar].
*
* @param time
* The date and time for which to calculate the position.
@@ -4894,6 +4895,7 @@ fun helioDistance(body: Body, time: Time): Double {
* 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].
*
* @param time
* The date and time for which to calculate position and velocity.
@@ -4903,8 +4905,13 @@ fun helioDistance(body: Body, time: Time): Double {
* The positions are expressed in AU.
* The velocities are expressed in AU/day.
*/
-fun helioState(body: Body, time: Time): StateVector =
- when (body) {
+fun helioState(body: Body, time: Time): StateVector {
+ if (isUserDefinedStar(body)) {
+ val vec = helioVector(body, time)
+ return StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time)
+ }
+
+ return when (body) {
Body.Sun -> StateVector(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, time)
Body.Pluto -> calcPluto(time, true)
Body.Moon -> helioEarthState(time) + geoMoonState(time)
@@ -4912,6 +4919,7 @@ fun helioState(body: Body, time: Time): StateVector =
Body.SSB -> solarSystemBarycenterState(time)
else -> StateVector(calcVsopPosVel(vsopModel(body), time.tt), time)
}
+}
/**
diff --git a/source/python/README.md b/source/python/README.md
index 5013c609..a9063312 100644
--- a/source/python/README.md
+++ b/source/python/README.md
@@ -1758,7 +1758,7 @@ of reference, consider using [`BaryState`](#BaryState) instead.
| Type | Parameter | Description |
| --- | --- | --- |
-| [`Body`](#Body) | `body` | The celestial body whose heliocentric state vector is to be calculated. Supported values are `Body.Sun`, `Body.SSB`, `Body.Moon`, `Body.EMB`, and all planets: `Body.Mercury`, `Body.Venus`, `Body.Earth`, `Body.Mars`, `Body.Jupiter`, `Body.Saturn`, `Body.Uranus`, `Body.Neptune`, `Body.Pluto`. |
+| [`Body`](#Body) | `body` | The celestial body whose heliocentric state vector is to be calculated. Supported values are `Body.Sun`, `Body.SSB`, `Body.Moon`, `Body.EMB`, 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). |
| [`Time`](#Time) | `time` | The date and time for which to calculate position and velocity. |
**Returns**: [`StateVector`](#StateVector)
@@ -1781,7 +1781,7 @@ If given an invalid value for `body`, this function raises an exception.
| Type | Parameter | Description |
| --- | --- | --- |
-| [`Body`](#Body) | `body` | The celestial body whose heliocentric position is to be calculated: The Sun, Moon, EMB, SSB, or any of the planets. |
+| [`Body`](#Body) | `body` | The celestial body whose heliocentric position is to be calculated: The Sun, Moon, EMB, SSB, or any of the planets. Also allowed to be a user-defined star created by [`DefineStar`](#DefineStar). |
| [`Time`](#Time) | `time` | The time at which to calculate the heliocentric position. |
**Returns**: [`Vector`](#Vector)
diff --git a/source/python/astronomy/astronomy.py b/source/python/astronomy/astronomy.py
index 6b8568fe..960fcfd6 100644
--- a/source/python/astronomy/astronomy.py
+++ b/source/python/astronomy/astronomy.py
@@ -4503,6 +4503,7 @@ def HelioVector(body, time):
body : Body
The celestial body whose heliocentric position is to be calculated:
The Sun, Moon, EMB, SSB, or any of the planets.
+ Also allowed to be a user-defined star created by #DefineStar.
time : Time
The time at which to calculate the heliocentric position.
@@ -4910,6 +4911,7 @@ def HelioState(body, time):
Supported values are `Body.Sun`, `Body.SSB`, `Body.Moon`, `Body.EMB`, 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.
time : Time
The date and time for which to calculate position and velocity.
@@ -4956,6 +4958,10 @@ def HelioState(body, time):
time
)
+ if _IsUserDefinedStar(body):
+ vec = HelioVector(body, time)
+ return StateVector(vec.x, vec.y, vec.z, 0.0, 0.0, 0.0, time)
+
raise InvalidBodyError(body)