-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVector2d.lua
More file actions
66 lines (29 loc) · 728 Bytes
/
Vector2d.lua
File metadata and controls
66 lines (29 loc) · 728 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---------------------------------------------------------
---------------[[Created by STR_Warrior]]----------------
---------------------------------------------------------
Vector2d = {}
function Vector2d:__call(a_X, a_Z)
local Obj = {}
setmetatable(Obj, Vector2d)
Obj.__index = Obj
Obj.x = a_X
Obj.z = a_Z
return Obj
end
function Vector2d:__add(a_Vector2)
return Vector2d(
self.x + a_Vector2.x,
self.z + a_Vector2.z
)
end
function Vector2d:__sub(a_Vector2)
return Vector2d(
self.x - a_Vector2.x,
self.z - a_Vector2.z
)
end
function Vector2d:Length()
return math.sqrt(self.x * self.x + self.z * self.z)
end
setmetatable(Vector2d, Vector2d)
Vector2d.__index = Vector2d