Viewing a house in MATLAB
5 ビュー (過去 30 日間)
古いコメントを表示
Hi, I would like to view the house given in the mat file.
When I issue:
load husdata.mat
patch(walls{1,1},walls{1,2},walls{1,3},'r')
set(gca,'projection','perspective')
view(3)
axis('off')
I get this
however, I think it should be a complete house, where one sees the roof. How can I view the whole thing and change the color of the roof into grey?
Thanks!
0 件のコメント
採用された回答
Star Strider
2024 年 2 月 29 日
The walls and roof needed duplicates with some offsets to plot correctly. Other than that, the patch arguments are set up to be straightforward to plot (for which I am grateful, because 3D patch plots can sometimes be challenging). I coloured the walls differently to show their differences when viewed at different angles. Colour them as you prefer. In the second plot, I changed the roof colour to gray.
Try this —
load('husdata.mat')
% whos
R = roof;
W = walls;
figure
hold on
patch(W{1,1}, W{1,2}, W{1,3}, 'r')
patch(W{2,1}, W{2,2}, W{2,3}, 'g')
patch(W{1,1}, W{1,2}+9, W{1,3}, 'c')
patch(W{2,1}+6, W{2,2}, W{2,3}, 'm')
patch(R{1}, R{2}, R{3}, 'b')
patch(flip(R{1})+3.3, R{2}, R{3}, 'b')
hold off
xlabel('X')
ylabel('Y')
view(30,30)
title('House: Front View (Note: X & Y Coordinates)')
figure
hold on
patch(W{1,1}, W{1,2}, W{1,3}, 'r') % End Wall
patch(W{2,1}, W{2,2}, W{2,3}, 'g') % Side Wall
patch(W{1,1}, W{1,2}+9, W{1,3}, 'c') % End Wall
patch(W{2,1}+6, W{2,2}, W{2,3}, 'm') % Side Wall
patch(R{1}, R{2}, R{3}, [1 1 1]*0.5)
patch(flip(R{1})+3.3, R{2}, R{3}, [1 1 1]*0.5)
hold off
xlabel('X')
ylabel('Y')
view(210,30)
title('House: Rear View (Note: X & Y Coordinates)')
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!