-
Notifications
You must be signed in to change notification settings - Fork 32
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
sf::Transform tutorial -- clarify transform order #135
Conversation
tutorials/2.5/graphics-transform.php
Outdated
@@ -160,7 +160,7 @@ | |||
sf::Transform t4 = t1 * t2 * t3; | |||
</code></pre> | |||
<p> | |||
You can apply several predefined transformations to the same transform as well. They will all be combined sequentially: | |||
You can apply several predefined transformations to the same transform as well. They will all be combined sequentially, in reverse order: the last operation (here <code>scale</code>) is applied first, and will be affected by operations above it in code (second would be <code>translate(-10.f, 50.f)</code>, for example). |
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.
Is it always in reverse order or just reverse order for the listed provided here?
Personally, I still don't understand why it is applied in reverse. 🤔
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.
Simple example: you start with a rectangle (black) as shown in the left graphic. The vector v
represents each vertex' position -- the transformed rectangle is a result of transforming each vertex.
- First, you rotate
v
using the rotation matrixR
. The result (blue) isR * v
, which we callw
. - Now, you apply a translation
T
tow
.
Same as before, the result (green) isT * w
, which isT * (R * v)
.
Matrix multiplication is associative; this is the same asT * R * v
. - Applying an additional scale transform
S
will yieldS * T * R * v
(red).
You see that even though the first transform was R
, it's the rightmost expression in the equation -- or the last statement in code. In other words, R
is written closest to v
, and R * v
can be understood as an intermediate vector, which is then further transformed by T
, and last S
.
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 wonder if this topic (order of transform) is something that we should elaborate in the tutorial, or if it's out of scope.
Any other feedback to the PR?
Is this blocked by the missing translation? |
Anyone wanting to translate this to French? :) Also, would it make sense to add something like this example to the doc?
|
Even if no one has the time/motivation to translate it to French, might be still worth adding it to the English docs. |
Hello, So I suggest this wording (not sure when to use the word "transformation" or "operation"):
|
@Bromeon what do you think of kimci86's suggestion? |
I think kimci86's suggestion makes sense. I wonder if we should even include the example picture that I made, to clarify the order. |
About the picture, I find it confusing because R is not only a rotation and S is not only a scale transform. R and S on the picture also include a translation. For example, if R was only a rotation, the bottom left corner of the blue rectangle would still be at the origin (0,0). |
ab8b30e
to
c9edf57
Compare
Adjusted it. |
In French, it can be:
|
c9edf57
to
afc7c94
Compare
Co-authored-by: kimci86 <kimci86@hotmail.fr>
afc7c94
to
60c3344
Compare
Integrated @kimci86's translation, credited him/her/them via |
Can we merge this? 🙂 |
Woops, forgot about this 🙂 |
Clarify order of transforms, as highlighted by pvigier in SFML/SFML#1608.
Once people agree with the wording, we can backport it to older tutorials.