Function snapToDoubleRange

Function Documentation

double snapToDoubleRange(double value, double from_value, double to_value, double step)

Snaps and clamps a double value to a given range and step.

Note: The value is snapped to the nearest integer number of steps from the ‘from_value’ or clamped to the ‘to_value’.

The magnitude of the ‘step’ is used and the sign is ignored.

If ‘step’ == 0 or if ‘from_value’ is == double::lowest(), the range is considered continuous.

Parameters:
  • value – Input value.

  • from_value – Range minimum.

  • to_value – Range maximum.

  • step – Step size.