W3C home > Mailing lists > Public > www-style@w3.org > November 2012

Re: [css3-transforms] Multiplication order

From: Rik Cabanier <cabanier@gmail.com>
Date: Sun, 11 Nov 2012 14:02:52 -0800
Message-ID: <CAGN7qDB68-Pt1KQ90YqeApuf1GRfwx7a8J1eiOQKA6q3KLxZaw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: www-style@w3.org
I think this all depends how you multiply the matrices. Graphics libraries
do a pre-concat which is the opposite of its mathematical definition and
probably the root of the confusion.

On Sun, Nov 11, 2012 at 8:03 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 11/11/12 12:56 AM, Simon Sapin wrote:
>
>> Le 11/11/2012 05:13, Rik Cabanier a écrit :
>>
>>> It's always left to right so:
>>>
>>>
>>>     accumulator = accumulator * to_matrix(function)
>>>
>>
>> Thanks for answering. For some reason I settled on the opposite in my
>> code.
>>
>
> That's because Rik is mostly wrong.  ;)
>
> This whole thing is bit of a mess and continues to be in spite of repeated
> requests to fix it up.  :(  See http://lists.w3.org/Archives/**
> Public/www-style/2011May/0633.**html<http://lists.w3.org/Archives/Public/www-style/2011May/0633.html>and
> http://lists.w3.org/Archives/**Public/www-style/2011Feb/0531.**html<http://lists.w3.org/Archives/Public/www-style/2011Feb/0531.html>for some previous issues that were raised...  Unfortunately, they were only
> partially addressed. http://dev.w3.org/csswg/css3-**
> transforms/#mathematical-**description<http://dev.w3.org/csswg/css3-transforms/#mathematical-description>now defines what matrix each transform function corresponds to, but not how
> to apply the matrix.  Note that the matrices defined in this section will
> act as expected if they are treated as matrices acting on column vectors by
> left-multiplication.
>
> Rik is thinking of this in terms of what seems to be the usual graphics
> programming convention in which matrices act on row vectors by
> right-multiplication.  So for _him_ the multiplication puts the new matrix
> to the right of the accumulator.
>
> If you're thinking of your matrices as acting on column vectors by
> left-multiplication, then your multiplication will need to put the new
> matrix to the left of the accumulator.
>

see also
http://en.wikipedia.org/wiki/Transformation_matrix#Composing_and_inverting_transformations


>
> These situations are completely equivalent (because just taking the
> transpose of everything will go between the two of them).  The main places
> where confusion can arise are the definition of the "transformation matrix"
> and the actual definition of what matrices matrix() produces.  The latter
> has been dealt with, but the former has not as you note.
>
> What I think we should do is define in section 21 that the matrices it
> defines act on the column vector [x,y,z,1] by left-multiplication.  And
> then we should clarify section 6 by either describing what the
> multiplication order for the matrices is is or by saying that the
> transformations are applied in order from left to right and that the
> "transformation matrix" is the matrix of the resulting transformation. That
> avoids the problem, since transformation application, while
> non-commutative, does not have the issue of "well, but _how_ do I apply the
> transformation".


Yes, if we write it out, it will be less confusing.


>
>
>      Similar questions arise with nested "transformed" stacking contexts
>>>
>>
> See links above.  :(
>
>
>  Is your confusion with preserver-3d or with regular 2d transforms?
>>> In the case of 2d, the outer transform happens first (= to the left)
>>>
>>
> See, this is part of the problem.  The way the spec is phrased right now,
> "first" is "to the _right_".  And the fact that not everyone is on board
> with that is not helping.  :(
>
> -Boris
>
>
Received on Sunday, 11 November 2012 22:03:20 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:02 GMT