51 Commits

Author SHA1 Message Date
FatalErr42O
f3fe056993 updated to current for 4dguns 2024-02-29 21:16:56 -08:00
FatalErr42O
9eddd7041d update 2023-11-21 21:29:05 -08:00
FatalErr42O
90dea05875 staging commits 2023-09-10 15:27:15 -07:00
FatalErr42O
843a573334
Merge pull request #1 from mcclure/euler-quat (add to_euler)
quat.to_euler_angles and quat.to_euler_angles_unpack
2023-09-09 11:52:16 -07:00
FatalErr42O
7ad207b4a9 added support for FFI library using trusted mods config 2023-09-08 19:11:08 -07:00
FatalErr42O
4f3bb3ea5e now runs (with some require hax) 2023-08-29 16:01:42 -07:00
Colby Klein
d83b4c71ce fix doc typo 2022-04-21 12:10:28 -07:00
David Briscoe
c26cc1a508 Include offending type in precondition failure msg
Output the type that was incorrect to make it more obvious what the user
is doing wrong without them adding logging.

To avoid string building during lots of vector math, introduced a
private precond module that only builds the strings when an error
occurs. It uses error() to put the resulting error message at the caller
to cpml.

Before:

  lua: ~/cpml/modules/vec2.lua:52: new: Wrong argument type for x (<number> expected)
  lua: ~/cpml/modules/vec2.lua:424: __add: Wrong argument type for right hand operand. (<cpml.vec2> expected)

  example stack traceback:
  	[C]: in function 'assert'
  	~/cpml/modules/vec2.lua:424: in metamethod '__add'
  	test_cpml.lua:32: in main chunk
  	[C]: in ?

After:

  lua: test_cpml.lua:31: new: Wrong argument type for x: string (<number> expected)
  lua: test_cpml.lua:32: __add: Wrong argument type 'string' for right hand operand. (<cpml.vec2> expected)

  example stack traceback:
  	[C]: in function 'error'
  	~/cpml/modules/_private_precond.lua:13: in function 'modules._private_precond.assert'
  	~/cpml/modules/vec2.lua:425: in metamethod '__add'
  	test_cpml.lua:32: in main chunk
  	[C]: in ?

The tracebacks are longer, but the initial error is at the location of
the mistake and the output includes the input type.
2022-03-27 09:56:15 -07:00
David Briscoe
29954aa60e vec: Add nan checking functions
Add:
* vec2.has_nan + test
* vec3.has_nan + test
* quat.has_nan
* mat4.has_nan
* utils.is_nan + test
2022-03-26 23:33:13 -07:00
mcc
ae4601fc52 quat.to_euler_angles and quat.to_euler_angles_unpack 2020-05-04 00:40:38 -04:00
mcc
9cd858a0ef Add tests to identity-quat patch and also take an axis not a full value for the identity fallback 2020-04-25 18:32:48 -04:00
mcc
f27f5520b1 Fix for issue #55 (quat():to_angle_axis() returns gibberish) 2020-04-25 18:06:09 -04:00
mcclure
86f0056397
Merge pull request #47 from mcclure/master-test-failures
Fix failing tests
2019-11-30 17:37:03 -05:00
mcc
a86935a39b Allow ffi.metatype to fail so that "busted" unit tests work
On Github we run unit tests inside "busted". At the start of each test "busted" does some sort of trick (clearing package.loaded)? Which causes "require" to run again for all lua files. This breaks ffi.metatype with error "cannot change a protected metatable" if it is called twice with a single type name, since this is true global state. To work around this this patch wraps ffi.metatype calls in a xpcall() so that failure is silently ignored.
2019-11-29 21:13:30 -05:00
mcc
7ac8b80f3f Remove DO_THRESHOLD check from quat.pow; this was an accidental, inappropriate copypaste from lerp(). 2019-11-29 11:23:27 -05:00
Colby Klein
ef46425cfe
Merge pull request #29 from mcclure/quat-component
Quaternions: Add "unpacked" versions of to_angle_axis and from_angle
2018-02-22 04:07:06 -08:00
mcc
5637034445 Clarify handedness of quaternion multiplication 2018-01-26 10:47:22 -05:00
mcc
d4fb346f0c Quaternions: Add "unpacked" versions of to_angle_axis and from_angle_axis (passing x, y and z in and out instead of using a vec3) 2018-01-26 09:33:25 -05:00
Colby Klein
b122e4d726 fix typo 2017-03-29 05:32:16 -07:00
Pedro Gimeno Fortea
d9108a198a Make pow work with non-integer exponents.
As a side effect, it no longer works with non-normalized quaternions.
2016-12-16 00:32:52 -08:00
karai17
08b23e394b Updated tests, fixed couple bugs 2016-12-15 19:57:31 -04:00
karai17
b3be2a154a unfactor quat 2016-12-14 20:22:22 -04:00
Colby Klein
7e46afa280 make quat.from_direction's up argument optional (defaults to +z) 2016-12-13 15:12:17 -08:00
karai17
69f30173b8 Fixed quat.lerp 2016-08-14 15:39:24 -03:00
karai17
799e1607bc Updated to work outside of a sanitized environment. 2016-08-14 03:36:36 -03:00
karai17
ebae3a1fce Updated mat4 LDocs 2016-07-24 22:16:04 -03:00
karai17
52eb8af61d More LDoc tidying 2016-07-24 20:57:59 -03:00
karai17
5f7a7f29fa Added quaternion tests
* Fixed an issue with is_quat, is_vec3, is_vec2, and is_mat4 methods
* Fixed a minor issue with local variables being declared too late
2016-07-21 20:04:32 -03:00
karai17
2950352ac8 Updated color module, etc. 2016-07-20 22:17:25 -03:00
karai17
2aa0e7fcb6 Cleaned up internal code to be less verbose 2016-07-20 18:24:54 -03:00
karai17
4f9bc17bf4 Refactored mat4
Did some tidying up on quat, vec2, vec3, and utils
2016-07-19 23:55:21 -03:00
karai17
46f8261ea0 Refactored mat4 (in progress)
Cleaned up vec2, vec3, quat
2016-07-18 06:17:42 -03:00
Landon Manning
5da09ddd8b removed ray_triangle2, it was too slow
also moved some vec3 definitions outside their respective function
bodies to speed thing sup and create less garbage
2015-12-29 04:58:53 -04:00
Landon Manning
2347bd9706 Looks like we don't need quat.div after all. 2015-12-28 12:40:52 -04:00
Matthew Blanchard
f4163b9893 Pruned mat4. Added quat.mul_vec3. 2015-12-28 11:11:45 -05:00
Landon Manning
437ac9135e Reimplemented quat*vec3, quat/quat, and quat/number
Fixed a few minor things in vec2 and vec3
2015-12-28 10:15:05 -04:00
Matthew Blanchard
85655e65af Refactored quat and added doc comments. Fixed some small typos and doc comments in vec2. 2015-12-25 20:06:31 -05:00
Landon Manning
71af8f5498 Rewrote quaternion module
Untested, but I hope it works!
2015-12-22 05:27:22 -04:00
Landon Manning
c72efbad3c buncha goodies
* Changed add/sub in vec2/vec3 to allow for integer math
* Fixed a string display error in quat
* Other stuff that @shakesoda probably did
2015-12-13 06:16:57 -04:00
Colby Klein
951aea865f Proper fix for the quat.to_axis_angle bug.
Apparently, I was getting a number so close to -1 (but just under) that
it just printed as -1. Fuck off.
2015-09-14 13:35:01 -07:00
Colby Klein
18dd29d1b5 Work around math.acos(-1) returning NaN on LuaJIT... sometimes. 2015-09-14 13:26:05 -07:00
Colby Klein
78989682cf Add LDoc documentation. Utils done. 2015-09-11 07:59:05 -07:00
Colby Klein
88e8ebc3de Add quaternion.unpack. Now vec2/3/quat all have it. 2015-07-25 19:31:14 -07:00
Colby Klein
7cdca018aa Add quat.cross, fix quat.rotate, cleanup. 2015-07-10 12:25:39 -07:00
Colby Klein
2b3f8bc31b Add quat:clone() 2015-05-05 02:03:02 -07:00
Landon Manning
3b53764662 I thought I updated this... 2015-04-18 06:01:24 -03:00
Landon Manning
a1723f5028 More consistency! 2015-01-16 04:14:40 -05:00
Landon Manning
d2d3c6c12f Fixed some stuff 2014-12-08 05:42:21 -04:00
Landon Manning
c2d8e814a7 Added linear interpolation to quaternion module
* lerp
* nlerp
* slerp
2014-12-07 01:08:15 -04:00
Colby Klein
2b41e8debb Fix quaternion (THIS IS WHY WE NEED TESTS). Also gave vec3 a table constructor. 2014-11-11 03:46:25 -08:00