When specifying affine transformations in the matrix format, shear matrices result in very weird transformations (see attached file).
I believe this is because transformations are stored in a decomposed form (according to the 23w06a update notes) which consists of translation - left_rotation - scale - right_rotation. I am unsure if this format can represent shears (@vdvman1 mentioned that it can), in any case, it doesn't seem to decompose correctly.
I have attached an image that illustrates the issue. The screenshot was created after summoning two block_displays:
/summon minecraft:block_display 0 0 0 {block_state:{Name:"minecraft:cobblestone"}, transformation: [1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]}
/summon minecraft:block_display 2 0 0 {block_state:{Name:"minecraft:crafting_table"}, transformation: [1.0, 0.1, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]}
The cobblestone's y axis was sheared 1 into the x direction. It looks like I just messed up the coordinates and sheared in another direction. But note that none of its sides (except z) remain parallel to the coordinate grid.
The crafting tables' y axis was sheared 0.1 into the x direction. Instead of being sheared slightly, it has flipped completely.
Attachments
Comments 8
This form definitely can represent shears/skews, here's a generic example:
[media]
Exactly why it is breaking during the decomposition, I am not sure. I am currently doing some analysis of the code to try to understand how the decomposition works to see if I can find the cause
Whelp, this maths is beyond my understanding. It seems to be using a process called single value decomposition on the upper left 3x3 submatrix, which is what extracts the left rotation, scale, and right rotation, and it extracts the translation separately from the original 4x4 matrix.
Unfortunately I don't understand how the process works, so I can't really check to see if there are any errors in the implementation. I'll leave it to Mojang to figure out why the decomposition isn't working correctly
The shearing (right_rotation) seems to only be M = UΣ, where V* is missing and has to be compensated with left_rotation.
The reason is that singular value decomposition is miscalculated.
For example, [1,1,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
The right rotation should be [0.0,0.0,0.48696187,-0.8734232],
or [0.0,0.0,-0.48696187,0.8734232],
However,in game it becomes[0.0,0.0,0.48696187,0.8734232]
Another example, [1,0,1,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
The right rotation should be [0.0,0.48696187,0.0,0.8734232],
or [0.0,-0.48696187,0.0,-0.8734232],
However,in game it becomes[0.0,-0.48696187,0.0,0.8734232]
In these two examples there's only one wrong number. The error of complex transformation is more obvious.
i made a mod to fix this bug.
and i want to upload this picture.
it is the expected behivior of the examples in the bug s description.
[^17e55495d037cf8f[1].png]
[media]