How can I use one of the 3-D plot functions on the MATLAB to plot multiples 3-D polygons? Thank you

4 vues (au cours des 30 derniers jours)
having a coordinate in this form: [53.366586, -6.234543] that represents a building for example. From tthis, how to plot the building in a 3D, in form of polygon assuming the height is 30m and the width and length is 5m.

Réponse acceptée

Star Strider
Star Strider le 5 Mai 2018
Modifié(e) : Star Strider le 5 Mai 2018
Try this:
l = 5; % Length
w = 5; % Width
h = 30; % Height
X = [-1 -1 1 1 -1; -1 -1 1 1 -1]*l;
Y = [-1 1 1 -1 -1; -1 1 1 -1 -1]*w;
Z = [ 1 1 1 1 1; 0 0 0 0 0]*h;
figure(1)
surf(X, Y, Z) % Plot Walls
hold on
patch(X(1,:), Y(1,:), Z(1,:), 'y') % Plot Flat Roof
hold off
grid on
axis equal
axis([-10 10 -10 10 0 40])
EDIT To plot multiple buildings:
figure(2)
surf(X, Y, Z) % Plot Walls - Building #1
hold on
patch(X(1,:), Y(1,:), Z(1,:), 'y') % Plot Flat Roof - Building #1
surf(X + ones(size(X))*15, Y + ones(size(Y))*20, Z) % Plot Walls - Building #2
patch(X(1,:) + 15, Y(1,:) + 20, Z(1,:), 'y') % Plot Flat Roof - Building #2
surf(X + ones(size(X))*35, Y + ones(size(Y))*25, Z) % Plot Walls - Building #3
patch(X(1,:) + 35, Y(1,:) + 25, Z(1,:), 'y') % Plot Flat Roof - Building #3
hold off
grid on
axis equal
axis([-10 50 -10 50 0 40])
  4 commentaires
Star Strider
Star Strider le 5 Mai 2018
As always, my pleasure!
‘Is there any way to use this w=53.366586, l=-6.234543 instead?’
Yes. The building can have any dimensions you want, and different buildings can have different dimensions, providing that the walls and roofs are squares or rectangles (as I have coded it). Note that ‘l’, and ‘w’ are the length and width of the building, respectively. You requested that the length and width be 5, and the height be 30, so I constructed them with those dimensions.

Connectez-vous pour commenter.

Plus de réponses (1)

Oflive Mamena
Oflive Mamena le 5 Mai 2018
Modifié(e) : Oflive Mamena le 5 Mai 2018
This was what I did:
c=[53.382818, -1.488529]; %ext to hicks building
xx2=c(2);
distanceRequired=nm2deg(50*0.000539957);% Convert meters to nautical miles and then to degrees
[newlat newlon]=reckon('rh',c(1),c(2),distanceRequired,85); % straight line in the right hand side
xx1=newlon;
yy2=newlat;
distanceRequired=nm2deg(60*0.000539957)
[newlat newlon]=reckon('rh',c(1),c(2),distanceRequired,180); % straight line downwards
[newlat newlon]=reckon('rh',newlat,newlon,distanceRequired,85); % straight line in the right hand side
yy1=newlat;
% hold on
plot3 ( [xx1, xx2,xx2,xx1,xx1],[yy1, yy1,yy2,yy2,yy1],[30 30 30 30 30],'c','LineWidth',3);
hold on
plot3 ( [xx1, xx2,xx2,xx1,xx1],[yy1, yy1,yy2,yy2,yy1],[0 0 0 0 0],'c','LineWidth',3);
plot3 ( [xx2, xx2],[yy1 yy1],[30 0],'c','LineWidth',3);
plot3 ( [xx2, xx2],[yy2 yy2],[30 0],'c','LineWidth',3);
plot3 ( [xx1, xx1],[yy2 yy2],[30 0],'c','LineWidth',3);
plot3 ( [xx1, xx1],[yy1 yy1],[30 0],'c','LineWidth',3);

Catégories

En savoir plus sur Seismology dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by