Browse Source

Vector equals methods;

bjorn 3 years ago
parent
commit
d0d8e4e6e2

+ 24 - 0
api/lovr/math/Mat4/equals.lua

@@ -0,0 +1,24 @@
+return {
+  summary = 'Check if a matrix equals another matrix.',
+  description = 'Returns whether a matrix is approximately equal to another matrix.',
+  arguments = {
+    {
+      name = 'n',
+      type = 'Mat4',
+      description = 'The other matrix.'
+    }
+  },
+  returns = {
+    {
+      name = 'equal',
+      type = 'boolean',
+      description = 'Whether the 2 matrices approximately equal each other.'
+    }
+  },
+  related = {
+    'Vec2:equals',
+    'Vec3:equals',
+    'Vec4:equals',
+    'Quat:equals'
+  }
+}

+ 24 - 0
api/lovr/math/Quat/equals.lua

@@ -0,0 +1,24 @@
+return {
+  summary = 'Check if a quaternion equals another quaternion.',
+  description = 'Returns whether a quaternion is approximately equal to another quaternion.',
+  arguments = {
+    {
+      name = 'r',
+      type = 'Quat',
+      description = 'The other quaternion.'
+    }
+  },
+  returns = {
+    {
+      name = 'equal',
+      type = 'boolean',
+      description = 'Whether the 2 quaternions approximately equal each other.'
+    }
+  },
+  related = {
+    'Vec2:equals',
+    'Vec3:equals',
+    'Vec4:equals',
+    'Mat4:equals'
+  }
+}

+ 44 - 0
api/lovr/math/Vec2/equals.lua

@@ -0,0 +1,44 @@
+return {
+  summary = 'Check if a vector equals another vector.',
+  description = 'Returns whether a vector is approximately equal to another vector.',
+  arguments = {
+    u = {
+      type = 'Vec2',
+      description = 'The other vector.'
+    },
+    x = {
+      type = 'number',
+      description = 'The x component of the other vector.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y component of the other vector.'
+    }
+  },
+  returns = {
+    equal = {
+      type = 'boolean',
+      description = 'Whether the 2 vectors approximately equal each other.'
+    },
+  },
+  variants = {
+    {
+      arguments = { 'u' },
+      returns = { 'equal' }
+    },
+    {
+      arguments = { 'x', 'y' },
+      returns = { 'equal' }
+    }
+  },
+  notes = [[
+    To handle floating point precision issues, this function returns true as long as the squared
+    distance between the vectors is below `1e-10`.
+  ]],
+  related = {
+    'Vec3:equals',
+    'Vec4:equals',
+    'Quat:equals',
+    'Mat4:equals'
+  }
+}

+ 48 - 0
api/lovr/math/Vec3/equals.lua

@@ -0,0 +1,48 @@
+return {
+  summary = 'Check if a vector equals another vector.',
+  description = 'Returns whether a vector is approximately equal to another vector.',
+  arguments = {
+    u = {
+      type = 'Vec3',
+      description = 'The other vector.'
+    },
+    x = {
+      type = 'number',
+      description = 'The x component of the other vector.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y component of the other vector.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z component of the other vector.'
+    }
+  },
+  returns = {
+    equal = {
+      type = 'boolean',
+      description = 'Whether the 2 vectors approximately equal each other.'
+    },
+  },
+  variants = {
+    {
+      arguments = { 'u' },
+      returns = { 'equal' }
+    },
+    {
+      arguments = { 'x', 'y', 'z' },
+      returns = { 'equal' }
+    }
+  },
+  notes = [[
+    To handle floating point precision issues, this function returns true as long as the squared
+    distance between the vectors is below `1e-10`.
+  ]],
+  related = {
+    'Vec2:equals',
+    'Vec4:equals',
+    'Quat:equals',
+    'Mat4:equals'
+  }
+}

+ 52 - 0
api/lovr/math/Vec4/equals.lua

@@ -0,0 +1,52 @@
+return {
+  summary = 'Check if a vector equals another vector.',
+  description = 'Returns whether a vector is approximately equal to another vector.',
+  arguments = {
+    u = {
+      type = 'Vec4',
+      description = 'The other vector.'
+    },
+    x = {
+      type = 'number',
+      description = 'The x component of the other vector.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y component of the other vector.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z component of the other vector.'
+    },
+    w = {
+      type = 'number',
+      description = 'The w component of the other vector.'
+    }
+  },
+  returns = {
+    equal = {
+      type = 'boolean',
+      description = 'Whether the 2 vectors approximately equal each other.'
+    },
+  },
+  variants = {
+    {
+      arguments = { 'u' },
+      returns = { 'equal' }
+    },
+    {
+      arguments = { 'x', 'y', 'z', 'w' },
+      returns = { 'equal' }
+    }
+  },
+  notes = [[
+    To handle floating point precision issues, this function returns true as long as the squared
+    distance between the vectors is below `1e-10`.
+  ]],
+  related = {
+    'Vec2:equals',
+    'Vec3:equals',
+    'Quat:equals',
+    'Mat4:equals'
+  }
+}