summaryrefslogtreecommitdiff
path: root/honey/quaternion.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-03-23 13:35:37 -0500
committersanine-a <sanine.not@pm.me>2023-03-23 13:35:37 -0500
commite5553bb81c93cd76456d07d3a1d7e8bb1b249b6e (patch)
treea92801deaba55c85dd4f52636ab4f616e8483796 /honey/quaternion.lua
parentf4346b8f06653dbc1e0c346d88f5f83ca8a7b876 (diff)
implement skeleton of physics system
Diffstat (limited to 'honey/quaternion.lua')
-rw-r--r--honey/quaternion.lua30
1 files changed, 30 insertions, 0 deletions
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