MCPcopy Create free account
hub / github.com/5ocworkshop/bgraph / normalize_value

Function normalize_value

src/functions/fnc_normalize.rs:16–27  ·  view source on GitHub ↗

Normalize a value to 0.0-1.0 range. Returns None for invalid ranges or values.

(value: f32, min: f32, max: f32)

Source from the content-addressed store, hash-verified

14
15/// Normalize a value to 0.0-1.0 range. Returns None for invalid ranges or values.
16pub(crate) fn normalize_value(value: f32, min: f32, max: f32) -> Option<f32> {
17 let range = max - min;
18 if !range.is_finite() || range.abs() < 0.0001 {
19 return None;
20 }
21
22 if !value.is_finite() {
23 return None;
24 }
25
26 Some(((value - min) / range).clamp(0.0, 1.0))
27}
28
29// <FILE>src/functions/fnc_normalize.rs</FILE> - <DESC>Normalization helpers for value-based coloring</DESC>
30// <VERS>END OF VERSION: 1.0.0</VERS>

Callers 3

renderMethod · 0.85
renderMethod · 0.85
render_brailleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected