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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
VINAYAK LUHA
le 8 Juin 2022
Modifié(e) : VINAYAK LUHA
le 8 Juin 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 commentaire
Matt J
le 9 Juin 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 commentaires
Voir également
Catégories
En savoir plus sur Elementary Polygons 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!