Re: affine mapping (scale, rotation, translation)



"Bruno " <bruno.marchesi@xxxxxxxxx> wrote in message <h7h4m7$e5$1@xxxxxxxxxxxxxxxxxx>...
Hello,

given 4 vertices of a rectangle, and an inside point p1(x,y),
how to translate the shape to the reference point p2(x,y)?
There may be a scaling given by 's' and a rotation given by 'r', in radians.

After some time, I solved this by:
calculating the 4 diagonals involving p1 and the vertices (modulus, angle)
applying the scale and rotation
translating them to rectangular coordinates
drawing the new shape around p2

I'm sure there are more straightforward ways to do this. Could I use maketform( )
and tformarray( )? Remember that it's not an image, but a set of points. And what
about 'affine mapping', how could I use this kind of arrays:

scale = 1.2; % scale factor
angle = 40*pi/180; % rotation angle
tx = 0; % x translation
ty = 0; % y translation

sc = scale*cos(angle);
ss = scale*sin(angle);

T = [ sc -ss;
ss sc;
tx ty];

Looks fine. To transform a point (x,y), just premultiply T by [x,y,1].

.



Relevant Pages

  • Re: Locating An Image At Arbitrary Scales, Translations, and Rotations
    ... at an arbitrary scale, translation, and rotation. ... If your object really is just a rectangle, it's easy enough to find its ...
    (sci.image.processing)
  • Re: possible to convert a 3x3 to a 4x4?
    ... Well, a 3x3 matrix transformation of a vector can change the rotation, ... and skew of a vector. ... This will not be as easy if you want to translate first; ... that hard to scale up as the algorithm is recursive. ...
    (comp.graphics.api.opengl)
  • Re: affine mapping (scale, rotation, translation)
    ... how to translate the shape to the reference point p2? ... applying the scale and rotation ... translating them to rectangular coordinates ... If there are 4 rectangle corners, it is expected that some coordinates increase, while ...
    (comp.soft-sys.matlab)
  • affine mapping (scale, rotation, translation)
    ... how to translate the shape to the reference point p2? ... applying the scale and rotation ... By the way, I was going crazy drawing a rectangle using line, because the points ...
    (comp.soft-sys.matlab)
  • Re: Cant get zooming into a selected area to work correctly.
    ... The idea being that the mouse is dragged over an area and the area within the selection rectangle is scaled and then centred to fit in the scrollpane. ... The point passed to that method specifies what point of the contained view will be in the upper-left corner of the viewport, ... It's not just some random method that's used to set the scale for the view. ... private BufferedImage _image; ...
    (comp.lang.java.programmer)

Loading