1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| function mapping4
global long lat eta xi m n alpha beta
FigHandle4 = figure(4);
set(FigHandle4, 'units','normalized','outerposition',[0 0 1 1]);
a1 = axes('unit', 'normalized', 'position', [0 0 1 1]);
alpha =45; beta = 10;
lat = 50;long = 100;
eta = 2;xi = 2;
% Points and angles (angle in radians)
m=0;n=0;
u=0;v=0;
d =sqrt((lat^2)+(long^2)-2*lat*long*cosd(180-alpha-beta));
% Sample data
for j=1:1:eta
for i=1:1:xi
xv=[m m+lat m+d*cosd(alpha) m+long*cosd(alpha+beta) m]; %:calim2: C'est ici que ce n'est pas bon
yv=[n n n+d*sind(alpha) n+long*sind(alpha+beta) n]; %:calim2: et ici
diagx=[m m+d*cosd(alpha)];
diagy=[n n+d*sind(alpha)];
m = xv(1);
n = yv(1);
% Tx matrices
first = [m n;m n;m n;m n;m n];
third = [m n;m n];
% Use homogenous coords
mp_quad(:,1) = xv';
mp_quad(:,2) = yv';
mp_diag(:,1) = diagx';
mp_diag(:,2) = diagy';
% Calculate (note because we premultiply)
rotated_quad = (mp_quad-first)'+first';
rotated_diag = (mp_diag-third)'+third';
hold on
axis equal
grid on
plot(rotated_quad(1,:), rotated_quad(2,:),'color',[0 0 0])
hold on
axis equal
grid on
grid minor
plot(rotated_diag(1,:), rotated_diag(2,:),'--','color',[0 0 0])
axis equal
grid on
grid minor
if i == 1 && j==1
aAB = (yv(2)-yv(1))/(xv(2)-xv(1));
end
if i == 1
aDE = (rotated_quad(2,3)-rotated_quad(2,4))/(rotated_quad(1,3)-rotated_quad(1,4));
u=rotated_quad(1,4);
v=rotated_quad(2,4);
end
m=rotated_quad(1,2);
n=rotated_quad(2,2);
end
m = u;
n = v;
end |
Partager