Skip to content

Commit 9f38ca1

Browse files
committed
Ok, now everything should be properly formatted
1 parent 6404213 commit 9f38ca1

4 files changed

Lines changed: 47 additions & 10 deletions

File tree

config.ld

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ file = {
66
'datapack/data/advanced_math/modules/'
77
}
88
format = 'markdown'
9-
dir = 'docs'
9+
dir = 'docs'
10+
11+
custom_tags = {
12+
{ 'since', title='Since', format = function(text) return text end }
13+
}
14+
15+
no_return_or_parms = true

datapack/data/advanced_math/modules/pid.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ end
144144

145145
--- A PID, with a scalar, vector, or quaternion setpoint, kP, kI, and kD, both as discrete and continuous.
146146
--
147-
--
148147
-- @type PID
149148
local pid = {
150149
--- Enables/disables the clamping of the output value

datapack/data/advanced_math/rom/apis/matrix.lua

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ local matrix = {
2323
-- Supports broadcasting with row vectors and column vectors.
2424
--
2525
-- @tparam Matrix self The first matrix to add
26-
-- @tparam Matrix, number other The second matrix, scalar, or vector to add
26+
-- @tparam Matrix|number other The second matrix, scalar, or vector to add
2727
-- @treturn Matrix The resulting matrix
2828
-- @usage m1:add(m2)
2929
-- @usage m1 + m2
@@ -62,7 +62,7 @@ local matrix = {
6262
--- Subtracts two matrices, or subtracts a scalar from all elements.
6363
--
6464
-- @tparam Matrix self The matrix to subtract from
65-
-- @tparam Matrix, number other The matrix or scalar to subtract
65+
-- @tparam Matrix|number other The matrix or scalar to subtract
6666
-- @treturn Matrix The resulting matrix
6767
-- @usage m1:sub(m2)
6868
-- @usage m1 - m2
@@ -73,7 +73,7 @@ local matrix = {
7373
--- Multiplies a matrix by a scalar or performs matrix multiplication.
7474
--
7575
-- @tparam Matrix self The matrix to multiply
76-
-- @tparam Matrix, number other The scalar or matrix to multiply with
76+
-- @tparam Matrix|number other The scalar or matrix to multiply with
7777
-- @treturn Matrix The resulting matrix
7878
-- Note: For matrix multiplication, the number of columns in self must equal the number of rows in other
7979
-- @usage m:mul(3)
@@ -110,7 +110,7 @@ local matrix = {
110110
--- Divides a matrix by a scalar or another matrix.
111111
--
112112
-- @tparam Matrix self The matrix to divide
113-
-- @tparam Matrix, number other The scalar or matrix to divide by
113+
-- @tparam Matrix|number other The scalar or matrix to divide by
114114
-- @treturn Matrix The resulting matrix
115115
-- Note: Division by a matrix is performed by multiplying by its inverse
116116
-- @usage m:div(2)
@@ -595,6 +595,15 @@ local metatable = {
595595
__eq = matrix.equals
596596
}
597597

598+
--- Constructs a new matrix of rows by columns, filling it using the provided function or scalar.
599+
--
600+
-- @tparam number rows The number of rows in the matrix
601+
-- @tparam number columns The number of columns in the matrix
602+
-- @tparam function|number|nil func A function taking (row, column) to generate values, or a scalar to fill all elements
603+
-- @treturn Matrix A new matrix
604+
-- @usage m = matrix.new(3, 3, function(r, c) return r + c end)
605+
-- @usage m = matrix.new(2, 4, 5) -- fills all elements with 5
606+
-- @usage m = matrix.new(2, 2) -- fills all elements with 1
598607
function new(rows, columns, func)
599608
expect(1, rows, "number", "nil")
600609
expect(2, columns, "number", "nil")
@@ -618,6 +627,11 @@ function new(rows, columns, func)
618627
return setmetatable(m, metatable)
619628
end
620629

630+
--- Constructs a matrix from a 2D array (table of tables).
631+
--
632+
-- @tparam table arr A 2D array representing the matrix data
633+
-- @treturn Matrix A new matrix
634+
-- @usage m = matrix.from2DArray({{1, 2}, {3, 4}})
621635
function from2DArray(arr)
622636
expect(1, arr, "table")
623637
if getmetatable(arr) ~= nil then
@@ -627,6 +641,13 @@ function from2DArray(arr)
627641
return new(#arr, #arr[1], function(r, c) return arr[r][c] or 0 end)
628642
end
629643

644+
--- Constructs a matrix from a vector, as either a row or column matrix.
645+
--
646+
-- @tparam table v The vector to convert
647+
-- @tparam boolean row Whether to create a row matrix (true) or column matrix (false). Defaults to true.
648+
-- @treturn Matrix A new matrix representing the vector
649+
-- @usage m = matrix.fromVector(vector.new(1, 2, 3), true) -- row matrix
650+
-- @usage m = matrix.fromVector(vector.new(1, 2, 3), false) -- column matrix
630651
function fromVector(v, row)
631652
expect(1, v, "table")
632653
if getmetatable(v).__index ~= getmetatable(vector.new()).__index then
@@ -649,6 +670,11 @@ function fromVector(v, row)
649670
return from2DArray(m)
650671
end
651672

673+
--- Constructs a rotation matrix from a quaternion.
674+
--
675+
-- @tparam table q The quaternion to convert
676+
-- @treturn Matrix A new 3x3 rotation matrix
677+
-- @usage m = matrix.fromQuaternion(quaternion.new(1, vector.new(0, 0, 0)))
652678
function fromQuaternion(q)
653679
expect(1, q, "table")
654680
if getmetatable(q).__index ~= getmetatable(quaternion.new()).__index then
@@ -669,6 +695,12 @@ function fromQuaternion(q)
669695
return from2DArray(m)
670696
end
671697

698+
--- Constructs an identity matrix of given dimensions.
699+
--
700+
-- @tparam number rows The number of rows
701+
-- @tparam number columns The number of columns
702+
-- @treturn Matrix A new identity matrix
703+
-- @usage m = matrix.identity(3, 3)
672704
function identity(rows, columns)
673705
return new(rows, columns)
674706
end

datapack/data/advanced_math/rom/apis/quaternion.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- A basic quaternion type and some common quaternion operations. This may be useful
22
-- when working with rotation in regards to physics (such as those from the
3-
-- @{ship} API).
3+
-- Ship API provided by CC: VS).
44
--
55
-- An introduction to quaternions can be found on [Wikipedia][wiki].
66
--
@@ -65,8 +65,8 @@ local quaternion = {
6565
--- Multiplies a quaternion by a scalar value, another quaternion, or a vector.
6666
--
6767
-- @tparam Quaternion self The quaternion to multiply
68-
-- @tparam number, Quaternion, or Vector other The scalar value, quaternion, or vector to multiply with
69-
-- @treturn Quaternion or Vector The resulting quaternion or rotated vector
68+
-- @tparam number|Quaternion|Vector other The scalar value, quaternion, or vector to multiply with
69+
-- @treturn Quaternion|Vector The resulting quaternion or rotated vector
7070
-- Note: If using a quaternion value, the resuulting quaternion will be the "addition" of the two rotations
7171
-- Note: If using a vector value, will rotate the vector by the quaternion
7272
-- Note: If using a scalar value, the resulting quaternion will not be normalized
@@ -110,7 +110,7 @@ local quaternion = {
110110
--- Divides a quaternion by a scalar or another quaternion.
111111
--
112112
-- @tparam Quaternion self The quaternion to divide
113-
-- @tparam Quaternion or number other The quaternion or scalar number to divide with
113+
-- @tparam Quaternion|number other The quaternion or scalar number to divide with
114114
-- @treturn Quaternion The resulting quaternion
115115
-- Note: If using a scalar value, the resulting quaternion will not be normalized
116116
-- @usage q1:div(q2)

0 commit comments

Comments
 (0)