How do I put the patch in the correct position?

3 views (last 30 days)
I have a longitude(x), latitude(y), altitude(z) data, which is aircraft data.
I made a patch using my data. but the patch is loacted in another position and y axis is not latitude number.
I don't know how to locate it in the correct position and how to use latitude(y) data for this.
so, I want the patch to be on trajectory like first image.
for i = 1:length(Dep_33L)
plot3(Dep_33L(i).Longitude, Dep_33L(i).Latitude, Dep_33L(i).BAlt)
hold on
end
yv = linspace(min(y), max(y), 30);
for k = 1:length(yv)
for i = 1:length(RKSI_Dep_33L)
x(i) = Dep_33L(i).Longitude(k);
z(i) = Dep_33L(i).BAlt(k);
end
xptcl = prctile(x,[2.5 97.5]);
zpctl = prctile(z,[2.5 97.5]);
xl(k,:) = xptcl;
zl(k,:) = zpctl;
patch([xptcl flip(xptcl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25)
end
plot3(xl(:,1), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,1), yv(:), zl(:,2), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,1), '-k', 'LineWidth',2)
plot3(xl(:,2), yv(:), zl(:,2), '-k', 'LineWidth',2)
xlabel('X')
ylabel('Y')
zlabel('Z')

Accepted Answer

Star Strider
Star Strider on 27 May 2022
It appears that the ‘x’ and ‘y’ axes are reversed with respect to the data and the percentile patches. Keep the percentile patches as they are, and experiment with changing the data plot arguments so that they overlap correctly. (Without the axis labels and the axis gridlines, it is difficult to determine what needs to be changed.)
  13 Comments
Star Strider
Star Strider on 28 May 2022
That would likely require some sort of rotation matrix in 3 dimensions on each percentile patch. The rotation angle can likely be calcualted from the climb angle (typically 30° if I remember correctly) with the other angles remaining unchanged, since all aircraft would be expected to maintain runway heading (actually course) until reaching pattern altitude. They would then be vectored to their respective SID routes.
Using my original code and the rotate function i was able to get this far —
x = rand(1,5000)*10+125;
y = randn(1,5000)*50+250;
z = randn(1,5000)*150+300;
t = linspace(0, 1, 5000);
x = x + sin(2.5*pi*t)*125;
y = y + cos(1.5*pi*t)*125;
z = z + t*cosd(30)*1E+3;
yv = linspace(min(y), max(y), 7); % Set 'Y' Values For The Box Locations
figure
scatter3(x,y,z,'.')
hold on
for k = 1:numel(yv)
yrng = find(y>=0.8*yv(k) & y <=1.2*yv(k));
xpctl = prctile(x(yrng),[2.5 97.5]);
zpctl = prctile(z(yrng),[2.5 97.5]);
xl(k,:) = xpctl;
zl(k,:) = zpctl;
hp = patch([xpctl flip(xpctl)], [0 1 1 0]+yv(k), [[1 1]*zpctl(1) [1 1]*zpctl(2)], 'r', 'FaceAlpha',0.25);
rotate(hp,[0.5 0 1],-30)
% vtx2 = get(hp,'Vertices')
xd(:,k) = hp.XData;
yd(:,k) = hp.YData;
zd(:,k) = hp.ZData;
end
% xd
% yd
% zd
% get(hp)
plot3(xd(1,:), yd(1,:), zd(1,:), '-k', 'LineWidth',2)
plot3(xd(2,:), yd(2,:), zd(2,:), '-k', 'LineWidth',2)
plot3(xd(3,:), yd(3,:), zd(3,:), '-k', 'LineWidth',2)
plot3(xd(4,:), yd(4,:), zd(4,:), '-k', 'LineWidth',2)
hold off
xlabel('X')
ylabel('Y')
zlabel('Z')
% xlim([120 140])
% ylim([100 400])
view(45,30)
I leave the rest to you. See the rotate documentation for details on how it works to make it work with your data.
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by