No matching definitions.

math/math

src/math/math.tur
defn

clamp

(clamp [x :float lo :float hi :float] :float)

clamp a float value to [lo, hi].

xinput value
lolower bound
hiupper bound

x clamped to [lo, hi].

(clamp 1.5 0.0 1.0)  ; => 1.0

Since: P1

defn

lerp

(lerp [a :float b :float t :float] :float)

linear interpolation between a and b by t.

astart value
bend value
tinterpolation factor (0.0=a, 1.0=b)

a + t*(b-a)

(lerp 0.0 10.0 0.5)  ; => 5.0

Since: P1

defn

remap

(remap [x :float in-lo :float in-hi :float out-lo :float out-hi :float] :float)

remap x from [in-lo, in-hi] to [out-lo, out-hi].

xinput value
in-loinput range low
in-hiinput range high
out-looutput range low
out-hioutput range high

x remapped to [out-lo, out-hi].

(remap 5.0 0.0 10.0 0.0 1.0)  ; => 0.5

Since: P1

defn

deg->rad

(deg->rad [deg :float] :float)

convert degrees to radians.

degangle in degrees

Angle in radians.

(deg->rad 180.0)  ; => 3.14159...

Since: P1

defn

rad->deg

(rad->deg [rad :float] :float)

convert radians to degrees.

radangle in radians

Angle in degrees.

(rad->deg 3.14159)  ; => ~180.0

Since: P1

defn

approx-eq

(approx-eq [a :float b :float eps :float] :bool)

test whether two floats are approximately equal within epsilon.

afirst value
bsecond value
epstolerance (use 1e-6 for most purposes)

true if |a - b| < eps.

(approx-eq 0.1 0.10001 1e-4)  ; => true

Since: P1