- Home /

# Detect perimetral walls of a room

Hi, I'm developing a building editor. Users can draw rooms by adding angles (vertices of the room) with a left click. Clicking on an existing angle closes the room and fills the floor by using the PointInPolygon algorithm. Let me illustrate the problem. I have this room.

```
#-----------#
| |
| |
| #-----#
| |
| |
| |
#-----#
```

Now I want to create another room by connecting two of the vertices like this:

```
#-----------#
| |
| |
| V--A--X < first click
| | |
| B | <--new room
| | |
#-----Y-----#
^
second click
```

I need to detect the vertex V and the edges A and B. I tried to implement the convex hull algorithm to find the external walls, but there are degenerated cases where those edges are interior walls... I even tried the Dijstra's algorithm to find the shortest path between X and Y, but again there are degenerated cases like this:

```
first click
v
X----------# < second click
| |
#-----#-----# |
| | | |
| | | | <--new room
| | | |
#-----#-----# |
| |
Y----------# < third click
^
fourth click
```

How should I approach this problem?

**Answer** by suchoparek
·
Jun 21, 2015 at 11:01 AM

This question was answered here: link text.

Rather than a graph algorithm, you can use a boolean operation to subtract the first room from the second one.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.