From f3fe05699301040584e85a871ea15c4077a30d8b Mon Sep 17 00:00:00 2001 From: FatalErr42O <58855799+FatalError42O@users.noreply.github.com> Date: Thu, 29 Feb 2024 21:16:56 -0800 Subject: [PATCH] updated to current for 4dguns --- docs/index.html | 2 +- docs/modules/bound2.html | 2 +- docs/modules/bound3.html | 2 +- docs/modules/bvh.html | 2 +- docs/modules/color.html | 2 +- docs/modules/constants.html | 2 +- docs/modules/intersect.html | 2 +- docs/modules/mat4.html | 2 +- docs/modules/mesh.html | 2 +- docs/modules/octree.html | 2 +- docs/modules/quat.html | 33 +-------------------------------- docs/modules/simplex.html | 2 +- docs/modules/utils.html | 2 +- docs/modules/vec2.html | 2 +- docs/modules/vec3.html | 2 +- docs/topics/readme.md.html | 12 +++++++----- modules/mat4.lua | 11 +++++++++++ modules/quat.lua | 24 +++++++++++++++++++++++- 18 files changed, 56 insertions(+), 52 deletions(-) diff --git a/docs/index.html b/docs/index.html index d0eaa7e..6c89e44 100644 --- a/docs/index.html +++ b/docs/index.html @@ -130,7 +130,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/bound2.html b/docs/modules/bound2.html index ceb5fad..5912a42 100644 --- a/docs/modules/bound2.html +++ b/docs/modules/bound2.html @@ -662,7 +662,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/bound3.html b/docs/modules/bound3.html index bdcc4b4..69eb6de 100644 --- a/docs/modules/bound3.html +++ b/docs/modules/bound3.html @@ -662,7 +662,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/bvh.html b/docs/modules/bvh.html index d07e692..b4603d8 100644 --- a/docs/modules/bvh.html +++ b/docs/modules/bvh.html @@ -77,7 +77,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/color.html b/docs/modules/color.html index 34232d7..7956d20 100644 --- a/docs/modules/color.html +++ b/docs/modules/color.html @@ -730,7 +730,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/constants.html b/docs/modules/constants.html index 3594813..7c15874 100644 --- a/docs/modules/constants.html +++ b/docs/modules/constants.html @@ -118,7 +118,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/intersect.html b/docs/modules/intersect.html index c3c06f0..6d27e16 100644 --- a/docs/modules/intersect.html +++ b/docs/modules/intersect.html @@ -77,7 +77,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/mat4.html b/docs/modules/mat4.html index bc97db6..5cf2dbf 100644 --- a/docs/modules/mat4.html +++ b/docs/modules/mat4.html @@ -1166,7 +1166,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/mesh.html b/docs/modules/mesh.html index 5505e00..41a8eed 100644 --- a/docs/modules/mesh.html +++ b/docs/modules/mesh.html @@ -77,7 +77,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/octree.html b/docs/modules/octree.html index aa7cf00..543d6a5 100644 --- a/docs/modules/octree.html +++ b/docs/modules/octree.html @@ -703,7 +703,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/quat.html b/docs/modules/quat.html index 97a0603..2b576cf 100644 --- a/docs/modules/quat.html +++ b/docs/modules/quat.html @@ -201,10 +201,6 @@ to_string (a) Return a formatted string. - - to_euler (a) - Convert a quaternion to an Euler angle -

Tables

@@ -1204,33 +1200,6 @@ - -
- - to_euler (a) -
-
- Convert a quaternion to an Euler angle - - -

Parameters:

- - -

Returns:

-
    - - vec3 - euler angle in radians -
- - - -

Tables

@@ -1266,7 +1235,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/simplex.html b/docs/modules/simplex.html index e742b1f..4302094 100644 --- a/docs/modules/simplex.html +++ b/docs/modules/simplex.html @@ -77,7 +77,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/utils.html b/docs/modules/utils.html index 59b88c9..e0a0490 100644 --- a/docs/modules/utils.html +++ b/docs/modules/utils.html @@ -550,7 +550,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/vec2.html b/docs/modules/vec2.html index 8a3def9..fd88b05 100644 --- a/docs/modules/vec2.html +++ b/docs/modules/vec2.html @@ -1117,7 +1117,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/modules/vec3.html b/docs/modules/vec3.html index 61796f0..0234cc4 100644 --- a/docs/modules/vec3.html +++ b/docs/modules/vec3.html @@ -1025,7 +1025,7 @@
generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/docs/topics/readme.md.html b/docs/topics/readme.md.html index a691dc1..770a0fe 100644 --- a/docs/topics/readme.md.html +++ b/docs/topics/readme.md.html @@ -62,23 +62,25 @@

Cirno's Perfect Math Library

Adapated for Minetest

-

For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add MTUL-CPML to your trusted list (so it can require() call the FFI library) -also works if you disable mod security (DANGEROUS, NOT RECCOMENDED).

+

For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add MTUL-CPML to your trusted list (so it can require() call the FFI library).

Various useful bits of game math. 3D line intersections, ray casting, 2d/3d vectors, 4x4 matrices, quaternions, etc.

-

(originally) intended to be used with LuaJIT and LÖVE (this is the backbone of LÖVE3D).

+

This is a fork of CPML (for LÖVE/love3d), it's been ported over the minetest so it can be used in whatever you need it for. +Documentation can be found here: https://minetest-unification-library.github.io/MTUL-CPML/.

+

Documentation must be generated manually when a commit is made, because I haven't set up workflows (and have no idea how to).

TODO:

-

* Vec3s and Vec2s are not currently adapted for functionality with MT vectors (seperate classes)

+

* Vec3s and Vec2s are not currently adapted for functionality with MT vectors (seperate classes) +* Figure out how CPML (originally) automatically updated docs, and do it here.

generated by LDoc 1.5.0 -Last updated 2023-09-10 15:25:31 +Last updated 2024-01-06 19:06:14
diff --git a/modules/mat4.lua b/modules/mat4.lua index dd1b1c6..0229acd 100644 --- a/modules/mat4.lua +++ b/modules/mat4.lua @@ -651,6 +651,17 @@ function mat4.transpose(out, a) return out end +--this probably doesnt work so I'm removing it for now, work is being done. +--- Decompose into euler angles, assumes xyz are all unit vectors. +--[[function mat4.decompose_rotation(a) + local x, y, z + x = math.atan2(a[7], a[11]) + y = math.atan2(-a[3], sqrt(a[7]^2 + a[11]^2)) + z = math.atan2(a[2], a[1]) + return x, y, z +end]] + + --- Project a point into screen space -- @tparam vec3 obj Object position in world space -- @tparam mat4 mvp Projection matrix diff --git a/modules/quat.lua b/modules/quat.lua index 88c53af..f8447d2 100644 --- a/modules/quat.lua +++ b/modules/quat.lua @@ -96,7 +96,29 @@ function quat.from_angle_axis(angle, axis, a3, a4) end end ---- Create a quaternion from a normal/up vector pair. +--works in theory... probably. +--- Create a quaternion from an euler angle +-- @tparam Vec3 (or xyz table) +-- @treturn quat out +function quat.from_euler_rotation(rot) + local cr = cos(rot.z*.5) + local sr = sin(rot.z*.5) + + local cp = cos(rot.x*.5) + local sp = sin(rot.x*.5) + + local cy = cos(rot.y*.5) + local sy = sin(rot.y*.5) + return quat.new({ + w = cr * cp * cy + sr * sp * sy, + x = sr * cp * cy - cr * sp * sy, + y = cr * sp * cy + sr * cp * sy, + z = cr * cp * sy - sr * sp * cy + }) +end + + +--- Create a quaternion from a normal/up vector pair. (accepts minetest vectors) -- @tparam vec3 normal -- @tparam vec3 up (optional) -- @treturn quat out