Expand description
§opticalc
Rust utilities for common clinical optics calculations used in optometry and ophthalmic settings.
Features
- Index conversion: Convert measured lens powers between assumed and actual refractive indices.
- Rx conversion: Scale full sphero‑cyl prescriptions between indices while preserving axis.
- Lensmeter simulation: Predict what a lensmeter would read for a true Rx at a different index.
- Induced prism: Compute horizontal/vertical prism from decentration using the full power matrix.
- Crossed cylinders and oblique meridian helpers.
§Examples
use opticalc::*;
// Convert a measured power from 1.523 to 1.586
let true_power = convert_power(-4.463, 1.523, 1.586);
// Convert a full sphero‑cyl Rx between indices
let measured = SpheroCyl { sphere: -2.00, cylinder: -1.00, axis_deg: 180.0 };
let true_rx = convert_rx(measured, 1.523, 1.586);
// Simulate what a lensmeter @1.523 would read for a true Rx @1.586
let reading = simulate_lensmeter_reading(true_rx, 1.523, 1.586);
Induced prism from decentration (Prentice’s rule, full toric matrix):
use opticalc::*;
let lens = SpheroCyl { sphere: 2.0, cylinder: -1.0, axis_deg: 25.0 };
let dec = Decentration { horizontal_mm: 2.0, vertical_mm: -1.0 };
let p = induced_prism(Eye::OD, lens, dec);
// Access signed or magnitude/base components
let h_signed = p.horizontal.signed();
let v_signed = p.vertical.signed();
let mag = p.magnitude();
Structs§
- Combined
Prism - Represents combined horizontal and vertical prism components.
- Decentration
- Represents lens decentration relative to the optical center.
- Horizontal
Prism - Represents horizontal prism in prism diopters, with an explicit base direction.
- Sphero
Cyl - Defines a sphero-cylinder lens.
- Vertical
Prism - Represents vertical prism in prism diopters, with an explicit base direction.
Enums§
- Eye
- Defines the eye.
- Horizontal
Base - Base direction for horizontal prism relative to the patient.
- Vertical
Base - Base direction for vertical prism.
Constants§
- CROWN_
GLASS_ INDEX - Refractive index of Crown Glass (standard optical glass).
- CR_
39_ INDEX - Refractive index of CR-39 (Columbia Resin #39).
- HIGH_
INDEX_ 160_ INDEX - Refractive index of High-Index 1.60 plastic.
- HIGH_
INDEX_ 167_ INDEX - Refractive index of High-Index 1.67 plastic.
- HIGH_
INDEX_ 174_ INDEX - Refractive index of High-Index 1.74 plastic.
- POLYCARBONATE_
INDEX - Refractive index of Polycarbonate.
- TRIVEX_
INDEX - Refractive index of Trivex.
Functions§
- convert_
power - Convert a lens power measured under an assumed refractive index to the true power for the actual material index.
- convert_
rx - Convert a full sph-cyl-axis Rx measured under an assumed index to the true Rx at the actual index. Axis is returned unchanged.
- crossed_
cylinders - Calculate Obliquely Crossed Cylinders
- induced_
prism - Compute induced prism using the full sphero-cylinder power matrix, including toric cross-terms, with OD/OS handling, returning clinical base directions.
- minimum_
blank_ size - Calculate the minimum blank size for a single vision lens.
- oblique_
meridian - Oblique Meridian Power
- recommended_
blank_ size - Calculate the recommended blank size including working edge border.
- simulate_
lensmeter_ reading - Inverse of
convert_rx
: given the true Rx at the actual index, compute what a lensmeter calibrated to the assumed index would read. Axis is unchanged. - transpose
- Transpose a spherocylindrical lens prescription to the opposite cylinder form.