New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add affine transformation matrix #5601
base: master
Are you sure you want to change the base?
Conversation
@bhennion what do you think about that simpler version of an affine transformation? I did not include a scaling parameter for strokes, since this is bound to strokes only. I also think, that the width of a stroke should not be a parameter of the element's virtual scale function. Should I move all matrix functions into the header file? This might improve performance, but it will increase build time a bit. |
af5b835
to
a63d666
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonible to me. Of course, the question of speed an efficiency is crucial, so having a benchmark (e.g. as a disabled test unit) wouldn't hurt.
Benchmark it and if it gives a significant execution speed gain, then yes! |
Interesting, 10 times faster, using constexpr
|
There is one thing that is not so clear to me. You want every Element to store its transformation matrix, correct? Also, for rendering purposes, it matters that we can easily access the bounding box of a Stroke. If a rotation is applied, we can rotate the original bounding box and take the smallest rectangle containing it (so your Matrix::multiply(Rectangle) -> Rectangle), but this is typically way larger than the actual bounding box, thus leading to bigger areas being rerendered. The same question applies to snapping and the computation of the "snappingBounds". |
I also stumbled over that. And we should discuss this. However, for the other elements, where the inner representation does not change, it is better to use a transformation matrix (Tex, Text, Pictures, PDF). For strokes, we have the problem, that the line width is messed up, as soon the x and y scaling is distinct. Even it behaves exactly like it should from the drawing perspective. But the user might only want to transform the points, not the linewidth. Regarding snapping, I would not return a rectangle anymore: Regarding the bounds to update the drawing, I don't think that the impact is that large, the maximum factor of the resulting Rectangle is exactly 2. Always looping over hundreds of points might be worse. |
- add additional format option to .clang-format, to automatically add a newline at EOF
a133a4b
to
bbf98aa
Compare
This adds a basic affine transformation matrix similar to the cairo_matrix_t, but independent and in the xoj namespace.
ostream& operator<<
overload for Rectangles.