Browse Source

Mat4 decomposition methods;

bjorn 1 year ago
parent
commit
e1fd8e5abf

+ 174 - 1
api/init.lua

@@ -26111,6 +26111,175 @@ return {
                 }
               }
             },
+            {
+              name = "getOrientation",
+              summary = "Get the angle/axis rotation of the matrix.",
+              description = "Returns the angle/axis rotation of the matrix.",
+              key = "Mat4:getOrientation",
+              module = "lovr.math",
+              related = {
+                "Mat4:getPosition",
+                "Mat4:getScale",
+                "Mat4:getPose",
+                "Mat4:unpack",
+                "Mat4:set"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "angle",
+                      type = "number",
+                      description = "The number of radians the matrix rotates around its rotation axis."
+                    },
+                    {
+                      name = "ax",
+                      type = "number",
+                      description = "The x component of the axis of rotation."
+                    },
+                    {
+                      name = "ay",
+                      type = "number",
+                      description = "The y component of the axis of rotation."
+                    },
+                    {
+                      name = "az",
+                      type = "number",
+                      description = "The z component of the axis of rotation."
+                    }
+                  }
+                }
+              }
+            },
+            {
+              name = "getPose",
+              summary = "Get the position and rotation of the matrix.",
+              description = "Returns the position and rotation of the matrix.",
+              key = "Mat4:getPose",
+              module = "lovr.math",
+              related = {
+                "Mat4:getPosition",
+                "Mat4:getOrientation",
+                "Mat4:getScale",
+                "Mat4:unpack",
+                "Mat4:set"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x translation."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y translation."
+                    },
+                    {
+                      name = "z",
+                      type = "number",
+                      description = "The z translation."
+                    },
+                    {
+                      name = "angle",
+                      type = "number",
+                      description = "The number of radians the matrix rotates around its rotation axis."
+                    },
+                    {
+                      name = "ax",
+                      type = "number",
+                      description = "The x component of the axis of rotation."
+                    },
+                    {
+                      name = "ay",
+                      type = "number",
+                      description = "The y component of the axis of rotation."
+                    },
+                    {
+                      name = "az",
+                      type = "number",
+                      description = "The z component of the axis of rotation."
+                    }
+                  }
+                }
+              }
+            },
+            {
+              name = "getPosition",
+              summary = "Get the translation of the matrix.",
+              description = "Returns the translation of the matrix.  This is the last column of the matrix.",
+              key = "Mat4:getPosition",
+              module = "lovr.math",
+              related = {
+                "Mat4:getOrientation",
+                "Mat4:getScale",
+                "Mat4:getPose",
+                "Mat4:unpack",
+                "Mat4:set"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x translation."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y translation."
+                    },
+                    {
+                      name = "z",
+                      type = "number",
+                      description = "The z translation."
+                    }
+                  }
+                }
+              }
+            },
+            {
+              name = "getScale",
+              summary = "Get the scale factor of the matrix.",
+              description = "Returns the scale factor of the matrix.",
+              key = "Mat4:getScale",
+              module = "lovr.math",
+              related = {
+                "Mat4:getPosition",
+                "Mat4:getOrientation",
+                "Mat4:getPose",
+                "Mat4:unpack",
+                "Mat4:set"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "sx",
+                      type = "number",
+                      description = "The x scale."
+                    },
+                    {
+                      name = "sy",
+                      type = "number",
+                      description = "The y scale."
+                    },
+                    {
+                      name = "sz",
+                      type = "number",
+                      description = "The z scale."
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "identity",
               summary = "Reset the matrix to the identity.",
@@ -26891,7 +27060,11 @@ return {
               key = "Mat4:unpack",
               module = "lovr.math",
               related = {
-                "Mat4:set"
+                "Mat4:set",
+                "Mat4:getPosition",
+                "Mat4:getOrientation",
+                "Mat4:getScale",
+                "Mat4:getPose"
               },
               variants = {
                 {

+ 36 - 0
api/lovr/math/Mat4/getOrientation.lua

@@ -0,0 +1,36 @@
+return {
+  summary = 'Get the angle/axis rotation of the matrix.',
+  description = 'Returns the angle/axis rotation of the matrix.',
+  arguments = {},
+  returns = {
+    angle = {
+      type = 'number',
+      description = 'The number of radians the matrix rotates around its rotation axis.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  related = {
+    'Mat4:getPosition',
+    'Mat4:getScale',
+    'Mat4:getPose',
+    'Mat4:unpack',
+    'Mat4:set'
+  }
+}

+ 48 - 0
api/lovr/math/Mat4/getPose.lua

@@ -0,0 +1,48 @@
+return {
+  summary = 'Get the position and rotation of the matrix.',
+  description = 'Returns the position and rotation of the matrix.',
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x translation.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y translation.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z translation.'
+    },
+    angle = {
+      type = 'number',
+      description = 'The number of radians the matrix rotates around its rotation axis.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'z', 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  related = {
+    'Mat4:getPosition',
+    'Mat4:getOrientation',
+    'Mat4:getScale',
+    'Mat4:unpack',
+    'Mat4:set'
+  }
+}

+ 32 - 0
api/lovr/math/Mat4/getPosition.lua

@@ -0,0 +1,32 @@
+return {
+  summary = 'Get the translation of the matrix.',
+  description = 'Returns the translation of the matrix.  This is the last column of the matrix.',
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x translation.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y translation.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z translation.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'z' }
+    }
+  },
+  related = {
+    'Mat4:getOrientation',
+    'Mat4:getScale',
+    'Mat4:getPose',
+    'Mat4:unpack',
+    'Mat4:set'
+  }
+}

+ 32 - 0
api/lovr/math/Mat4/getScale.lua

@@ -0,0 +1,32 @@
+return {
+  summary = 'Get the scale factor of the matrix.',
+  description = 'Returns the scale factor of the matrix.',
+  arguments = {},
+  returns = {
+    sx = {
+      type = 'number',
+      description = 'The x scale.'
+    },
+    sy = {
+      type = 'number',
+      description = 'The y scale.'
+    },
+    sz = {
+      type = 'number',
+      description = 'The z scale.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'sx', 'sy', 'sz' }
+    }
+  },
+  related = {
+    'Mat4:getPosition',
+    'Mat4:getOrientation',
+    'Mat4:getPose',
+    'Mat4:unpack',
+    'Mat4:set'
+  }
+}

+ 5 - 1
api/lovr/math/Mat4/unpack.lua

@@ -25,6 +25,10 @@ return {
     }
   },
   related = {
-    'Mat4:set'
+    'Mat4:set',
+    'Mat4:getPosition',
+    'Mat4:getOrientation',
+    'Mat4:getScale',
+    'Mat4:getPose'
   }
 }