[added] tostring for vec2 and vec3 - not sure how to handle wanting more/less precision for these currently.

This commit is contained in:
Max Cahill 2020-04-08 21:10:03 +10:00
parent c191a7b4f6
commit afd279f1db
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,11 @@ local math = require(path .. "mathx") --shadow global math module
local vec2 = class()
vec2.type = "vec2"
--stringification
vec2.__mt.__tostring = function(self)
return ("(%.2f, %.2f)"):format(self.x, self.y)
end
--probably-too-flexible ctor
function vec2:new(x, y)
if x and y then

View File

@ -11,6 +11,11 @@ local math = require(path .. "mathx") --shadow global math module
local vec3 = class()
vec3.type = "vec3"
--stringification
vec2.__mt.__tostring = function(self)
return ("(%.2f, %.2f, %.2f)"):format(self.x, self.y, self.z)
end
--probably-too-flexible ctor
function vec3:new(x, y, z)
if x and y and z then