From e5553bb81c93cd76456d07d3a1d7e8bb1b249b6e Mon Sep 17 00:00:00 2001 From: sanine-a Date: Thu, 23 Mar 2023 13:35:37 -0500 Subject: implement skeleton of physics system --- honey/quaternion.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 honey/quaternion.lua (limited to 'honey/quaternion.lua') diff --git a/honey/quaternion.lua b/honey/quaternion.lua new file mode 100644 index 0000000..6fbfdd5 --- /dev/null +++ b/honey/quaternion.lua @@ -0,0 +1,30 @@ +local glm = honey.glm +local Mat4 = require "honey.mat4" + +local module = {} +setmetatable(module, {__index=_G}) +setfenv(1, module) + +Quaternion = {} +Quaternion.__index = Quaternion + + +function Quaternion.new(_, tbl) + local tbl = tbl or { 0, 0, 0, 0 } + local self = {} + self.data = glm.quat_create() + glm.quat_init(self.data, unpack(tbl)) + setmetatable(self, Quaternion) + return self +end +setmetatable(Quaternion, {__call=Quaternion.new}) + + +function Quaternion.toMat4(self) + local m = Mat4() + glm.quat_mat4(self.data, m.data) + return m +end + + +return module.Quaternion -- cgit v1.2.1