Re: affine mapping (scale, rotation, translation)
- From: "Matt " <xys@xxxxxxxxxxxx>
- Date: Mon, 31 Aug 2009 18:40:23 +0000 (UTC)
"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].
.
- References:
- affine mapping (scale, rotation, translation)
- From: Bruno
- affine mapping (scale, rotation, translation)
- Prev by Date: Re: How to write all possible combinations
- Next by Date: Re: VME read through C++ and Matlab
- Previous by thread: affine mapping (scale, rotation, translation)
- Next by thread: FYI: R2007a Student Version on Snow Leopard
- Index(es):
Relevant Pages
|
Loading