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>
6 次查看(过去 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!