2024-12-01 12:04:30 -08:00

1513 lines
36 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>CPML documentation</title>
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>LEEF Math</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/bound2.html">bound2</a></li>
<li><a href="../modules/bound3.html">bound3</a></li>
<li><a href="../modules/bvh.html">bvh</a></li>
<li><a href="../modules/color.html">color</a></li>
<li><a href="../modules/constants.html">constants</a></li>
<li><a href="../modules/intersect.html">intersect</a></li>
<li><strong>mat4</strong></li>
<li><a href="../modules/mesh.html">mesh</a></li>
<li><a href="../modules/octree.html">octree</a></li>
<li><a href="../modules/quat.html">quat</a></li>
<li><a href="../modules/simplex.html">simplex</a></li>
<li><a href="../modules/utils.html">utils</a></li>
<li><a href="../modules/vec2.html">vec2</a></li>
<li><a href="../modules/vec3.html">vec3</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/readme.md.html">readme</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>mat4</code></h1>
<p>double 4x4, 1-based, column major matrices</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#new">new (a)</a></td>
<td class="summary">The public constructor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#identity">identity (a)</a></td>
<td class="summary">Create an identity matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_angle_axis">from_angle_axis (angle, axis)</a></td>
<td class="summary">Create a matrix from an angle/axis pair.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_quaternion">from_quaternion (q)</a></td>
<td class="summary">Create a matrix from a quaternion.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_rot_from_quaternion">set_rot_from_quaternion (q)</a></td>
<td class="summary">set the rotation of a matrix from a quaternion.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_direction">from_direction (direction, up)</a></td>
<td class="summary">Create a matrix from a direction/up pair.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_transform">from_transform (trans, rot, scale)</a></td>
<td class="summary">Create a matrix from a transform.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_rot_zxy">set_rot_zxy (pitch, yaw, roll)</a></td>
<td class="summary">set the rotation of a given matrix in euler in the ZXY application order.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_rot_luanti_entity">set_rot_luanti_entity (pitch, yaw, roll)</a></td>
<td class="summary">alias of <code>set_rot_zxy</code>.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_rot_zxy">get_rot_zxy (the)</a></td>
<td class="summary">get the ZXY euler rotation of the given matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_rot_luanti_entity">get_rot_luanti_entity (the)</a></td>
<td class="summary">Alias of <code>get_rot_zxy</code>.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_rot_xyz">set_rot_xyz (pitch, yaw, roll)</a></td>
<td class="summary">set the rotation of a given matrix in euler in the XYZ application order.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_rot_irrlicht_bone">set_rot_irrlicht_bone (pitch, yaw, roll)</a></td>
<td class="summary">alias of <code>set_rot_xyz</code>.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_rot_xyz">get_rot_xyz (the)</a></td>
<td class="summary">Get the XYZ euler rotation of the given matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_rot_irrlicht_bone">get_rot_irrlicht_bone (the)</a></td>
<td class="summary">Alias of <code>get_rot_zxy</code>.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_ortho">from_ortho (left, right, top, bottom, near, far)</a></td>
<td class="summary">Create matrix from orthogonal.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from_perspective">from_perspective (fovy, aspect, near, far)</a></td>
<td class="summary">Create matrix from perspective.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clone">clone (a)</a></td>
<td class="summary">Clone a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#mul">mul (out, or, right)</a></td>
<td class="summary">Multiply N matrices.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#mul_vec3_perspective">mul_vec3_perspective (out, a, b)</a></td>
<td class="summary">Multiply a matrix and a vec3, with perspective division.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#mul_vec4">mul_vec4 (out, a, b)</a></td>
<td class="summary">Multiply a matrix and a vec4.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#invert">invert (out, a)</a></td>
<td class="summary">Invert a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scale">scale (out, a, s)</a></td>
<td class="summary">Scale a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#rotate">rotate (out, a, angle, axis)</a></td>
<td class="summary">Rotate a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#translate">translate (out, a, t)</a></td>
<td class="summary">Translate a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#shear">shear (out, a, yx, zx, xy, zy, xz, yz)</a></td>
<td class="summary">Shear a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#reflect">reflect (Matrix, Matrix, position, normal)</a></td>
<td class="summary">Reflect a matrix across a plane.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#look_at">look_at (out, eye, center, up)</a></td>
<td class="summary">Transform matrix to look at a point.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#target">target (out, eye, center, up)</a></td>
<td class="summary">Transform matrix to target a point.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#transpose">transpose (out, a)</a></td>
<td class="summary">Transpose a matrix.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#project">project (obj, mvp, viewport)</a></td>
<td class="summary">Project a point into screen space</td>
</tr>
<tr>
<td class="name" nowrap><a href="#unproject">unproject (win, mvp, viewport)</a></td>
<td class="summary">Unproject a point from screen space to world space.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_mat4">is_mat4 (a)</a></td>
<td class="summary">Return a boolean showing if a table is or is not a mat4.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#vec2.has_nan">vec2.has_nan (a)</a></td>
<td class="summary">Return whether any component is NaN</td>
</tr>
<tr>
<td class="name" nowrap><a href="#to_string">to_string (a)</a></td>
<td class="summary">Return a formatted string.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#to_vec4s">to_vec4s (a)</a></td>
<td class="summary">Convert a matrix to row vec4s.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#to_vec4s_cols">to_vec4s_cols (a)</a></td>
<td class="summary">Convert a matrix to col vec4s.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "new"></a>
<strong>new (a)</strong>
</dt>
<dd>
The public constructor.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
Can be of four types: </br>
table Length 16 (4x4 matrix)
table Length 9 (3x3 matrix)
table Length 4 (4 vec4s)
nil
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "identity"></a>
<strong>identity (a)</strong>
</dt>
<dd>
Create an identity matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to overwrite
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "from_angle_axis"></a>
<strong>from_angle_axis (angle, axis)</strong>
</dt>
<dd>
Create a matrix from an angle/axis pair.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">angle</span>
<span class="types"><span class="type">number</span></span>
Angle of rotation
</li>
<li><span class="parameter">axis</span>
<span class="types"><span class="type">vec3</span></span>
Axis of rotation
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "from_quaternion"></a>
<strong>from_quaternion (q)</strong>
</dt>
<dd>
Create a matrix from a quaternion.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">q</span>
<span class="types"><span class="type">quat</span></span>
Rotation quaternion
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "set_rot_from_quaternion"></a>
<strong>set_rot_from_quaternion (q)</strong>
</dt>
<dd>
set the rotation of a matrix from a quaternion. Not sure at all where i got this code from, but it works...
i refactored so it works with https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.html
I think I got it from https://github.com/minetest/irrlicht/blob/7173c2c62997b6416f17b90f9a50bff11fef1c4c/include/quaternion.h#L367
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">q</span>
<span class="types"><span class="type">quat</span></span>
rotation quaternion. only supports normal quaternion rotation (will normalize)
</li>
</ul>
</dd>
<dt>
<a name = "from_direction"></a>
<strong>from_direction (direction, up)</strong>
</dt>
<dd>
Create a matrix from a direction/up pair.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">direction</span>
<span class="types"><span class="type">vec3</span></span>
Vector direction
</li>
<li><span class="parameter">up</span>
<span class="types"><span class="type">vec3</span></span>
Up direction
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "from_transform"></a>
<strong>from_transform (trans, rot, scale)</strong>
</dt>
<dd>
Create a matrix from a transform.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">trans</span>
<span class="types"><span class="type">vec3</span></span>
Translation vector
</li>
<li><span class="parameter">rot</span>
<span class="types"><span class="type">quat</span></span>
Rotation quaternion
</li>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vec3</span></span>
Scale vector
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "set_rot_zxy"></a>
<strong>set_rot_zxy (pitch, yaw, roll)</strong>
</dt>
<dd>
set the rotation of a given matrix in euler in the ZXY application order. This is the order that minetest entities are rotated in.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pitch</span>
<span class="types"><span class="type">float</span></span>
the clockwise pitch in radians
</li>
<li><span class="parameter">yaw</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in radians
</li>
<li><span class="parameter">roll</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in roll
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">matrix</span></span>
</ol>
</dd>
<dt>
<a name = "set_rot_luanti_entity"></a>
<strong>set_rot_luanti_entity (pitch, yaw, roll)</strong>
</dt>
<dd>
alias of <code>set_rot_zxy</code>. Sets the rotation of a given matrix in euler in the ZXY application order. This is the order that minetest entities are rotated in.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pitch</span>
<span class="types"><span class="type">float</span></span>
the clockwise pitch in radians
</li>
<li><span class="parameter">yaw</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in radians
</li>
<li><span class="parameter">roll</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in roll
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">matrix</span></span>
</ol>
</dd>
<dt>
<a name = "get_rot_zxy"></a>
<strong>get_rot_zxy (the)</strong>
</dt>
<dd>
get the ZXY euler rotation of the given matrix. This is the order that minetest entities are rotated in.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">the</span>
<span class="types"><span class="type">matrix</span></span>
matrix to get the rotation of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">float</span></span>
pitch</li>
<li>
<span class="types"><span class="type">float</span></span>
yaw</li>
<li>
<span class="types"><span class="type">float</span></span>
roll</li>
</ol>
</dd>
<dt>
<a name = "get_rot_luanti_entity"></a>
<strong>get_rot_luanti_entity (the)</strong>
</dt>
<dd>
Alias of <code>get_rot_zxy</code>. Gets the ZXY euler rotation of the given matrix. This is the order that minetest entities are rotated in.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">the</span>
<span class="types"><span class="type">matrix</span></span>
matrix to get the rotation of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">float</span></span>
pitch</li>
<li>
<span class="types"><span class="type">float</span></span>
yaw</li>
<li>
<span class="types"><span class="type">float</span></span>
roll</li>
</ol>
</dd>
<dt>
<a name = "set_rot_xyz"></a>
<strong>set_rot_xyz (pitch, yaw, roll)</strong>
</dt>
<dd>
set the rotation of a given matrix in euler in the XYZ application order. This is the rotation order irrlicht uses (i.e. for bones in Luanti)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pitch</span>
<span class="types"><span class="type">float</span></span>
the clockwise pitch in radians
</li>
<li><span class="parameter">yaw</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in radians
</li>
<li><span class="parameter">roll</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in roll
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">matrix</span></span>
</ol>
</dd>
<dt>
<a name = "set_rot_irrlicht_bone"></a>
<strong>set_rot_irrlicht_bone (pitch, yaw, roll)</strong>
</dt>
<dd>
alias of <code>set_rot_xyz</code>. Sets the rotation of a given matrix in euler in the XYZ application order. This is the rotation order irrlicht uses (i.e. for bones in Luanti)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pitch</span>
<span class="types"><span class="type">float</span></span>
the clockwise pitch in radians
</li>
<li><span class="parameter">yaw</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in radians
</li>
<li><span class="parameter">roll</span>
<span class="types"><span class="type">float</span></span>
the clockwise yaw in roll
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">matrix</span></span>
</ol>
</dd>
<dt>
<a name = "get_rot_xyz"></a>
<strong>get_rot_xyz (the)</strong>
</dt>
<dd>
Get the XYZ euler rotation of the given matrix. This is the rotation order irrlicht uses (i.e. for bones in Luanti)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">the</span>
<span class="types"><span class="type">matrix</span></span>
matrix to get the rotation of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">float</span></span>
pitch</li>
<li>
<span class="types"><span class="type">float</span></span>
yaw</li>
<li>
<span class="types"><span class="type">float</span></span>
roll</li>
</ol>
</dd>
<dt>
<a name = "get_rot_irrlicht_bone"></a>
<strong>get_rot_irrlicht_bone (the)</strong>
</dt>
<dd>
Alias of <code>get_rot_zxy</code>. Gets the XYZ euler rotation of the given matrix. This is the rotation order irrlicht uses (i.e. for bones in Luanti).
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">the</span>
<span class="types"><span class="type">matrix</span></span>
matrix to get the rotation of
</li>
</ul>
<h3>Returns:</h3>
<ol>
<li>
<span class="types"><span class="type">float</span></span>
pitch</li>
<li>
<span class="types"><span class="type">float</span></span>
yaw</li>
<li>
<span class="types"><span class="type">float</span></span>
roll</li>
</ol>
</dd>
<dt>
<a name = "from_ortho"></a>
<strong>from_ortho (left, right, top, bottom, near, far)</strong>
</dt>
<dd>
Create matrix from orthogonal.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">left</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">right</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">top</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">bottom</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">near</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">far</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "from_perspective"></a>
<strong>from_perspective (fovy, aspect, near, far)</strong>
</dt>
<dd>
Create matrix from perspective.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">fovy</span>
<span class="types"><span class="type">number</span></span>
Field of view
</li>
<li><span class="parameter">aspect</span>
<span class="types"><span class="type">number</span></span>
Aspect ratio
</li>
<li><span class="parameter">near</span>
<span class="types"><span class="type">number</span></span>
Near plane
</li>
<li><span class="parameter">far</span>
<span class="types"><span class="type">number</span></span>
Far plane
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "clone"></a>
<strong>clone (a)</strong>
</dt>
<dd>
Clone a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to clone
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "mul"></a>
<strong>mul (out, or, right)</strong>
</dt>
<dd>
Multiply N matrices.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">or</span>
<span class="types"><span class="type">mat4</span></span>
{mat4, ...} left hand operand(s)
</li>
<li><span class="parameter">right</span>
<span class="types"><span class="type">mat4</span></span>
hand operand if a is not table
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out multiplied matrix result
</ol>
</dd>
<dt>
<a name = "mul_vec3_perspective"></a>
<strong>mul_vec3_perspective (out, a, b)</strong>
</dt>
<dd>
Multiply a matrix and a vec3, with perspective division.
This function uses an implicit 1 for the fourth component.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">vec3</span></span>
vec3 to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Left hand operand
</li>
<li><span class="parameter">b</span>
<span class="types"><span class="type">vec3</span></span>
Right hand operand
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vec3</span></span>
out
</ol>
</dd>
<dt>
<a name = "mul_vec4"></a>
<strong>mul_vec4 (out, a, b)</strong>
</dt>
<dd>
Multiply a matrix and a vec4.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
table to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Left hand operand
</li>
<li><span class="parameter">b</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Right hand operand
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vec4</span></span>
out
</ol>
</dd>
<dt>
<a name = "invert"></a>
<strong>invert (out, a)</strong>
</dt>
<dd>
Invert a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to invert
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "scale"></a>
<strong>scale (out, a, s)</strong>
</dt>
<dd>
Scale a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to scale
</li>
<li><span class="parameter">s</span>
<span class="types"><span class="type">vec3</span></span>
Scalar
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "rotate"></a>
<strong>rotate (out, a, angle, axis)</strong>
</dt>
<dd>
Rotate a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to rotate
</li>
<li><span class="parameter">angle</span>
<span class="types"><span class="type">number</span></span>
Angle to rotate by (in radians)
</li>
<li><span class="parameter">axis</span>
<span class="types"><span class="type">vec3</span></span>
Axis to rotate on
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "translate"></a>
<strong>translate (out, a, t)</strong>
</dt>
<dd>
Translate a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to translate
</li>
<li><span class="parameter">t</span>
<span class="types"><span class="type">vec3</span></span>
Translation vector
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "shear"></a>
<strong>shear (out, a, yx, zx, xy, zy, xz, yz)</strong>
</dt>
<dd>
Shear a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to translate
</li>
<li><span class="parameter">yx</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">zx</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">xy</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">zy</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">xz</span>
<span class="types"><span class="type">number</span></span>
</li>
<li><span class="parameter">yz</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "reflect"></a>
<strong>reflect (Matrix, Matrix, position, normal)</strong>
</dt>
<dd>
Reflect a matrix across a plane.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">Matrix</span>
<span class="types"><span class="type">a</span></span>
to reflect
</li>
<li><span class="parameter">Matrix</span>
<span class="types"><span class="type">a</span></span>
to reflect
</li>
<li><span class="parameter">position</span>
<span class="types"><span class="type">vec3</span></span>
A point on the plane
</li>
<li><span class="parameter">normal</span>
<span class="types"><span class="type">vec3</span></span>
The (normalized!) normal vector of the plane
</li>
</ul>
</dd>
<dt>
<a name = "look_at"></a>
<strong>look_at (out, eye, center, up)</strong>
</dt>
<dd>
Transform matrix to look at a point.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store result
</li>
<li><span class="parameter">eye</span>
<span class="types"><span class="type">vec3</span></span>
Location of viewer's view plane
</li>
<li><span class="parameter">center</span>
<span class="types"><span class="type">vec3</span></span>
Location of object to view
</li>
<li><span class="parameter">up</span>
<span class="types"><span class="type">vec3</span></span>
Up direction
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "target"></a>
<strong>target (out, eye, center, up)</strong>
</dt>
<dd>
Transform matrix to target a point.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store result
</li>
<li><span class="parameter">eye</span>
<span class="types"><span class="type">vec3</span></span>
Location of viewer's view plane
</li>
<li><span class="parameter">center</span>
<span class="types"><span class="type">vec3</span></span>
Location of object to view
</li>
<li><span class="parameter">up</span>
<span class="types"><span class="type">vec3</span></span>
Up direction
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "transpose"></a>
<strong>transpose (out, a)</strong>
</dt>
<dd>
Transpose a matrix.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">out</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to store the result
</li>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to transpose
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">mat4</span></span>
out
</ol>
</dd>
<dt>
<a name = "project"></a>
<strong>project (obj, mvp, viewport)</strong>
</dt>
<dd>
Project a point into screen space
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">obj</span>
<span class="types"><span class="type">vec3</span></span>
Object position in world space
</li>
<li><span class="parameter">mvp</span>
<span class="types"><span class="type">mat4</span></span>
Projection matrix
</li>
<li><span class="parameter">viewport</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
XYWH of viewport
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vec3</span></span>
win
</ol>
</dd>
<dt>
<a name = "unproject"></a>
<strong>unproject (win, mvp, viewport)</strong>
</dt>
<dd>
Unproject a point from screen space to world space.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">win</span>
<span class="types"><span class="type">vec3</span></span>
Object position in screen space
</li>
<li><span class="parameter">mvp</span>
<span class="types"><span class="type">mat4</span></span>
Projection matrix
</li>
<li><span class="parameter">viewport</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
XYWH of viewport
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vec3</span></span>
obj
</ol>
</dd>
<dt>
<a name = "is_mat4"></a>
<strong>is_mat4 (a)</strong>
</dt>
<dd>
Return a boolean showing if a table is or is not a mat4.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to be tested
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
is_mat4
</ol>
</dd>
<dt>
<a name = "vec2.has_nan"></a>
<strong>vec2.has_nan (a)</strong>
</dt>
<dd>
Return whether any component is NaN
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to be tested
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">boolean</span></span>
if any component is NaN
</ol>
</dd>
<dt>
<a name = "to_string"></a>
<strong>to_string (a)</strong>
</dt>
<dd>
Return a formatted string.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to be turned into a string
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
formatted
</ol>
</dd>
<dt>
<a name = "to_vec4s"></a>
<strong>to_vec4s (a)</strong>
</dt>
<dd>
Convert a matrix to row vec4s.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to be converted
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
vec4s
</ol>
</dd>
<dt>
<a name = "to_vec4s_cols"></a>
<strong>to_vec4s_cols (a)</strong>
</dt>
<dd>
Convert a matrix to col vec4s.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">a</span>
<span class="types"><span class="type">mat4</span></span>
Matrix to be converted
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
vec4s
</ol>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>