Pebble.Game.Math
Small math helpers for game and animation code.
Vectors
Vec2
type alias Vec2 =
{ x : Float
, y : Float
}Two-dimensional floating-point vector.
vec2
vec2 : Float -> Float -> Vec2Construct a vector from x/y components.
add
add : Vec2 -> Vec2 -> Vec2Add two vectors.
sub
sub : Vec2 -> Vec2 -> Vec2Subtract the second vector from the first.
scale
scale : Float -> Vec2 -> Vec2Scale a vector by a scalar factor.
lengthSquared
lengthSquared : Vec2 -> FloatSquared vector length.
Use this when comparing distances without needing the square root.
distanceSquared
distanceSquared : Vec2 -> Vec2 -> FloatSquared distance between two vectors.
Scalars
clamp
clamp : comparable -> comparable -> comparable -> comparableClamp a value between lower and upper bounds.