Remove overlapping areas of 663 rectangles

As in the first image (Figure 1), I am trying to remove the overlaps of 663 intersecting rectangles, and have the outmost lines visible. The second image (Figure 2) presents an example with two intersecting rectangle. I have attached an EXCEL file containing the coordinates of all the rectangles. I've stuck with this problem, please help me.
Figure 1
Figure 2

4 comentarios

KSSV
KSSV el 6 de Nov. de 2018
There are many rectangles overlapping..you want to consider only two rectangles? OR all the overlapping rectangles?
Wen Fang
Wen Fang el 6 de Nov. de 2018
Thank you for your comment. I want to consider all the overlapping rectangles.
KSSV
KSSV el 6 de Nov. de 2018
Editada: KSSV el 6 de Nov. de 2018
If you can tell what is the final purpose....there might be another simple approach rather then this.
Are you looking for something like this?
Wen Fang
Wen Fang el 6 de Nov. de 2018
You are totally right. But I want to have the sides of the polygons visible after removing the overlaps. The following is a simple example with three intersecting rectangles.

Iniciar sesión para comentar.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 6 de Nov. de 2018
data = xlsread('Rectangle points.xlsx');
data = reshape(data,[],2,4);
data = permute(data,[2 3 1]);
n = size(data,3);
p = arrayfun(@(k) polyshape(data(1,:,k),data(2,:,k)), 1:n);
q = p(1);
for k=2:n
q = union(q,p(k));
end
plot(q)
axis equal

9 comentarios

Wen Fang
Wen Fang el 6 de Nov. de 2018
Bingo! Thank you so much for helping me solve this problem. It helps me a lot. By the way, is there any way to calculate the area of the final ploygons filled with color?
KSSV
KSSV el 6 de Nov. de 2018
+1...I was thinking it in a complex way.
>> q.area
ans =
2.8940e+05
Please read doc of POLYSHAPE before asking.
KSSV
KSSV el 6 de Nov. de 2018
Editada: KSSV el 6 de Nov. de 2018
@ Wen Fang I am curious to know what this data corresponds to and what is the application? Kind of maze or something?
Wen Fang
Wen Fang el 6 de Nov. de 2018
@Bruno Luong I am sorry, but I don't have POLYSHAPE function in my version of MATLAB(R2015b). I have added a copy of this function to my MATLAB. Thank you again for your kind help.
@KSSV Also give special thanks to you=. Actually this data corresponds to the fracture distribution of a outcrop, something relates to my major.
Bruno Luong
Bruno Luong el 6 de Nov. de 2018
For your convenient Online doc of polyshape.
Wen Fang
Wen Fang el 19 de Nov. de 2018
@ Bruno Luong Thank you so much for your previous kind help. Now this problem become harder. What if the problem becomes a 3D problem? That is to say, every rectangle becomes a cuboid. We still know the 8 coordpoints of every cuboid (plz see attachment). Is there any way to remove the intersections? Please help me.
Bruno Luong
Bruno Luong el 19 de Nov. de 2018
Sorry I do not know any built-in data structure that can store a volume in 3D by plannar faces, beside convex hul (but in your case it is not convex at all), let alone doing operation on it.
Wen Fang
Wen Fang el 19 de Nov. de 2018
@ Bruno Luong Thank you for your reply. Seems like this is an impossible task.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 6 de Nov. de 2018

Comentada:

el 19 de Nov. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by