[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-dev] Re:Matrix math (strk)
From: |
strk |
Subject: |
Re: [Gnash-dev] Re:Matrix math (strk) |
Date: |
Thu, 4 Sep 2008 01:38:56 +0200 |
On Wed, Sep 03, 2008 at 09:40:27AM -0700, Mark Voorhies wrote:
> On Wednesday 03 September 2008 04:10:54 strk wrote:
> > On Tue, Sep 02, 2008 at 11:23:01PM -0700, Mark Voorhies wrote:
> >
> > > I think that pushing the reflection into sx gives the expected behavior
> > > as
> > > long as the sx != 0 (choosing sx rather than sy is arbitrary).
> > >
> > > For the reflection case, atan2 returns the wrong sign (the logic for
> assigning
> > > quadrants assumes only rotation), so it is still necessary to do the sign
> > > correction in get_rotation:
> > >
> > > E.g.
> > >
> > > double
> > > matrix::get_x_scale() const
> > > {
> > > if(determinant() < 0)
> > > {
> > > // Capture reflection in x-scale
> > > return -sqrt(((double)sx * sx + (double)shx * shx)) / 65536.0;
> > > }
> > > else
> > > {
> > > return sqrt(((double)sx * sx + (double)shx * shx)) / 65536.0;
> > > }
> > > }
> > >
> > > double
> > > matrix::get_y_scale() const
> > > {
> > > return sqrt(((double)sy * sy + (double)shy * shy)) / 65536.0;
> > > }
> >
> > Using sqrt here would make it impossible for Y scale to be negative.
> >
> > --strk;
> >
>
> Correct. If x_scale and y_scale are both positive then there is no
> reflection. If x_scale xor y_scale is negative then there is a reflection
> (about the y-axis or x-axis respectively). If both x_scale and y_scale are
> negative then there is no net reflection; instead, the reflections about both
> axes yield a rotation, which is redundant to the rotation component.
>
> Since the rotation and translation components _can't_ describe a reflection,
> we have to capture it as a negative value in one of the scale components. I
> arbitrarily chose x_scale, which should work in all cases except for x_scale
> = 0. (x_scale = 0 xor y_scale = 0 will give a zero determinant and collapse
> the image to a line. In this case, capturing a reflection as a 180 degree
> rotation _will_ work. If both x_scale and y_scale = 0, the image will
> collapse to a point and both reflection and rotation become moot).
Do you think you can produce an SWF testcase showing a failure in Gnash ?
See testsuite/misc-ming.all/matrix_test.c for sample code (can add to it).
The .getBounds() calls there triggers matrix transformation of the shape
bounds (a rectangle). None of those test fail. get_x_scale/get_y_scale
are NOT involved in those operations, and we're debating whether they
should in general...
--strk;