Skip to content
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 Transform.inverse() #137

Open
vtereshkov opened this issue Jan 28, 2024 · 4 comments
Open

Add Transform.inverse() #137

vtereshkov opened this issue Jan 28, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vtereshkov
Copy link
Contributor

No description provided.

@marekmaskarinec marekmaskarinec self-assigned this Jan 30, 2024
@marekmaskarinec marekmaskarinec added enhancement New feature or request good first issue Good for newcomers labels Jan 30, 2024
@skejeton
Copy link
Member

skejeton commented Feb 3, 2024

I think it's something simple like this

result := {p: {-t.p.x, -t.p.y}, s: {1/t.s.x, 1/t.s.y}, r: -t.r, o: t.o}

@vtereshkov
Copy link
Contributor Author

@skejeton Not that simple. You seem to ignore the order in which the translation, rotation and scaling are applied.

Even without rotations, the correct inverse is

result := {p: {-t.p.x / t.s.x, -t.p.y / t.s.y}, s: {1.0 / t.s.x, 1.0 / t.s.y}}

(notice that the p is also scaled).

@skejeton
Copy link
Member

skejeton commented Feb 3, 2024

I need to experiment, I thought scaling was relative to the origin, but I'm also now not sure if the origin is relative to position.

@vtereshkov
Copy link
Contributor Author

@skejeton The th.um documentation defines the following order:

scale
rotation
position

So the inverse should be

-position
-rotation
1 / scale

The origin parameter seems to be only used for rotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants