Re: animateTransform with to-animation

>> as far as I have seen, there is no special note about
>> to-animations in any SVG-specification, but it is always
>> mentioned, that one has to look into SMIL. Because
>> transform and other attributes animatable with 
>> animateTransform are additive, simply the special
>> rules from SMIL for to-animations are applicable.
>> This means, the rule has to be applied for each
>> component of the transform matrix - this is the
>> only way I could work, I can see and as defined 
>> in SMIL. This is not difficult, but I think, up to now 
>> any viewer is wrong with this ;o)

>I think the problem, though, with using the components of the underlying
>value’s matrix is that there is no canonical way to decompose it.  In my
>example, the “matrix(2,0,0,2,10,10)” could be decomposed as
>“translate(10,10) scale(2)” or “scale(2) translate(5,5)”.  Which
>translate component would be used as the one to animate from?

No, don't even try to decompose matrix to some special other
transformations, this might cause even more problems.
Don't try to calculate something to be post-multiplied - this
will cause even more problems and nonsense (I did this on a
sheet of paper and it is only possible, if the initial or 
final matrix has an inverse, for example scale(2 0) has no
inverse).

A general way for any situation with a to-animation as the
highest priority animation is something like the following
(of course it is nowhere mentioned, to animate matrix, but 
one has to do it in cases like this, as well if there is more than
one special transformation in the transform attribute or in
general if the initial transformation type does not fit to the final):

1. Expand the value of 'to' into a matrix.
For example is scale(a d) = matrix(a 0 0 d 0 0).
Lets call the result F.
2. Determination of the underlying value from the
initial static attribute value and from underlying 
lower priority animations, I think, it is called CTM in
the specifications.
2.a Expand the value from the transform attribute 
to a matrix. 
2.b Perform any underlying animations of transform,
post-multiply it or do whatever is necessary to get it
and expand it for the time t to a matrix, lets call it
C(t).
3. Do the to-animation as specified by SMIL:

The animation function becomes something like
f(t) = C(t) + (F - C(t)) * t/d
(d is the simple duration, see SMIL for details).
f(t) is the matrix, that has to be used as the
value of transform at the time t (I think,
called the CTM(t)).

Of course, it is only necessary to do the calculation
separately for the six given components in matrix, 
but even if it is done with the complete matrix 
(including the 1 at position 3,3) this will cause no 
problem, position 3,3 will always be 1 because it is 
1 in C(t).

I never tried to get f(t) myself, but intuitively I 
guess, that there will be no ugly surprises, because 
all initial and final transformations are already 
constrained to be somehow useful.


Excursus:
This will avoid problems by trying to post-multiply 
something to get the desired behaviour.
Especially there will be no problems as might be caused
by using some nasty things like the inverse matrix
from something, not always existing, as for example 
mentioned in SVG1.2 tiny; 7.7.5 The ref() transform value
(hopefully no implementor really will try to calculate
the inverse of a matrix, because it will be my first
check, if it crashes, if the inverse does not exist, what
will happen more often as in SVG1.1, just because with 
vector-effect it will be possible to create visible 
one-dimensional structures by scaling down one
dimension to zero...). Did anyone already try 
to implement something, which requires the 
calculation of the inverse in such case? ;o) 

Received on Sunday, 9 July 2006 11:41:49 UTC