{ x : Basics.Float, y : Basics.Float }
Two dimensional vector type
vec2 : Basics.Float -> Basics.Float -> Vec2
Creates a new 2-element vector with the given values.
The set functions create a new copy of the vector, updating a single field.
getX : Vec2 -> Basics.Float
Extract the x component of a vector.
getY : Vec2 -> Basics.Float
Extract the y component of a vector.
setX : Basics.Float -> Vec2 -> Vec2
Update the x component of a vector, returning a new vector.
setY : Basics.Float -> Vec2 -> Vec2
Update the y component of a vector, returning a new vector.
add : Vec2 -> Vec2 -> Vec2
Vector addition: a + b
sub : Vec2 -> Vec2 -> Vec2
Vector subtraction: a - b
negate : Vec2 -> Vec2
Vector negation: -a
scale : Basics.Float -> Vec2 -> Vec2
Multiply the vector by a scalar: s * v
dot : Vec2 -> Vec2 -> Basics.Float
The dot product of a and b
normalize : Vec2 -> Vec2
A unit vector with the same direction as the given vector: a / |a|
direction : Vec2 -> Vec2 -> Vec2
The normalized direction from b to a: (a - b) / |a - b|
mul : Vec2 -> Vec2 -> Vec2
Multiply the vector values by other vector values: a * b
length : Vec2 -> Basics.Float
The length of the given vector: |a|
lengthSquared : Vec2 -> Basics.Float
The square of the length of the given vector: |a| * |a|
distance : Vec2 -> Vec2 -> Basics.Float
The distance between two vectors.
distanceSquared : Vec2 -> Vec2 -> Basics.Float
The square of the distance between two vectors.
max : Vec2 -> Vec2 -> Vec2
Get longest vector of two
projection : Vec2 -> Vec2 -> Vec2
Projecting one vector onto another
toRecord : Vec2 -> { x : Basics.Float, y : Basics.Float }
Convert a vector to a record.
fromRecord : { x : Basics.Float, y : Basics.Float } -> Vec2
Convert a record to a vector.