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

[css-transforms-1] Error in prose describing order of multiple transform function #909

Closed
smfr opened this issue Jan 13, 2017 · 13 comments
Closed
Assignees
Labels
css-transforms-1 Current Work

Comments

@smfr
Copy link
Contributor

smfr commented Jan 13, 2017

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29110:

http://www.w3.org/TR/2013/WD-css-transforms-1-20131126/#transform-rendering
states in Example 4:

| transform: translate(80px, 80px) scale(1.5, 1.5) rotate(45deg);
| }
|
| This transform moves the element by 80 pixels in both the X and Y directions,
| then scales the element by 150%, then rotates it 45° clockwise about the Z axis.

This is technically incorrect. It should read

"This transform rotates the element 45° clockwise about the Z axis, then scales the element by 150%, then moves it by 80 pixels in both the X and Y directions."

And further:

| Note that the scale and rotation operate about the center of the element,
| since the element has the default transform-origin of 50% 50%.

This is very misleading in this context, since it implies that the translation affects the transform-origin too, which it doesn't.

Similar issue in http://www.w3.org/TR/2013/WD-css-transforms-1-20131126/#transform-function-lists :
| [...] a nested set of transforms is equivalent to a single list of transform functions,
| applied from the outside in.

I'm not sure what that even means. Would "applied from the inside out" be more appropriate?
Mathematically, we're talking about the fact that for all x, we have (f o g)(x) == f(g(x)). Now, are we applying f and g "from the inside out" or "from the outside in"? Or is there a better way to put it? I feel like there should be.

@smfr smfr changed the title Error in prose describing order of multiple transform function [css-transforms-1] Error in prose describing order of multiple transform function Jan 13, 2017
@smfr
Copy link
Contributor Author

smfr commented Jan 14, 2017

Need to also ensure that https://www.w3.org/mid/509FCC62.5080101@mit.edu is satisfied.

@samjross
Copy link

I came here to express that this issue is causing confusion. This stackoverflow question illustrates that people are seeing the documentation and getting confused about the order of operations.

@smfr
Copy link
Contributor Author

smfr commented Nov 5, 2017

I think the mental ordering you use depends on whether you're used to thinking about matrix math.

<div style="translate(80px, 80px) scale(1.5, 1.5) rotate(45deg)"></div>

gives the same result as:

   <div style="transform: translate(80px, 80px)">
        <div style="transform: scale(1.5, 1.5)">
            <div style="transform: rotate(45deg)"></div>
        </div>
    </div>

and since ancestors are painted before descendants, describing this in terms of the translate being applied first makes sense. Someone designing this in a tool would first translate, then scale, then rotate.

@smfr
Copy link
Contributor Author

smfr commented Nov 5, 2017

Maybe, as suggested in https://lists.w3.org/Archives/Public/www-style/2011May/0633.html, the spec should talk more about how transforms affect coordinate systems, rather than coordinates.

@samjross
Copy link

samjross commented Nov 5, 2017

@smfr when you reverse the order of transformations, it becomes quite clear which order the transformations happen in. Take a look at this jsfiddle You can explain the blue shape arguably forward and backward, but you cannot explain the orange shape with forward application of the rules.

@smfr
Copy link
Contributor Author

smfr commented Nov 5, 2017

How about something like this:

-This transform moves the element by 80 pixels in both the X and Y directions, then scales the element by 150%, then rotates it 45° clockwise about the Z axis. Note that the scale and rotation operate about the center of the element, since the element has the default transform-origin of ''50% 50%''.
+This transformation translates the local coordinate system by 80 pixels in both the X and Y directions, then applies a 150% scale, then a 45° clockwise rotation about the Z axis. The impact on the rendering of the element can be intepreted as an application of these transforms in reverse order: the elements is rotated, then scaled, then translated.

@smfr
Copy link
Contributor Author

smfr commented Nov 6, 2017

I'm lost in row-major vs. column-major and pre- vs post-multiply confusion here. I think, if we consider the matrices to be in column-major order (which is indicated by the order of arguments to matrix() and matrix3d() that "concatenate" means post-multiply.

I'm also confused by this figure in SVG: https://www.w3.org/TR/SVG/images/coords/MatrixMultiply.png where it talks about mapping from new to old coordinate systems with the column vector on the right.

smfr added a commit that referenced this issue Nov 6, 2017
…the example to talk about transforming coordinate systems, rather than moving the element.
@smfr
Copy link
Contributor Author

smfr commented Nov 6, 2017

Prose updated, but still needs mathy edits.

triple-underscore added a commit to triple-underscore/triple-underscore.github.io that referenced this issue Nov 6, 2017
Add a paragraph to Module Interactions to reference computation of
scrollable overflow
w3c/csswg-drafts@2096ecf0c07388008ecb31363b8a8
3d941db1127

Use UA style instead of prose to handle the exception of
transform-origin for SVG
w3c/csswg-drafts@dec1a83d199a6b0cf81539fb2bdfc
4a99e0de190

Change one occurrence of <percentage> to <length-percentage>
w3c/csswg-drafts@26444582dcaac7f1ef9f9b60044d6
9f8a76534a5

Per issue 857, change the initial value of transform-box to view-box.
w3c/csswg-drafts@861a54a2bcec16613ab7dfd03cd77
35ab8da8fd4

Attempt to address some of issue
w3c/csswg-drafts#909
by changing the example to talk about transforming coordinate systems,
rather than moving the element.
w3c/csswg-drafts@73ee670a655a34032d78b16a2ba49
e32f79dcff1

Incorrect autolinking of "transform"
w3c/csswg-drafts@ed0f4268e7cf2dee5ac896fb8f5eb
de2c690a0d6
(和訳には織り込み済み)
@dirkschulze
Copy link
Contributor

@smfr IMO for pre- post-multiply we should reference the geometry spec [1] and make sure we are consistent across the spec. Do you still think we should clarify what column-major order is? IMO it is a mathy term already. Might at least partly be related to #924.

@smfr smfr assigned smfr and dirkschulze and unassigned smfr Apr 10, 2018
@dirkschulze
Copy link
Contributor

I am adding the definition of pre-multiply, post-multiply and multiply from Geometry to CSS Transforms.

The graphics that @smfr mentions tries to explain where any point in the coordinate space of a transformed element actually would be in the elements parent coordinate space. I agree that this might not be obvious on the first view.

The same way, the nested transform section shows how any point in the coordinate space of an element can be transformed (by post-multiplying all subsequent transformations) into the coordinate space of any ancestor element.

Example 4 is example 3 now. I changed the text a little bit so that it obvious that the first sentence is explaining how the result looks like visually.

The complicated part is the part about "rendering". I think here we should do the same as SVG does and explain (maybe with formulas in a normative section) how any point in the current coordinate space can be mapped to the coordinate space of an ancestor.

The section that @smfr mentions with "inside out" should be changed to reflect what SVG says. I am going to do some edits and put it for review into the spec.

Though, post-multiplied is specified now, I need to go over the individual instances to check that the terms are used correctly. I am unsure about that currently.

dirkschulze added a commit that referenced this issue Apr 11, 2018
…iply and multiply. Clean up examples and editorial changes. #909
@dirkschulze
Copy link
Contributor

dirkschulze commented Apr 11, 2018

Ok, just did the math. The reverse transform list is exactly the wrong way. Should be:

  1. Multiply from ancestor to descendant from left to right per transform list.
  2. Multiply transform with the point.

Will do the edits tomorrow.

fergald pushed a commit to fergald/csswg-drafts that referenced this issue May 7, 2018
…iply and multiply. Clean up examples and editorial changes. w3c#909
dirkschulze added a commit that referenced this issue May 26, 2018
…g (and referencing) post-multiply/pre-multiply. #909
@dirkschulze
Copy link
Contributor

Multiplication order in general should be clarified in the spec now. Leaving the issue open for now because I am considering to pull back more math from SVG 1.1.

@dirkschulze
Copy link
Contributor

Did add clarification The Transform Rendering Model. Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-transforms-1 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants