2 func plus(a,b:Vec2 -> Vec2; inline)
3 return Vec2(a.x+b.x, a.y+b.y)
5 func minus(a,b:Vec2 -> Vec2; inline)
6 return Vec2(a.x-b.x, a.y-b.y)
8 func dot(a,b:Vec2 -> Int; inline)
9 return a.x*b.x + a.y*b.y
11 func scaled_by(a:Vec2, k:Int -> Vec2; inline)
12 return Vec2(a.x*k, a.y*k)
14 func times(a,b:Vec2 -> Vec2; inline)
15 return Vec2(a.x*b.x, a.y*b.y)
17 func divided_by(a:Vec2, k:Int -> Vec2; inline)
18 return Vec2(a.x/k, a.y/k)
20 func negative(v:Vec2 -> Vec2; inline)
21 return Vec2(-v.x, -v.y)
23 func negated(v:Vec2 -> Vec2; inline)
24 return Vec2(not v.x, not v.y)
26 func bit_and(a,b:Vec2 -> Vec2; inline)
27 return Vec2(a.x and b.x, a.y and b.y)
29 func bit_or(a,b:Vec2 -> Vec2; inline)
30 return Vec2(a.x or b.x, a.y or b.y)
32 func bit_xor(a,b:Vec2 -> Vec2; inline)
33 return Vec2(a.x xor b.x, a.y xor b.y)
35 func left_shifted(v:Vec2, bits:Int -> Vec2; inline)
36 return Vec2(v.x >> bits, v.y >> bits)
38 func right_shifted(v:Vec2, bits:Int -> Vec2; inline)
39 return Vec2(v.x << bits, v.y << bits)
41 func modulo(v:Vec2, modulus:Int -> Vec2; inline)
42 return Vec2(v.x mod modulus, v.y mod modulus)
44 func modulo1(v:Vec2, modulus:Int -> Vec2; inline)
45 return Vec2(v.x mod1 modulus, v.y mod1 modulus)
49 >> y := Vec2(100, 200)
50 assert x + y == Vec2(x=110, y=220)
51 assert x - y == Vec2(x=-90, y=-180)
52 assert x * y == Vec2(x=1000, y=4000)
53 assert x.dot(y) == 5000
54 assert x * -1 == Vec2(x=-10, y=-20)
55 assert -10 * x == Vec2(x=-100, y=-200)
59 assert x == Vec2(x=11, y=22)
61 assert x == Vec2(x=110, y=-22)
64 assert x == Vec2(x=-110, y=22)
67 assert -x == Vec2(x=-1, y=-2)
71 assert (x and y) == Vec2(x=0, y=2)
72 assert (x or y) == Vec2(x=5, y=3)
73 assert (x xor y) == Vec2(x=5, y=1)
74 assert x / 2 == Vec2(x=0, y=1)
75 assert x mod 3 == Vec2(x=1, y=2)
76 assert x mod1 3 == Vec2(x=1, y=2)