Skip to main content

MathUtils

Namespace

Namespace in the Lens Scripting API.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Variables

VariableDescription
DegToRadConstant mapping degrees to radians. This equals pi/180.
RadToDegConstant mapping radians to degrees. This equals 180/pi.

Functions

FunctionDescription
clampClamp floating-point value v in the range [lo, hi] (inclusive).
lerpLinearly interpolate from floating-point a to b, based on fraction t (where t=0.0 returns a, and t=1.0 returns b). This is equivalent to the vec2 and vec3 lerp() functions, but operates on scalar floating-point values.
randomRangeGenerate a random floating-point value in the range [lo, hi). Note, the range is inclusive at the lower end, and exclusive at the upper.
remapMap floating-point v from range [inMin, inMax] to [outMin, outMax].