double clamp(double min, double max) { if (this < min) { return min; } else if (this > max) { return max; } else { return this; } }