CalculationsKt

public final class CalculationsKt

Functions

constrain
Link copied to clipboard
final static Float constrain(Float n, Float low, Float high)

Constrains a value between a minimum and maximum value.

lerp
Link copied to clipboard
final static Float lerp(Float start, Float stop, Float amt)

Calculates a number between two numbers at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, and 1.0 is equal to the second point. If the value of amt is more than 1.0 or less than 0.0, the number will be calculated accordingly in the ratio of the two given numbers. The lerp function is convenient for creating motion along a straight path and for drawing dotted lines.

map
Link copied to clipboard
final static Float map(Float n, Float start1, Float stop1, Float start2, Float stop2, Boolean withBounds)

Re-maps a number from one range to another.

norm
Link copied to clipboard
final static Float norm(Float n, Float start, Float stop)

Normalizes a number from another range into a value between 0 and 1. Identical to map(value, low, high, 0, 1). Numbers outside of the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. (See the example above.)