Hello everybody I have a question . I have a cuboid shape, I want to calculate all the points within this figure as x,y values and save to workspace>
3 ビュー (過去 30 日間)
古いコメントを表示
Hello everybody
I have a question . I have a cuboid shape, I want to calculate all the points within this figure as x,y values and save to workspace>
0 件のコメント
回答 (2 件)
VINAYAK LUHA
2022 年 6 月 8 日
編集済み: VINAYAK LUHA
2022 年 6 月 8 日
Hi Wisam ,
As per my understanding of your problem , you wish to store all interior integer coordinates in the cuboid,in this case each point will be a tuple of 3 elements, (x,y,z) .
Let (x1,y1,z1) and (x2,y2,z2) be the endpoints of body digonal of the cuboid,then interior points can be calculated as follows.
let,
x1=5;x2=8; y1=4;y2=6;z1=0;z2=2;
xmin=min(x1,x2);
xmax=max(x1,x2);
ymin=min(y1,y2);
ymax=max(y1,y2);
zmin=min(z1,z2);
zmax=max(z1,z2);
points=[[]];
for x=xmin:xmax
for y=ymin:ymax
for z=zmin:zmax
points=[points;[x,y,z]];
end
end
end
disp(points)
scatter3(points(:,1),points(:,2),points(:,3),'o')
Hope this helps.
Matt J
2022 年 6 月 9 日
tf = inpolygon(xq,yq,[2.23 0.1404 8.258 10.37],[14.95 0.9339 1.579 15.61 ]);
x=xq(tf);
y=yq(tf);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Elementary Polygons についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!