Browse Source

Add quat get/set euler

xiejiangzhi 10 months ago
parent
commit
1bb3e2f455
2 changed files with 41 additions and 0 deletions
  1. 18 0
      api/lovr/math/Quat/getEuler.lua
  2. 23 0
      api/lovr/math/Quat/setEuler.lua

+ 18 - 0
api/lovr/math/Quat/getEuler.lua

@@ -0,0 +1,18 @@
+return {
+  summary = 'Get the euler angles of the quaternion.',
+  description = [[
+    Rotation order is YXZ
+  ]],
+  arguments = {},
+  returns = {
+    pitch = { type = 'number', },
+    yaw = { type = 'number' },
+    roll = { type = 'number' }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'pitch', 'yaw', 'roll' }
+    }
+  },
+}

+ 23 - 0
api/lovr/math/Quat/setEuler.lua

@@ -0,0 +1,23 @@
+return {
+  summary = 'Set the quaternion by euler angles.',
+  description = [[
+    Rotation order is YXZ
+  ]],
+  arguments = {
+    pitch = { type = 'number', },
+    yaw = { type = 'number' },
+    roll = { type = 'number' }
+  },
+  returns = {
+    self = {
+      type = 'Quat',
+      description = 'The modified quaternion.'
+    },
+  },
+  variants = {
+    {
+      arguments = { 'pitch', 'yaw', 'roll' },
+      returns = { 'self' }
+    }
+  },
+}