18 lines
398 B
Lua
18 lines
398 B
Lua
-- math library
|
|
|
|
function vec3_magnitude(_x, _y, _z)
|
|
return math.sqrt(_x * _x + _y * _y + _z * _z)
|
|
end
|
|
|
|
function vec3_normalize(_x, _y, _z)
|
|
local mag = vec3_magnitude(_x, _y, _z)
|
|
if mag == 0 then return 0, 0, 0 end
|
|
return _x / mag, _y / mag, _z / mag
|
|
end
|
|
|
|
function vec3_cross(_x1, _y1, _z1, _x2, _y2, _z2)
|
|
return _y1 * _z2 - _y2 * _z1,
|
|
_z1 * _x2 - _z2 * _x1,
|
|
_x1 * _y2 - _x2 * _y1
|
|
end
|