static double clamp01(double value) { if (value <= 0.0) return 0.0; if (value >= 1.0) return 1.0; return value; }