Expand description
§use-optics
Small wavelength and spectral helpers for RustUse.
use-optics provides visible-spectrum boundaries, wavelength classification helpers, and a compact
SpectralSample value type for lightweight optical calculations.
§What this crate provides
| Item | Purpose |
|---|---|
SpectralBand | Ultraviolet, visible, and infrared classification |
VISIBLE_MIN_NM / MAX_NM | Visible-light range constants |
classify_wavelength_nm() | Wavelength band classification |
wavelength_to_frequency_hz() | Frequency helper for a wavelength in nanometers |
SpectralSample | Small wavelength-plus-intensity value type |
§Installation
[dependencies]
use-optics = "0.1.0"§Example
use use_optics::{is_visible_wavelength_nm, SpectralSample, SpectralBand};
let sample = SpectralSample::new(450.0, 0.8);
assert_eq!(sample.band(), Some(SpectralBand::Visible));
assert!(is_visible_wavelength_nm(sample.wavelength_nm));§Scope
- Wavelength-first helpers.
- Small immutable values.
- No polarization, interference, or rendering pipeline yet.
Modules§
- prelude
- Common optics primitives.
Structs§
- Spectral
Sample - A simple wavelength-plus-intensity sample.
Enums§
- Spectral
Band - Coarse spectral bands used by the scaffold API.
Constants§
- SPEED_
OF_ LIGHT_ MPS - Speed of light in meters per second.
- VISIBLE_
MAX_ NM - Upper bound of the conventional visible spectrum in nanometers.
- VISIBLE_
MIN_ NM - Lower bound of the conventional visible spectrum in nanometers.
Functions§
- clamp_
visible_ wavelength_ nm - Clamps a valid wavelength into the visible range.
- classify_
wavelength_ nm - Classifies a wavelength in nanometers into a coarse spectral band.
- is_
visible_ wavelength_ nm - Returns whether the wavelength falls inside the conventional visible range.
- wavelength_
to_ frequency_ hz - Converts a wavelength in nanometers to frequency in hertz.