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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
VINAYAK LUHA
am 8 Jun. 2022
Bearbeitet: VINAYAK LUHA
am 8 Jun. 2022
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.
1 Kommentar
Matt J
am 9 Jun. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Elementary Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!