blob: 24b42141c930c2a41487a8932f10044c15ac6e6a (
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
|
local M = {}
function M.copy(t)
local c = {}
for k,v in pairs(t) do
c[k] = v
end
return c
end
function M.deepcopy(t)
local copied = {}
local function dc(t)
if not copied[t] then
local c = {}
copied[t] = c
for k,v in pairs(t) do
if type(v) == 'table' then
v = dc(v)
end
c[k] = v
end
end
return copied[t]
end
return dc(t)
end
function M.rot(a, x, y)
return x*math.cos(a) - y*math.sin(a), x*math.sin(a) + y*math.cos(a)
end
return M
|