theta=0.5;
phi=0.5;
di=2;
dp=-2;
grid_ctr=[0 0]';
grid_side=5;
grid_scale=1;
grid_i=[1;0]*grid_scale;
grid_j=[0;1]*grid_scale;
obj_pts=zeros(2,grid_side*grid_side);
img_pts=obj_pts;
k=1;
for(i=1:grid_side)
    for(j=1:grid_side)
        obj_pts(:,k)=(i-grid_side/2-0.5)*grid_i+(j-grid_side/2-0.5)*grid_j+grid_ctr;
        k=k+1;
    end
end

%obj_pts=[0 0;1 0;0 1;1 1]';

or_mat=[cos(theta) -sin(theta);sin(theta) cos(theta)];
or_pts=or_mat*obj_pts;
op_mat=[cos(phi) 0;0 1;sin(phi) 0];
op_pts=op_mat*or_pts + [0;0;dp];
img_pts(1,:)=op_pts(1,:)./op_pts(3,:)*di;
img_pts(2,:)=op_pts(2,:)./op_pts(3,:)*di;
plot(img_pts(1,:),img_pts(2,:),'.')
axis equal
drawnow
hold on
%set(gca,'XLimMode','manual');
%set(gca,'YLimMode','manual');
