summaryrefslogtreecommitdiff
path: root/common/coords.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-02-03 01:32:09 +0000
committerubq323 <ubq323@ubq323.website>2023-02-03 01:32:09 +0000
commitec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 (patch)
tree1893ad4fe5dc651370411f2bc84060cd7c0465cb /common/coords.lua
parent04664ee48de5fc8b06a584e20a4b75c41dafa558 (diff)
drawing changes, world generation, perlin noise
Diffstat (limited to 'common/coords.lua')
-rw-r--r--common/coords.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/common/coords.lua b/common/coords.lua
index 1bb9154..2399e43 100644
--- a/common/coords.lua
+++ b/common/coords.lua
@@ -76,6 +76,8 @@ function Pos.__div(a,b)
end
function Pos.lensq(self) return self.x^2 + self.y^2 end
function Pos.len(self) return math.sqrt(self:lensq()) end
+function Pos.norm(self) return self/self:len() end
+function Pos.dot(self,other) return self.x*other.x + self.y*other.y end
function Pos.to_hex(self)
local q = self.x*(SR3/3) - self.y*(1/3)
local r = (2/3)*self.y