static double normalizeTo0to1(double x) { ret Math.min(Math.max(x, 0), 1); }