From a7e667309ddacc88e849dce526cb8a693e92eb2c Mon Sep 17 00:00:00 2001 From: Don Cross Date: Fri, 1 Apr 2022 19:34:26 -0400 Subject: [PATCH] Kotlin: rotationEqdEcl, rotationEclEqd. --- generate/template/astronomy.kt | 35 +++++++++++++++++++ source/kotlin/doc/-astronomy/index.md | 2 ++ .../kotlin/doc/-astronomy/rotation-ecl-eqd.md | 18 ++++++++++ .../kotlin/doc/-astronomy/rotation-eqd-ecl.md | 18 ++++++++++ .../github/cosinekitty/astronomy/astronomy.kt | 35 +++++++++++++++++++ .../io/github/cosinekitty/astronomy/Tests.kt | 20 +++++++++++ 6 files changed, 128 insertions(+) create mode 100644 source/kotlin/doc/-astronomy/rotation-ecl-eqd.md create mode 100644 source/kotlin/doc/-astronomy/rotation-eqd-ecl.md diff --git a/generate/template/astronomy.kt b/generate/template/astronomy.kt index 836e09ac..fa4fa283 100644 --- a/generate/template/astronomy.kt +++ b/generate/template/astronomy.kt @@ -4271,6 +4271,41 @@ object Astronomy { */ fun rotationEqjHor(time: AstroTime, observer: Observer): RotationMatrix = rotationHorEqj(time, observer).inverse() + + /** + * Calculates a rotation matrix from equatorial of-date (EQD) to ecliptic J2000 (ECL). + * + * This is one of the family of functions that returns a rotation matrix + * for converting from one orientation to another. + * Source: EQD = equatorial system, using equator of date. + * Target: ECL = ecliptic system, using equator at J2000 epoch. + * + * @param time + * The date and time of the source equator. + * + * @returns + * A rotation matrix that converts EQD to ECL. + */ + fun rotationEqdEcl(time: AstroTime): RotationMatrix = + rotationEqdEqj(time) combine + rotationEqjEcl() + + /** + * Calculates a rotation matrix from ecliptic J2000 (ECL) to equatorial of-date (EQD). + * + * This is one of the family of functions that returns a rotation matrix + * for converting from one orientation to another. + * Source: ECL = ecliptic system, using equator at J2000 epoch. + * Target: EQD = equatorial system, using equator of date. + * + * @param time + * The date and time of the desired equator. + * + * @returns + * A rotation matrix that converts ECL to EQD. + */ + fun rotationEclEqd(time: AstroTime): RotationMatrix = + rotationEqdEcl(time).inverse() } //======================================================================================= diff --git a/source/kotlin/doc/-astronomy/index.md b/source/kotlin/doc/-astronomy/index.md index 616bb4b2..005b4a02 100644 --- a/source/kotlin/doc/-astronomy/index.md +++ b/source/kotlin/doc/-astronomy/index.md @@ -26,7 +26,9 @@ The main container of astronomy calculation functions. | [massProduct](mass-product.md) | [jvm]
fun [massProduct](mass-product.md)(body: [Body](../-body/index.md)): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
Returns the product of mass and universal gravitational constant of a Solar System body. | | [refractionAngle](refraction-angle.md) | [jvm]
fun [refractionAngle](refraction-angle.md)(refraction: [Refraction](../-refraction/index.md), altitude: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)
Calculates the amount of "lift" to an altitude angle caused by atmospheric refraction. | | [rotationAxis](rotation-axis.md) | [jvm]
fun [rotationAxis](rotation-axis.md)(body: [Body](../-body/index.md), time: [AstroTime](../-astro-time/index.md)): [AxisInfo](../-axis-info/index.md)
Calculates information about a body's rotation axis at a given time. | +| [rotationEclEqd](rotation-ecl-eqd.md) | [jvm]
fun [rotationEclEqd](rotation-ecl-eqd.md)(time: [AstroTime](../-astro-time/index.md)): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from ecliptic J2000 (ECL) to equatorial of-date (EQD). | | [rotationEclEqj](rotation-ecl-eqj.md) | [jvm]
fun [rotationEclEqj](rotation-ecl-eqj.md)(): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from ecliptic J2000 (ECL) to equatorial J2000 (EQJ). | +| [rotationEqdEcl](rotation-eqd-ecl.md) | [jvm]
fun [rotationEqdEcl](rotation-eqd-ecl.md)(time: [AstroTime](../-astro-time/index.md)): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from equatorial of-date (EQD) to ecliptic J2000 (ECL). | | [rotationEqdEqj](rotation-eqd-eqj.md) | [jvm]
fun [rotationEqdEqj](rotation-eqd-eqj.md)(time: [AstroTime](../-astro-time/index.md)): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from equatorial of-date (EQD) to equatorial J2000 (EQJ). | | [rotationEqdHor](rotation-eqd-hor.md) | [jvm]
fun [rotationEqdHor](rotation-eqd-hor.md)(time: [AstroTime](../-astro-time/index.md), observer: [Observer](../-observer/index.md)): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from equatorial of-date (EQD) to horizontal (HOR). | | [rotationEqjEcl](rotation-eqj-ecl.md) | [jvm]
fun [rotationEqjEcl](rotation-eqj-ecl.md)(): [RotationMatrix](../-rotation-matrix/index.md)
Calculates a rotation matrix from equatorial J2000 (EQJ) to ecliptic J2000 (ECL). | diff --git a/source/kotlin/doc/-astronomy/rotation-ecl-eqd.md b/source/kotlin/doc/-astronomy/rotation-ecl-eqd.md new file mode 100644 index 00000000..271d9cdb --- /dev/null +++ b/source/kotlin/doc/-astronomy/rotation-ecl-eqd.md @@ -0,0 +1,18 @@ +//[astronomy](../../../index.md)/[io.github.cosinekitty.astronomy](../index.md)/[Astronomy](index.md)/[rotationEclEqd](rotation-ecl-eqd.md) + +# rotationEclEqd + +[jvm]\ +fun [rotationEclEqd](rotation-ecl-eqd.md)(time: [AstroTime](../-astro-time/index.md)): [RotationMatrix](../-rotation-matrix/index.md) + +Calculates a rotation matrix from ecliptic J2000 (ECL) to equatorial of-date (EQD). + +This is one of the family of functions that returns a rotation matrix for converting from one orientation to another. Source: ECL = ecliptic system, using equator at J2000 epoch. Target: EQD = equatorial system, using equator of date. + +## Parameters + +jvm + +| | | +|---|---| +| time | The date and time of the desired equator. | diff --git a/source/kotlin/doc/-astronomy/rotation-eqd-ecl.md b/source/kotlin/doc/-astronomy/rotation-eqd-ecl.md new file mode 100644 index 00000000..f77e22d7 --- /dev/null +++ b/source/kotlin/doc/-astronomy/rotation-eqd-ecl.md @@ -0,0 +1,18 @@ +//[astronomy](../../../index.md)/[io.github.cosinekitty.astronomy](../index.md)/[Astronomy](index.md)/[rotationEqdEcl](rotation-eqd-ecl.md) + +# rotationEqdEcl + +[jvm]\ +fun [rotationEqdEcl](rotation-eqd-ecl.md)(time: [AstroTime](../-astro-time/index.md)): [RotationMatrix](../-rotation-matrix/index.md) + +Calculates a rotation matrix from equatorial of-date (EQD) to ecliptic J2000 (ECL). + +This is one of the family of functions that returns a rotation matrix for converting from one orientation to another. Source: EQD = equatorial system, using equator of date. Target: ECL = ecliptic system, using equator at J2000 epoch. + +## Parameters + +jvm + +| | | +|---|---| +| time | The date and time of the source equator. | 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 eb13ebec..832f16dc 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 @@ -4271,6 +4271,41 @@ object Astronomy { */ fun rotationEqjHor(time: AstroTime, observer: Observer): RotationMatrix = rotationHorEqj(time, observer).inverse() + + /** + * Calculates a rotation matrix from equatorial of-date (EQD) to ecliptic J2000 (ECL). + * + * This is one of the family of functions that returns a rotation matrix + * for converting from one orientation to another. + * Source: EQD = equatorial system, using equator of date. + * Target: ECL = ecliptic system, using equator at J2000 epoch. + * + * @param time + * The date and time of the source equator. + * + * @returns + * A rotation matrix that converts EQD to ECL. + */ + fun rotationEqdEcl(time: AstroTime): RotationMatrix = + rotationEqdEqj(time) combine + rotationEqjEcl() + + /** + * Calculates a rotation matrix from ecliptic J2000 (ECL) to equatorial of-date (EQD). + * + * This is one of the family of functions that returns a rotation matrix + * for converting from one orientation to another. + * Source: ECL = ecliptic system, using equator at J2000 epoch. + * Target: EQD = equatorial system, using equator of date. + * + * @param time + * The date and time of the desired equator. + * + * @returns + * A rotation matrix that converts ECL to EQD. + */ + fun rotationEclEqd(time: AstroTime): RotationMatrix = + rotationEqdEcl(time).inverse() } //======================================================================================= diff --git a/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt b/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt index 66b3b6e3..96eb61fe 100644 --- a/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt +++ b/source/kotlin/src/test/kotlin/io/github/cosinekitty/astronomy/Tests.kt @@ -604,6 +604,26 @@ class Tests { ), "EQJ HOR" ) + + compareMatrices( + Astronomy.rotationEqdEcl(time), + RotationMatrix( + 0.9999856608656787, -0.00535518855821894, -4.305530497609837e-06, + 0.004911515527973243, 0.917457490583079, -0.39780350675706494, + 0.002134262929010771, 0.39779778145246825, 0.9174706371286464, + ), + "EQD ECL" + ) + + compareMatrices( + Astronomy.rotationEclEqd(time), + RotationMatrix( + 0.9999856608656787, 0.004911515527973243, 0.002134262929010771, + -0.00535518855821894, 0.917457490583079, 0.39779778145246825, + -4.305530497609837e-06, -0.39780350675706494, 0.9174706371286464, + ), + "ECL EQD" + ) } //----------------------------------------------------------------------------------------