Using coordinate matrices and linear algebra, we can project a 3D model on screen. A linear map using rotation and scale matrices allows support for both rotation and zoom. The lines are drawn entirely using the regular canvas.Line
objects in Fyne.
matrix-display.webm
Multiple points are added together to form a coordinate matrix. We then tell Fyne to draw lines between all of the positions within the columns of the coordinate matrix. We can then simply use matrix transformations to modify the coordinate matrix and thus also the view on screen.
For rotation with the mouse, it uses two threedimensional rotation matricies, those for X and Y rotation, multiplied together to a single matrix. This allows the view to be roteted only by multiplying one coordinate matrix (instead of two times) and then telling Fyne to re-draw it.
For scaling with the scroll whell, it uses a scaling matrix to make the view larger or smaller on the screen. Again, it is as simple as multiplying the the coordinate matrix and telling Fyne to re-draw it.
This project is built using the following projects:
Linedisp is licensed under the BSD 3-Clause License
and freely avaliable to all of those that wish to use it.