Vector calculator routines in calc.inc
Vector addition, subtraction, scaling
Dot product, length
Cross product
Matrix addition, subtraction, scaling
Matrix multiplication,
matrix applied to a vector
Matrix transposition
Solving systems
Row operations
Matrix inverses
2D and 3D rotation matrices
Determinants
[ number number number ... ]
like
[ 2 3 4 ]
Matrices are arrays of rows
[ vector vector vector ... ]
like
[
[ 1 0 0 ]
[ 0 1 0 ]
[ 0 0 1 ]
]
The instructions
In each case I have tried to show how the stack should look
before and after an operation. Occasionally I include some further
comments.
x+y
where
/vectorsub
x-y
where
/vectorscale
cx
x.y
where
/radius
/normalize
v/|v|
u x v
where
x+y
/matrixsub
x - y
/matrixscale
cx
where
transpose of x
xy
mv
where
swaps items
/rowscale
replaces row
/rowsubscale
replaces row
n x n
/tworotation
2 x 2
/threerotation
v
w l u
replaces matrix
/triangular-solve
x
where
det(a)
where
/threedet
det(a)
where
where
/threeinverse
where