| Crates.io | opticalc |
| lib.rs | opticalc |
| version | 0.1.4 |
| created_at | 2025-10-16 23:02:30.869184+00 |
| updated_at | 2025-10-17 21:56:51.853032+00 |
| description | Utility functions and types for common clinical optics calculations used in optometry and ophthalmic settings. |
| homepage | |
| repository | https://github.com/ocudigital/opticalc |
| max_upload_size | |
| id | 1886911 |
| size | 79,212 |
Rust utilities for common clinical optics calculations used in optometry and ophthalmic settings.
Features
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();