4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
fn.vsep = function(vec) -- separate a vector into a direction + magnitude
return vec:normalize(), vec:length()
end
-- minetest now only provides the version of this function that sqrts the result
-- which is pointlessly wasteful much of the time
fn.vdsq = function(a,b)
local d = vector.subtract(v1,v2)
return (d.x ^ 2) + (d.y ^ 2) + (d.z ^ 2)
end
fn.vdcomp = function(dist,v1,v2) -- compare the distance between two points
-- (cheaper than calculating distance outright)
local d if v2
then d = vector.subtract(v1,v2)
|
|
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
fn.vsep = function(vec) -- separate a vector into a direction + magnitude
return vec:normalize(), vec:length()
end
-- minetest now only provides the version of this function that sqrts the result
-- which is pointlessly wasteful much of the time
fn.vdsq = function(a,b)
local d = vector.subtract(a,b)
return (d.x ^ 2) + (d.y ^ 2) + (d.z ^ 2)
end
fn.vdcomp = function(dist,v1,v2) -- compare the distance between two points
-- (cheaper than calculating distance outright)
local d if v2
then d = vector.subtract(v1,v2)
|