SFML community forums

Help => Graphics => Topic started by: person999 on July 24, 2024, 08:12:08 pm

Title: How to extract Rotation And Scale from sf::Transform
Post by: person999 on July 24, 2024, 08:12:08 pm
Context Of Question : https://stackoverflow.com/questions/78779882/updating-transformable-child-objects-in-a-class-derived-from-sftransformable?noredirect=1#comment138905586_78779882 (https://stackoverflow.com/questions/78779882/updating-transformable-child-objects-in-a-class-derived-from-sftransformable?noredirect=1#comment138905586_78779882)

So, is there any way to extract rotation and scale from sf::Transform class?
Title: Re: How to extract Rotation And Scale from sf::Transform
Post by: eXpl0it3r on July 28, 2024, 03:07:42 pm
Not exactly. sf::Transform is essentially a 4x4 transformation matrix. So all the applied operations are calculated into the matrix and thus you can't extract the original inputs.
What you can do with a transformation matrix is decompose it into it's combined components (translation, rotation and scale), see also this StackExchange answer (https://math.stackexchange.com/a/1463487/336687).

As for the StackOverflow question, I'll answer there directly.
Title: Re: How to extract Rotation And Scale from sf::Transform
Post by: person999 on August 01, 2024, 12:02:49 pm
Thanks man, it helped me alot. I was very confused with the coordinate system and this transformation matrix because I am new.