blob: 056c657fbdb61a57edaa70267cfde512f9740b1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
module Vec2 where
type alias Vec2 =
{ x : Float
, y : Float
}
add : Vec2 -> Vec2 -> Vec2
add v1 v2 =
{ x = v1.x + v2.x
, y = v1.y + v2.y
}
sub : Vec2 -> Vec2 -> Vec2
sub v1 v2 =
{ x = v1.x - v2.x
, y = v1.y - v2.y
}
mul : Float -> Vec2 -> Vec2
mul m v =
{ x = m * v.x
, y = m * v.y
}
div : Vec2 -> Float -> Vec2
div v d =
{ x = v.x / d
, y = v.y / d
}
isNull : Vec2 -> Bool
isNull v = (v.x == 0) && (v.y == 0)
originVec : Vec2
originVec = { x = 0, y = 0 }
|