`matrix/Interpolate()` not implemented
http://www.byond.com/docs/ref/#/matrix/proc/Interpolate
Ran a quick test to try to figure out how the matrices interpolate in Byond, so here is one example.
With following matrices:
A = 0, 1, 2 ,3 ,4, 5
matrix(
[0,3,0],
[1,4,0],
[2,5,1]
)
B = 6, 5, 4, 3, 2, 1
matrix(
[6,3,0],
[5,2,0],
[4,1,1]
)
With varying ts as seen to left
MATRIX: 0.00 -> [0, 1, 2, 3, 4, 5,]
MATRIX: 0.20 -> [0.995492, 1.39835, 2.4, 2.23765, 3.08132, 4.2,]
MATRIX: 0.25 -> [1.27667, 1.54055, 2.5, 2.10113, 2.88275, 4,]
MATRIX: 0.40 -> [2.17789, 2.05677, 2.8, 1.83138, 2.37584, 3.4,]
MATRIX: 0.50 -> [2.81365, 2.46671, 3, 1.77282, 2.11976, 3,]
MATRIX: 0.60 -> [3.46478, 2.92031, 3.2, 1.81452, 1.93564, 2.6,]
MATRIX: 0.75 -> [4.44599, 3.66437, 3.5, 2.06829, 1.80442, 2,]
MATRIX: 0.80 -> [4.76866, 3.925, 3.6, 2.20407, 1.80121, 1.8,]
MATRIX: 1.00 -> [6, 5, 4, 3, 2, 1,]
Another trial
A =
matrix(
[1,1,0],
[2,2,0],
[3,3,1]
)
B =
matrix(
[3,3,0],
[2,2,0],
[1,1,1]
)
MATRIX: 0.00 -> [1, 2, 3, 1, 2, 3,]
MATRIX: 0.20 -> [1.4, 2, 2.6, 1.4, 2, 2.6,]
MATRIX: 0.25 -> [1.5, 2, 2.5, 1.5, 2, 2.5,]
MATRIX: 0.40 -> [1.8, 2, 2.2, 1.8, 2, 2.2,]
MATRIX: 0.50 -> [2, 2, 2, 2, 2, 2,]
MATRIX: 0.60 -> [2.2, 2, 1.8, 2.2, 2, 1.8,]
MATRIX: 0.75 -> [2.5, 2, 1.5, 2.5, 2, 1.5,]
MATRIX: 0.80 -> [2.6, 2, 1.4, 2.6, 2, 1.4,]
MATRIX: 1.00 -> [3, 2, 1, 3, 2, 1,]
More findings that I could find:
- It does SSRT (Scale/Shear, Rotation and Translate) interpolation depending on that rotation found in every matrix. Takes any or both of A and B to be invertible to do this method.
- If both A and B are non-invertible matrices, then straight linear interpolation (e.g.
A + (B-A)*torA*t + B*(1-t)) is done
Although those are not entirely empirical findings and supported by the little evidence I had. Overall this is a very odd function and is rarely used by any SS13 codebase except for tgstation with one sole use.
Trying my hand at this and I can't understand what you mean by SSRT.
Do you mean that you decompose the matrix M into
M = S*R*T
With S being a Scale/Shear matrix, R being a rotation, and T being a translation ? And you smoothly interpolate each of the component operations, right ?
The SSRT is coined from a discussion we had in the OpenDream discussion, it comes from the specification given by the Byond DM documentation. In words:
There are many ways to interpolate matrices. Whenever possible, DM will interpolate by doing scaling and/or shearing first, then rotation, then translation. This is done by trying to find the angle of rotation of each matrix first; a rotation of 180° is counted as a flip rather than a rotation.
We had this discussion in the Discord trying to dechiper from the description and tests how it exactly works. And we are not even sure either.