Let’s see the code.

This is very redundant, but I tried to tear donw the problem,

There is 2 “for” cycle.

The first is to apply the matrix on the original data. (To test the one step method with multiplied transformation matrices.

The second “for” cycle is to “accumulate” the results.

The best what I could achieve is that if I can use the step by step method I finally reached the target. (the rotated shape is into the original position. (but this is not the target)

I getting sick because the one-step method does not work, even if I use the same matrices that are good into the STEP-BY-STEP method.

So the multiplication portion has a problem.

Any help is appreciated. I think I spent too much time on this. And I am blind on the solution. I am pretty sure to solution will be easy.

page_screen_output(0);

page_output_immediately(1);

format short;

function Init_Project

base_data =[ 10,10,10;

20,10,10;

20,20,10;

10,20,10;

10,10,10;

15,15,10];

figure(1),clf;

axis equal;

axis square;

xlabel(“x”);

ylabel(“y”);

zlabel(“z”);

axis equal;

plot3([base_data(:,1)],[base_data(:,2)],[base_data(:,3)],’:k’,‘LineWidth’,7);

transl_x = (max(base_data(:,1))+ min(base_data (:,1)))/2 ;

transl_y = (max(base_data(:,2))+ min(base_data (:,2)))/2 ;

angle_inc = pi/16;

transl_forw_Matrice = [1,0,0,-transl_x;

0,1,0,-transl_y;

0,0,1,0;

0,0,0,1];

rot_Matrice = [cos(angle_inc),-sin(angle_inc),0,0;

sin(angle_inc),cos(angle_inc),0,0;

0,0,1,0;

0,0,0,1];

transl_backw_Matrice = [1,0,0,transl_x,;

0,1,0,transl_y;

0,0,1,0;

0,0,0,1];

one_shot = [base_data(:, , ones(size(base_data(:,:))(1,1),1)];

endfunction;

Init_Project;

%comb_Matrice = transl_forw_Matrice;

comb_Matrice = rot_Matrice * transl_forw_Matrice ;

comb_Matrice = transl_forw_Matrice * rot_Matrice ;

%comb_Matrice = rot_Matrice ;

comb_Matrice = (transl_forw_Matrice * rot_Matrice) * transl_backw_Matrice ;

%comb_Matrice = transl_backw_Matrice ;

for jjk= 1:size(base_data(:,1))(1,1)

one_shot(jjk, = (comb_Matrice * [base_data(jjk,:),1]’)’;

endfor

axis equal;

hold on;

plot3([one_shot(:,1)],[one_shot(:,2)],[one_shot(:,3)],’:b’,‘LineWidth’,7);

% apply the matrice on shape

for ddf= 1:size(base_data(:,1))(1,1)

one_shot(ddf, = (comb_Matrice * [one_shot(ddf,:)]’)’;

endfor

axis equal;

hold on;

plot3([one_shot(:,1)],[one_shot(:,2)],[one_shot(:,3)],’:r’,‘LineWidth’,7);