### Calculate Julian Day and Ephemeris Day (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Demonstrates how to specify a specific time using the `astro::time` module. It shows how to create `DayOfMonth` and `Date` structs, calculate the Julian Day from a date, and then calculate the Julian Ephemeris Day by accounting for Delta T. ```rust // for example, the time of the Apollo 11 moon landing let day_of_month = time::DayOfMonth{day : 20, hr : 20, min : 18, sec : 4.0, time_zone: 0.0}; let date = time::Date{year : 1969, month : 7, // July decimal_day: time::decimal_day(&day_of_month), cal_type : time::CalType::Gregorian}; let julian_day = time::julian_day(&date); // for higher accuracy in specifying the time of interest, // find the Julian Ephemeris day; this slightly differs from // the Julian day by ΔT, which is usually a few seconds. you // can get a reported value of it from the Astronomical // Almanac, or calculate it using the built-in function let delta_t = time::delta_t(date.year, date.month); let julian_ephm_day = time::julian_ephemeris_day(julian_day, delta_t); ``` -------------------------------- ### Add Astro Dependency (Cargo.toml) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Adds the `astro` crate as a dependency to the project's `Cargo.toml` file, specifying version 2.0.0. This is the first step to include the library in a Rust project. ```toml [dependencies] astro = "2.0.0" ``` -------------------------------- ### Include Astro Crate (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Includes the `astro` crate in the Rust source code using `extern crate` and brings all public items into the current scope with `use astro::*`. This makes the library's functions and types available for use. ```rust extern crate astro; use astro::*; ``` -------------------------------- ### Convert Equatorial to Ecliptic Coordinates (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Demonstrates converting equatorial coordinates (Right Ascension and Declination) to ecliptic coordinates (longitude and latitude) using the `ecl_frm_eq!` macro. It requires the mean obliquity of the ecliptic and notes that the macro requires `#[macro_use]` on the crate import. ```rust // equatorial coordinates of the star Pollux let right_ascension = 116.328942_f64.to_radians(); let declination = 28.026183_f64.to_radians(); // mean obliquity of the ecliptic let oblq_eclip = 23.4392911_f64.to_radians(); // you can also get oblq_eclip from ecliptic::mn_oblq_IAU(julian_day) // for the Julian day on which the coordinates of the star // were observed // also make sure to type #[macro_use] before including the crate // to use macros // now, convert equatorial coordinates to ecliptic coordinates let (ecl_long, ecl_lat) = ecl_frm_eq!(right_ascension, declination, oblq_eclip); ``` -------------------------------- ### Calculate Nutation Corrections (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Shows how to calculate nutation corrections for both ecliptic coordinates (longitude and obliquity) and equatorial coordinates (Right Ascension and Declination) using the `astro::nutation` module, based on a given Julian Day. ```rust // nutation in ecliptic longitude and obliquity of the ecliptic let (nut_in_long, nut_in_oblq) = nutation::nutation(julian_day); // nutation in equatorial coordinates let (nut_in_asc, nut_in_dec) = nutation::nutation_in_eq_coords(julian_day); ``` -------------------------------- ### Calculate Heliocentric Positions of Planets (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Demonstrates how to calculate the heliocentric position (longitude, latitude) and radius vector (distance from the Sun) for various planets, including Jupiter, Neptune, and Pluto, using the `astro::planet` and `astro::pluto` modules based on a Julian Day. ```rust // the heliocentric point and radius vector of a planet, like Jupiter let (jup_long, jup_lat, rad_vec) = planet::heliocent_pos(&planet::Planet::Jupiter, julian_day); // or neptune let (nep_long, nep_lat, rad_vec) = planet::heliocent_pos(&planet::Planet::Neptune, julian_day); // positioning for all the eight planets (and (the dwarf planet) Pluto) is supported let (plut_long, plut_lat, rad_vec) = pluto::heliocent_pos(julian_day); ``` -------------------------------- ### Convert Equatorial to Galactic Coordinates (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Demonstrates converting equatorial coordinates (Right Ascension and Declination) to galactic coordinates (longitude and latitude) using the `gal_frm_eq!` macro. It shows how to convert degrees, minutes, seconds (DMS) and hours, minutes, seconds (HMS) to radians before conversion. ```rust // equatorial coordinates of the Nova Serpentis 1978 let right_ascension = angle::deg_frm_hms(17, 48, 59.74).to_radians(); let declination = angle::deg_frm_dms(-14, 43, 8.2).to_radians(); // convert to galactic coordinates let (gal_long, gal_lat) = gal_frm_eq!(right_ascension, declination); ``` -------------------------------- ### Calculate Geocentric Positions of Sun and Moon (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Calculates the geocentric ecliptic position (longitude and latitude) and radius vector (distance) for the Sun and the Moon using the `astro::sun` and `astro::lunar` modules, based on a given Julian Day. ```rust // geocentric ecliptic point and radius vector of the Sun let (sun_ecl_point, rad_vec_sun) = sun::geocent_ecl_pos(julian_day); // sun_ecl_point.long - ecliptic longitude (radians) // sun_ecl_point.lat - ecliptic latitude (radians) // rad_vec_sun - distance between the Sun and the Earth (AU) // and similarly for the Moon let (moon_ecl_point, rad_vec_moon) = lunar::geocent_ecl_pos(julian_day); ``` -------------------------------- ### Calculate Geodesic Distance on Earth (Rust) Source: https://github.com/saurvs/astro-rust/blob/master/README.md Calculates the geodesic distance in meters between two geographical points on Earth. It uses `astro::coords::GeographPoint` to define locations by longitude and latitude (converted from degrees, minutes, seconds using `astro::angle::deg_frm_dms`) and `astro::planet::earth::geodesic_dist` to compute the distance. ```rust // geodesic distance between the Observatoire de Paris and // the US Naval Observatory at Washington DC let paris = coords::GeographPoint{long: angle::deg_frm_dms(-2, 20, 14.0).to_radians(), lat : angle::deg_frm_dms(48, 50, 11.0).to_radians()}; let washington = coords::GeographPoint{long: angle::deg_frm_dms(77, 3, 56.0).to_radians(), lat : angle::deg_frm_dms(38, 55, 17.0).to_radians()}; // angle::deg_frm_dms() converts degrees expressed in degrees, // minutes and seconds into a fractional degree let distance = planet::earth::geodesic_dist(&paris, &washington); // in meters ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.