pub struct SolarPosition { /* private fields */ }Expand description
Solar position in topocentric coordinates.
Represents the sun’s position as seen from a specific point on Earth’s surface. Uses the standard astronomical coordinate system where:
- Azimuth: 0° = North, measured clockwise to 360°
- Zenith angle: 0° = directly overhead (zenith), 90° = horizon, 180° = nadir
- Elevation angle: 90° = directly overhead, 0° = horizon, -90° = nadir
Implementations§
Source§impl SolarPosition
impl SolarPosition
Sourcepub fn new(azimuth: f64, zenith_angle: f64) -> Result<Self>
pub fn new(azimuth: f64, zenith_angle: f64) -> Result<Self>
Creates a new solar position from azimuth and zenith angle.
§Arguments
azimuth- Azimuth angle in degrees (will be normalized to 0-360°)zenith_angle- Zenith angle in degrees (must be 0-180°)
§Returns
Solar position or error if zenith angle is invalid
§Errors
Returns error if azimuth or zenith angles are outside valid ranges.
§Example
let position = SolarPosition::new(180.0, 30.0).unwrap();
assert_eq!(position.azimuth(), 180.0);
assert_eq!(position.zenith_angle(), 30.0);
assert_eq!(position.elevation_angle(), 60.0);Sourcepub const fn azimuth(&self) -> f64
pub const fn azimuth(&self) -> f64
Gets the azimuth angle in degrees.
§Returns
Azimuth angle (0° to 360°, 0° = North, increasing clockwise)
Sourcepub const fn zenith_angle(&self) -> f64
pub const fn zenith_angle(&self) -> f64
Sourcepub fn elevation_angle(&self) -> f64
pub fn elevation_angle(&self) -> f64
Gets the elevation angle in degrees.
This is the complement of the zenith angle: elevation = 90° - zenith
§Returns
Elevation angle (-90° to 90°, 90° = zenith, 0° = horizon, -90° = nadir)
Sourcepub fn is_sun_down(&self) -> bool
pub fn is_sun_down(&self) -> bool
Checks if the sun is at or below the horizon.
§Returns
true if elevation angle <= 0°, false otherwise
Trait Implementations§
Source§impl Clone for SolarPosition
impl Clone for SolarPosition
Source§fn clone(&self) -> SolarPosition
fn clone(&self) -> SolarPosition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SolarPosition
impl Debug for SolarPosition
Source§impl PartialEq for SolarPosition
impl PartialEq for SolarPosition
impl Copy for SolarPosition
impl StructuralPartialEq for SolarPosition
Auto Trait Implementations§
impl Freeze for SolarPosition
impl RefUnwindSafe for SolarPosition
impl Send for SolarPosition
impl Sync for SolarPosition
impl Unpin for SolarPosition
impl UnwindSafe for SolarPosition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more