0
$\begingroup$

Greetings All

I have some test matlab code which can scale and do rotation but the translation (tl value) doesn't seem to be working. I expected the entire object to be moved over x=2 and y=0 but it doesn't move any ideas?

clf; clear all 
rp=[0 4 2 -1 0; 0 1 -4 -3 0;0 0 0 0 0] %x-y values 
scalenum=2 %scale factor 
tx=2;ty=0; %translate values 
% 
for theta=0:45:90 
    tl=[1 0 tx; 0 1 ty;0 0 1] %translation 
    rot=[cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0;0 0 1]; 
%rotation 
    scale=[scalenum 0 0;0 scalenum 0;0 0 1] %scale 
    rt=tl*rp %new translation 
    r=rot*rp %new rotation of points 
    rs=scale*r %new scale with rotation 
    hold off 
    plot(rt(1,:),rt(2,:)) 
axis([-8 8 -8 8]) 
grid on 
pause(.5) 
end; 
  • 4
    There is no need for the "tia sal22" in the titles of yor questions. If you browse the site bit, you will surely notice that the local custom is to avoid SMS-ish acronyms and that no one signs titles. If you format your code in a legible way, you increase the chances that someone will actually look at it---the FAQ has links which explain how to do that.2011-01-25
  • 0
    @Mariano Out of curiosity, what did tia sal22 mean? I've seen it a lot on matlab groups.2011-03-21

1 Answers 1

0

I'm highly suspicious of

rp=[0 4 2 -1 0; 0 1 -4 -3 0;0 0 0 0 0] %x-y values

If you want to do translation you don't need (x, y): you need (x, y, w), where w is the reciprocal scaling factor. So all your points are at infinity, and translating them isn't going to do much.

rp=[0 4 2 -1 0; 0 1 -4 -3 0;1 1 1 1 1] %(x,y,w) values

should get you somewhere.