Expand description
§lightning-distance
Estimate how far away a lightning strike is from the delay between the flash and the thunder, and apply the standard 30-second safety rule.
Sound takes roughly 5 seconds to travel one mile (3 seconds per kilometer).
use lightning_distance::{miles, is_dangerous};
assert!((miles(10.0) - 2.0).abs() < 1e-9); // 10 s ~ 2 miles
assert_eq!(is_dangerous(10.0), true); // <= 30 s is dangerousConstants§
- DANGER_
THRESHOLD_ SECS - The standard “go inside” threshold (seconds).
- SECS_
PER_ KM - Seconds for sound to travel one kilometer (~3.0).
- SECS_
PER_ MILE - Seconds for sound to travel one statute mile (~5.0).
Functions§
- is_
dangerous - The 30-second rule: if the gap is <= 30 s the storm is close enough to be dangerous.
- kilometers
- Distance in kilometers from the delay in seconds.
- miles
- Distance in miles from the flash-to-thunder delay in seconds.