Browse Source

Merge pull request #41 from jmiskovic/fix/quat-api

Align docs with current quat API
Bjorn 4 years ago
parent
commit
e5a177fe64
3 changed files with 14 additions and 40 deletions
  1. 6 27
      api/init.lua
  2. 8 4
      api/lovr/math/Quat/mul.lua
  3. 0 9
      api/lovr/math/Quat/set.lua

+ 6 - 27
api/init.lua

@@ -17862,7 +17862,7 @@ return {
             {
             {
               name = "mul",
               name = "mul",
               summary = "Multiply a quaternion by another quaternion or a vector.",
               summary = "Multiply a quaternion by another quaternion or a vector.",
-              description = "Multiplies this quaternion by another value.  If the value is a quaternion, the rotations in the two quaternions are applied sequentially and the result is stored in the first quaternion.  If the value is a vector, then the vector is rotated by the quaternion.",
+              description = "Multiplies this quaternion by another value.  If the value is a quaternion, the rotations in the two quaternions are applied sequentially and the result is stored in the first quaternion.  If the value is a vector, then the input vector is rotated by the quaternion and returned.",
               key = "Quat:mul",
               key = "Quat:mul",
               module = "lovr.math",
               module = "lovr.math",
               variants = {
               variants = {
@@ -17885,16 +17885,16 @@ return {
                 {
                 {
                   arguments = {
                   arguments = {
                     {
                     {
-                      name = "v",
+                      name = "v3",
                       type = "vec3",
                       type = "vec3",
                       description = "A vector to rotate."
                       description = "A vector to rotate."
                     }
                     }
                   },
                   },
                   returns = {
                   returns = {
                     {
                     {
-                      name = "q",
-                      type = "quat",
-                      description = "The original quaternion."
+                      name = "v3",
+                      type = "vec3",
+                      description = "Vector rotated by quaternion."
                     }
                     }
                   }
                   }
                 }
                 }
@@ -17926,7 +17926,7 @@ return {
             {
             {
               name = "set",
               name = "set",
               summary = "Set the components of the quaternion.",
               summary = "Set the components of the quaternion.",
-              description = "Sets the components of the quaternion.  There are lots of different ways to specify the new components, the summary is:\n\n- Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.\n  - Alternatively, a `vec3` can be used for the axis.\n- Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.\n- An existing quaternion can be passed in to copy its values.\n- A single direction vector can be specified to turn its direction (relative to the default\n  forward direction of \"negative z\") into a rotation.\n- Two direction vectors can be specified to set the quaternion equal to the rotation between the\n  two vectors.\n- A matrix can be passed in to extract the rotation of the matrix into a quaternion.",
+              description = "Sets the components of the quaternion.  There are lots of different ways to specify the new components, the summary is:\n\n- Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.\n- Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.\n- An existing quaternion can be passed in to copy its values.\n- A single direction vector can be specified to turn its direction (relative to the default\n  forward direction of \"negative z\") into a rotation.\n- Two direction vectors can be specified to set the quaternion equal to the rotation between the\n  two vectors.\n- A matrix can be passed in to extract the rotation of the matrix into a quaternion.",
               key = "Quat:set",
               key = "Quat:set",
               module = "lovr.math",
               module = "lovr.math",
               related = {
               related = {
@@ -17973,27 +17973,6 @@ return {
                     }
                     }
                   }
                   }
                 },
                 },
-                {
-                  arguments = {
-                    {
-                      name = "angle",
-                      description = "The angle to use for the rotation, in radians.",
-                      default = "0"
-                    },
-                    {
-                      name = "axis",
-                      type = "vec3",
-                      description = "The axis of rotation (does not need to be normalized)."
-                    }
-                  },
-                  returns = {
-                    {
-                      name = "q",
-                      type = "quat",
-                      description = "The original quaternion."
-                    }
-                  }
-                },
                 {
                 {
                   arguments = {
                   arguments = {
                     {
                     {

+ 8 - 4
api/lovr/math/Quat/mul.lua

@@ -3,14 +3,14 @@ return {
   description = [[
   description = [[
     Multiplies this quaternion by another value.  If the value is a quaternion, the rotations in the
     Multiplies this quaternion by another value.  If the value is a quaternion, the rotations in the
     two quaternions are applied sequentially and the result is stored in the first quaternion.  If
     two quaternions are applied sequentially and the result is stored in the first quaternion.  If
-    the value is a vector, then the vector is rotated by the quaternion.
+    the value is a vector, then the input vector is rotated by the quaternion and returned.
   ]],
   ]],
   arguments = {
   arguments = {
     r = {
     r = {
       type = 'quat',
       type = 'quat',
       description = 'A quaternion to combine with the original.'
       description = 'A quaternion to combine with the original.'
     },
     },
-    v = {
+    v3 = {
       type = 'vec3',
       type = 'vec3',
       description = 'A vector to rotate.'
       description = 'A vector to rotate.'
     }
     }
@@ -19,6 +19,10 @@ return {
     q = {
     q = {
       type = 'quat',
       type = 'quat',
       description = 'The original quaternion.'
       description = 'The original quaternion.'
+    },
+    v3 = {
+      type = 'vec3',
+      description = 'Vector rotated by quaternion.'
     }
     }
   },
   },
   variants = {
   variants = {
@@ -27,8 +31,8 @@ return {
       returns = { 'q' }
       returns = { 'q' }
     },
     },
     {
     {
-      arguments = { 'v' },
-      returns = { 'q' }
+      arguments = { 'v3' },
+      returns = { 'v3' }
     }
     }
   }
   }
 }
 }

+ 0 - 9
api/lovr/math/Quat/set.lua

@@ -5,7 +5,6 @@ return {
     components, the summary is:
     components, the summary is:
 
 
     - Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.
     - Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.
-      - Alternatively, a `vec3` can be used for the axis.
     - Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.
     - Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion.
     - An existing quaternion can be passed in to copy its values.
     - An existing quaternion can be passed in to copy its values.
     - A single direction vector can be specified to turn its direction (relative to the default
     - A single direction vector can be specified to turn its direction (relative to the default
@@ -34,10 +33,6 @@ return {
       default = '0',
       default = '0',
       description = 'The z component of the axis of rotation.'
       description = 'The z component of the axis of rotation.'
     },
     },
-    axis = {
-      type = 'vec3',
-      description = 'The axis of rotation (does not need to be normalized).'
-    },
     raw = {
     raw = {
       type = 'boolean',
       type = 'boolean',
       default = 'false',
       default = 'false',
@@ -71,10 +66,6 @@ return {
       arguments = { 'angle', 'ax', 'ay', 'az', 'raw' },
       arguments = { 'angle', 'ax', 'ay', 'az', 'raw' },
       returns = { 'q' }
       returns = { 'q' }
     },
     },
-    {
-      arguments = { 'angle', 'axis' },
-      returns = { 'q' }
-    },
     {
     {
       arguments = { 'r' },
       arguments = { 'r' },
       returns = { 'q' }
       returns = { 'q' }