Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Added basic transformations, reversing #46
Added basic transformations, reversing #46
Changes from all commits
1764d33
a4f67e9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
And this is just a negative transform, really...
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.
It is, but also dunder methods would allow you to say:
new_line = line - (6+3j)
Which is generally easy to understand as a command as to what you'd want.
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.
Although multiplications on complex numbers are cool, they don't really translate into anything particularly useful in graphics. I don't think we need it.
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.
Multiplication does scaling. If you take that element and you multiply by 2 it scales by 2.
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.
It also moves it by two, so that's not what you want in most cases.
I think we probably should implement this by first implementing the matrix transformation, and then possibly implementing others as shortcuts.
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.
It doesn't move it by 2. It multiplies the .imag and .real by that value which is a uniform scaling operation, relative to the origin. To scaled based on a given point you'd subtract by a complex, multiply by a real, then add the original complex again.
(x + yj) * s = (sx, sy). That's a properly scaled point.
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.
Yes, and that's what is necessary. If you have a path that makes a square on point 1+1j, 1+2j, 2+2j and 2+1j and you multiply that by 2 you get the points 2+2j, 2+4j, 4+4j and 4+2j.
That's scaled AND moved, and that's not a useful graphical operation.
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.
@regebro, nope. That's scaled.
You are confusing scaled with scaled relative to a location. Whereas the operation scaled is relative to the origin. To perform a scale relative to the center you would do path
path -= 1.5 + 1.5j
path *= 2
path += 1.5 + 1.5j
That is scale and scale is by definition a very useful graphical operation. I think the confusion is in thinking scale cannot move elements. It totally can. I'm not sure how you would make all point relative to other points larger without moving the points around.
A rectangle at (1,1), (1,2), (2,2), (2,1) scaled by 2 has points (2,2), (2,4), (4,4), (4,2) that's not an argument for wrongness, that's the definition of scaled in a geometric sense. All scale operations are relative to the origin. You need to do "transform(-x,-y), scale(s), transform(x,y)" to do this relative to a point but that's really just move the origin, scale, move the origin back.
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.
If you want to wrap your head around it, consider the distance between any point and any other point in the original versus scaled version. You will find they are in every case exactly twice as far away.
M 2,2 L 2,4 L 4,4 L 4,2 Z
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.
I have wrapped my head around it. Thanks.