--------------------------------------------------------------------------------
function math.hypot(x, y)
- local t
- x = math.abs(x)
- y = math.abs(y)
- t = math.min(x, y)
- x = math.max(x, y)
- if x == 0 then return 0 end
- t = t / x
- return x * math.sqrt(1 + t * t)
+ return math.sqrt(x * x + y * y)
end
--------------------------------------------------------------------------------
return nil
end
- local p = {}
- p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
- if p.x and p.y and p.z then
- p.x = tonumber(p.x)
- p.y = tonumber(p.y)
- p.z = tonumber(p.z)
- return p
- end
- p = {}
- p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
- if p.x and p.y and p.z then
- p.x = tonumber(p.x)
- p.y = tonumber(p.y)
- p.z = tonumber(p.z)
- return p
+ local x, y, z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
+ if x and y and z then
+ x = tonumber(x)
+ y = tonumber(y)
+ z = tonumber(z)
+ return vector.new(x, y, z)
+ end
+ x, y, z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
+ if x and y and z then
+ x = tonumber(x)
+ y = tonumber(y)
+ z = tonumber(z)
+ return vector.new(x, y, z)
end
return nil
end