File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
[gameplay]/superman/vectors Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
function newVector3D (posX , posY , posZ )
2
2
local newVector = {x = posX or 0.0 , y = posY or 0.0 , z = posZ or 0.0 }
3
-
4
3
return newVector
5
4
end
6
5
7
6
function moduleVector3D (vector3D )
7
+ if not vector3D or type (vector3D .x ) ~= " number" then
8
+ return 0
9
+ end
8
10
return math.sqrt (vector3D .x * vector3D .x + vector3D .y * vector3D .y + vector3D .z * vector3D .z )
9
11
end
10
12
11
13
function normalizeVector3D (vector3D )
14
+ if not vector3D or type (vector3D .x ) ~= " number" then
15
+ return newVector3D (0 , 0 , 0 )
16
+ end
12
17
local mod = moduleVector3D (vector3D )
13
-
14
18
if mod ~= 0 then
15
19
vector3D .x = vector3D .x / mod
16
20
vector3D .y = vector3D .y / mod
17
21
vector3D .z = vector3D .z / mod
18
22
end
19
-
20
23
return vector3D
21
24
end
22
25
23
26
function mulVector3D (vector3D , n )
27
+ if not vector3D or type (vector3D .x ) ~= " number" or type (n ) ~= " number" then
28
+ return newVector3D (0 , 0 , 0 )
29
+ end
24
30
return newVector3D (vector3D .x * n , vector3D .y * n , vector3D .z * n )
25
- end
31
+ end
You can’t perform that action at this time.
0 commit comments