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 11function newVector3D (posX , posY , posZ )
22 local newVector = {x = posX or 0.0 , y = posY or 0.0 , z = posZ or 0.0 }
3-
43 return newVector
54end
65
76function moduleVector3D (vector3D )
7+ if not vector3D or type (vector3D .x ) ~= " number" then
8+ return 0
9+ end
810 return math.sqrt (vector3D .x * vector3D .x + vector3D .y * vector3D .y + vector3D .z * vector3D .z )
911end
1012
1113function normalizeVector3D (vector3D )
14+ if not vector3D or type (vector3D .x ) ~= " number" then
15+ return newVector3D (0 , 0 , 0 )
16+ end
1217 local mod = moduleVector3D (vector3D )
13-
1418 if mod ~= 0 then
1519 vector3D .x = vector3D .x / mod
1620 vector3D .y = vector3D .y / mod
1721 vector3D .z = vector3D .z / mod
1822 end
19-
2023 return vector3D
2124end
2225
2326function 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
2430 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