In TI-BASIC, matrices are essentially two-dimensional lists with limitations. There are only a few math commands that work on matrices: =, ≠, the dedicated matrix commands, and these:
Additionally, scalar multiplication works on matrices.
These select commands are actually very useful: recall that, for example, the following code
Code:
gets the 7th digit from the right of a scalar A. Applying this to an entire matrix:
Code:
gives the 7th digit of every element of [A]. Therefore, since floats can be stored to a precision of 14 digits, and matrices can be 20x20, it is possible to create a sort of 20x20x14 array of digits, from which each z-slice can be extracted easily. This can be applied, for example, to a game with a small 3d map for which there can be up to 10 tile types (maybe a maze).
It's possible to reduce the number of tile types while increasing the size of the matrix in the z-direction, by using a different base's digits. For example, in base 2, a float can store 44 bits, allowing an enormous 20x20x44 maze. However, multiplication is slower when not by powers of ten, so this comes at the expense of speed.
Using matrix multiplication, it's also possible to take x-slices and y-slices of the 3d array, and even rotate and flip the matrix.
tibasicdev wrote:
abs( and angle( (but no other complex number commands) [...]
fPart(, iPart(, int(, and round(
\
fPart(, iPart(, int(, and round(
Additionally, scalar multiplication works on matrices.
These select commands are actually very useful: recall that, for example, the following code
Code:
int(10fPart(A|E~7
gets the 7th digit from the right of a scalar A. Applying this to an entire matrix:
Code:
int(10fPart([A]|E~7
gives the 7th digit of every element of [A]. Therefore, since floats can be stored to a precision of 14 digits, and matrices can be 20x20, it is possible to create a sort of 20x20x14 array of digits, from which each z-slice can be extracted easily. This can be applied, for example, to a game with a small 3d map for which there can be up to 10 tile types (maybe a maze).
It's possible to reduce the number of tile types while increasing the size of the matrix in the z-direction, by using a different base's digits. For example, in base 2, a float can store 44 bits, allowing an enormous 20x20x44 maze. However, multiplication is slower when not by powers of ten, so this comes at the expense of speed.
Using matrix multiplication, it's also possible to take x-slices and y-slices of the 3d array, and even rotate and flip the matrix.