Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]; 
    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 
axis([-8 8 -8 8]) 
grid on 
share|cite|improve this question
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. – Mariano Suárez-Alvarez Jan 25 '11 at 0:51
@Mariano Out of curiosity, what did tia sal22 mean? I've seen it a lot on matlab groups. – Please Delete Account Mar 21 '11 at 22:18
up vote 0 down vote accepted

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.

share|cite|improve this answer
thanks that helped :-) – Rick T Mar 22 '11 at 2:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.