Skip to content

Commit 2b80047

Browse files
committed
Revamped and documented matrix API as well as added cross-conversion between quaternions and matrices\nALSO added YML and config.ld for using LDoc
1 parent d112632 commit 2b80047

8 files changed

Lines changed: 467 additions & 13 deletions

File tree

.github/workflows/docs.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Generate and Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install Lua and LuaRocks
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y lua5.3 luarocks
22+
23+
- name: Install LDoc
24+
run: sudo luarocks install ldoc
25+
26+
- name: Generate Documentation
27+
run: ldoc .
28+
29+
- name: Upload artifact
30+
uses: actions/upload-pages-artifact@v2
31+
with:
32+
path: ./docs
33+
34+
deploy:
35+
needs: build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: github-pages
39+
url: ${{ steps.deployment.outputs.page_url }}
40+
steps:
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/docs

config.ld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
project = 'Advanced Math Library'
2+
title = 'Advanced Math Documentation'
3+
description = 'Mathematical APIs for ComputerCraft'
4+
file = {
5+
'datapack/data/advanced_math/rom/apis/',
6+
'datapack/data/advanced_math/modules/'
7+
}
8+
format = 'markdown'
9+
dir = 'docs'
Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
WIP
1+
Functions in the Matrix Math API:
2+
matrix.new( rows, columns, func )
3+
matrix.from2DArray( arr )
4+
matrix.fromVector( vector, row )
5+
matrix.fromQuaternion( quaternion )
6+
matrix.identity( rows, columns )
7+
8+
Matrices returned by the above methods have the following fields and methods:
9+
matrix.rows
10+
matrix.columns
11+
matrix:add( matrix or scalar )
12+
matrix:sub( matrix or scalar )
13+
matrix:mul( matrix or scalar )
14+
matrix:div( matrix or scalar )
15+
matrix:unm()
16+
matrix:pow( n )
17+
matrix:tostring()
18+
matrix:equals( matrix )
19+
matrix:minor( row, column )
20+
matrix:determinant()
21+
matrix:transpose()
22+
matrix:cofactor()
23+
matrix:adjugate()
24+
matrix:inverse()
25+
matrix:trace()
26+
matrix:rank()
27+
matrix:frobenius_norm()
28+
matrix:max_norm()
29+
matrix:hadamard_product( matrix )
30+
matrix:elementwise_div( matrix )
31+
matrix:is_symmetric()
32+
matrix:is_diagonal()
33+
matrix:is_identity()
34+
matrix:clone()
35+
matrix:length()
36+
The +, -, *, /, ^, and # operators can also be used on matrices.
37+
38+
Note: When using a scalar value with add or mul, the operation is applied element-wise to all matrix elements.
39+
Note: Matrix division by another matrix is performed by multiplying by the inverse.
40+
Note: The pow operator requires a square matrix and a non-negative integer exponent.

datapack/data/advanced_math/help/quaternion.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ quaternion.new( vector, w )
33
quaternion.fromAxisAngle( axis, angle )
44
quaternion.fromEuler( pitch, yaw, roll )
55
quaternion.fromComponents( x, y, z, w )
6-
quaternion.fromShip()
6+
quaternion.fromMatrix()
77
quaternion.identity()
88

9+
Deprecated Functions:
10+
quaternion.fromShip()
11+
912
Quaternions returned by the above methods have the following fields and methods:
1013
quaternion.v
1114
quaternion.a

datapack/data/advanced_math/modules/pid.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
local expect = require "cc.expect"
22
local expect = expect.expect
33

4+
--- A basic PID type and common PID operations. This may be useful
5+
-- when working with control systems.
6+
--
7+
-- An introduction to PIDs can be found on [Wikipedia][wiki].
8+
--
9+
-- [wiki]: https://en.wikipedia.org/wiki/Proportional-integral-derivative_controller
10+
--
11+
-- @module pid
12+
-- @since 0.0.0
13+
414
--- Performs a PID control step if the setpoint is a scalar (number) value
515
--
616
-- @tparam pid self The PID instance
@@ -132,6 +142,10 @@ local function quaternionStep(self, value, dt)
132142
return output
133143
end
134144

145+
--- A PID, with a scalar, vector, or quaternion setpoint, kP, kI, and kD, both as discrete and continuous.
146+
--
147+
--
148+
-- @type Matrix
135149
local pid = {
136150
--- Enables/disables the clamping of the output value
137151
--

0 commit comments

Comments
 (0)