opensolid/geometry/2.0.1

NOTE: this package is not compatible with Elm 0.19.1

OpenSolid.Scalar

Convenience functions for working with scalar (floating-point) values.

equalWithin : Float -> Float -> Float -> Bool

Check if two values are equal within a given tolerance.

Scalar.equalWithin 1e-6 1.9999 2.0001
--> False


Scalar.equalWithin 1e-3 1.9999 2.0001
--> True
interpolateFrom : Float -> Float -> Float -> Float

Interpolate from the first value to the second, based on a parameter that ranges from zero to one. Passing a parameter value of zero will return the start value and passing a parameter value of one will return the end value.

Scalar.interpolateFrom 5 10 0.5
--> 7.5


Scalar.interpolateFrom 2 -2 0.75
--> -1

Parameter values less than zero or greater than one can be used to extrapolate:

Scalar.interpolateFrom 5 10 1.5
--> 12.5


Scalar.interpolateFrom 2 -2 -0.25
--> 3