emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: Image transformations

 From: Eli Zaretskii Subject: Re: Image transformations Date: Thu, 13 Jun 2019 16:05:42 +0300

```> From: Alp Aker <address@hidden>
> Date: Thu, 13 Jun 2019 05:19:52 -0400
> Cc: Alan Third <address@hidden>, Emacs devel <address@hidden>
>
> > This already goes contrary to my geometric intuition, please bear with
> > me.  The rotation is around the (0,0) origin, i.e. around the top-left
> > corner of the original image, right?  If so, the rotation should have
> > been followed by a translation along the X axis, not Y
>
> The last sentence is problematic.  When a transformation matrix describes a
> rotation followed by a translation, the translation is specified relative
> to the fixed coordinate axes.  The rotation doesn't affect the
> direction of the translation.

That's right, but this is exactly what I was trying to describe.  When
I wrote "translation along the X axis", I meant the original X axis,
which is unaffected by the rotation.  Are you saying that my
expectations are incorrect in that interpretation of "X axis"?

> >     +------------------+> X        +----------+-------------------> X
> >     |                  |           |          |
> >     |                  |           |          |
> >     |                  |           |          |
> >     |                  |   ===>    |          |
> >     +------------------+           |          |
> >     |                              |          |
> >     |                              |          |
> >     |                              |          |
> >     |                              +----------+
> >     |                                         |
> >     V                                         V
> >     Y                                         Y
> >
> > The above is just after the rotation around (0,0).  Is that correct,
> > or am I missing something?
>
> That's correct.
>
> > I also tried to approach this from the matrix notation aspect.  Is the
> > following the correct equations of computing (x',y'), the new
> > coordinates of any pixel of the image, from its original coordinates
> > (x,y)?
> >
> >   x' = m11 * x + m12 * y + tx
> >   y' = m21 * x + m22 * y + ty
> >
> > where the factors are related to the matrix as follows:
> >
> >    m = m11 | m = m12 | m = 0
> >    --------------+---------------+-------------
> >    m = m21 | m = m22 | m = 0
> >    --------------+---------------+-------------
> >    m = tx  | m = ty  | m = 1
>
> I confess I'm not sure how to interpret that matrix.  I just looked through
> image_set_rotation and found it somewhat confusing, as it seems to use
> column-major representation where I'd expect row-major.  E.g., the above
> matrix
> looks odd to me, because tx and ty would normally be in m and m
> (and
> I'd expect m == m == 0).  Similarly, the rotation matrix used in
> image_set_rotation:
>
>    = cos_r,  = -sin_r
>    = sin_r,  = cos_r
>
> would normally describe a counter-clockwise rotation by r, not a clockwise
> rotation.

Maybe that's the problem: if the rotation is counter-clockwise, then
the translation should indeed be along the Y axis.

> That said, if I correctly understand the layout of the data, the equations
> should be:
>
>    x' = m11 * x + m21 * y + tx
>    y' = m12 * x + m22 * y + ty

AFAIU, this indeed describes a counter-clockwise rotation, not a
clockwise rotation.

> > the correct coordinates should be (233,0), not (0,232).
> > What am I missing here?
>
> The transformation described by the matrix is: rotate 90 degrees
> around the origin, then translate by 232 along the y axis.  The
> first operation leaves (0, 0) unmoved, then the second operation
> moves it to (0, 232).

But if the rotation is clockwise, the result should be (233,0), right?

Thank you for helping me figure out this stuff.

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]