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
| % We want to create an acquisition
% We request for BCD
% We know A(x,y)
% a and b side
% alpha is random number
%
%
k=input('Write the number of satellites you wish : ');
sat=[];
for j=1:k
x=input('Write the first coordinate (West-Est) : ');
y=input('Write the second coordinate (North-South) : ');
p(k,:)=[x y];
if j==1
sat=[p(k,:)];
else
sat=[sat;p(k,:)];
end
end
fg =size(sat,1);
xv=[];
yv=[];
p1=[];
for i=1:fg
p1= p(i,:);
a = 15;
b = 5;
alpha=45;
% Formula to find B and C
pa = [p1(1)+b*cos(alpha) p(2)+b*sin(alpha)];
pb = [p1(1)-a*sin(alpha) p(2)+a*cos(alpha)];
% D = C + (B-A);
pc = [pb(1)+(pa(1)-p1(1)) pb(2)+(pa(2)-p1(2))];
% Creating the area
v(:,i)=[p1(1);pa(1);pc(1);pb(1);p1(1)];
w(:,i)=[p1(2);pa(2);pc(2);pb(2);p1(2)];
%M(i,:)=[v w]
if i==fg
% if the last satellite do this
xv = [xv v(:,i)]
yv = [yv w(:,i)]
else
% else add
xv = [xv v(:,i) NaN]
yv = [yv w(:,i) NaN]
end
end
[X,Y,xq,yq] = Init_Region %Je charge la grille
% showing the acquisition
in = inpolygon(X,Y,xv,yv); %C'est l'ensemble des rectangles
figure
axis equal
hold on
plot(xv,yv,'LineWidth',2) % acquisition
plot(X(in),Y(in),'rp') % points inside
plot(X(~in),Y(~in),'b+') % points outside
hold off |
Partager