star-cem

Compute the position of the sun
git clone git://git.meso-star.com/star-cem.git
Log | Files | Refs | README | LICENSE

commit c7486e46c1f613b85125f5436ef99ad9671e57a5
parent fe71ca556aa00327f7cbc59d231cbea87bcaf77b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 10 Jun 2026 17:24:27 +0200

Rename zenith in elevation in API and code

As zenith was defined "positive towards the sky", it was really what is
commonly defined as elevation.

Diffstat:
Msrc/scem.h | 4++--
Msrc/scem_main.c | 4++--
Msrc/scem_meeus.c | 2+-
Msrc/scem_psa.c | 2+-
Msrc/test_scem_sun_position.c | 2+-
5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/scem.h b/src/scem.h @@ -39,7 +39,7 @@ enum scem_sun_algo { /* Sun position */ struct scem_sun_pos { /* In [-PI/2, PI/2]. Positive toward the sky */ - double zenith; /* [rad] */ + double elevation; /* [rad] */ /* In [0, 2PI] with 0 aligned with north, PI/2 east, PI south, and 3PI/2 west */ double azimuth; /* [rad] */ @@ -73,7 +73,7 @@ scem_sun_algo_cstr(const enum scem_sun_algo algo) BEGIN_DECLS -/* Compute the position of the Sun in local coordinates (zenith and azimuth) for +/* Compute the position of the Sun in local coordinates (elevation and azimuth) for * a given observer at the surface of the Earth (can be extended to other * planets if required) i.e. the observer has to be located at the surface for * the required date */ diff --git a/src/scem_main.c b/src/scem_main.c @@ -181,9 +181,9 @@ main(int argc, char** argv) } if(args.radian) { - printf("%g %g\n", pos.zenith, pos.azimuth); + printf("%g %g\n", pos.elevation, pos.azimuth); } else { - printf("%g %g\n", MRAD2DEG(pos.zenith), MRAD2DEG(pos.azimuth)); + printf("%g %g\n", MRAD2DEG(pos.elevation), MRAD2DEG(pos.azimuth)); } exit: diff --git a/src/scem_meeus.c b/src/scem_meeus.c @@ -202,7 +202,7 @@ sun_position_from_earth_meeus /* Zenital angle: angle between the horizontal plane and the Sun direction */ latitude_rad = MDEG2RAD(pos->latitude /* [deg] */); - sun->zenith /* [rad] */ = asin + sun->elevation /* [rad] */ = asin ( sin(latitude_rad)*sin(celestial.declination) + cos(latitude_rad)*cos(celestial.declination)*cos(H_rad)); diff --git a/src/scem_psa.c b/src/scem_psa.c @@ -155,7 +155,7 @@ sun_pos_local_coords zenith_rad += parallax; sun->azimuth = fmod(azimuth_rad, 2 * PI); - sun->zenith = PI * 0.5 - fmod(zenith_rad, 2 * PI); + sun->elevation = PI * 0.5 - fmod(zenith_rad, 2 * PI); } /******************************************************************************* diff --git a/src/test_scem_sun_position.c b/src/test_scem_sun_position.c @@ -69,7 +69,7 @@ test_api(void) CHK(scem_sun_position_from_earth(&utc, &pos, algo, &sun) == RES_OK); printf("%s - zenith: %g°; azimuth: %g°\n", scem_sun_algo_cstr(algo), - MRAD2DEG(sun.zenith), + MRAD2DEG(sun.elevation), MRAD2DEG(sun.azimuth)); } }