Skip to main content

Crate use_optics

Crate use_optics 

Source
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

ItemPurpose
SpectralBandUltraviolet, visible, and infrared classification
VISIBLE_MIN_NM / MAX_NMVisible-light range constants
classify_wavelength_nm()Wavelength band classification
wavelength_to_frequency_hz()Frequency helper for a wavelength in nanometers
SpectralSampleSmall 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§

SpectralSample
A simple wavelength-plus-intensity sample.

Enums§

SpectralBand
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.