# How to find if three lines can form a triangle

Page 1 of 1

## 3 Replies - 1436 Views - Last Post: 01 December 2011 - 08:08 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=257944&amp;s=2bd35636f17a48ba36738bc68502d42e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 rapo

Reputation: 0
• Posts: 67
• Joined: 27-November 08

# How to find if three lines can form a triangle

Posted 01 December 2011 - 06:57 AM

I have a problem and I can't find an algoritm. I have an area[Workspace] (a square for example), in this area I'm drawing objects(squares or triangle), after the drawing of objects ( i'm calling them obstacles), I want the rest of the area to divide it in triangles. My algoritm is in this stage:
• I have the coordinates of the area (Workspace)
• I have the coordinates of the obstacles(Every point of outline of every obstacle)
• I'm drawing lines to join each point (obstacles extremities and area extremities)
• I have the coordinates of the lines between obstacles and between obstacles and workspace

I need an I idea of an algorithm to form valid traingles. I will attach two pictures to be more exact.
I'm in the situation of the first picture, I have the draw,coordinates, but I can't find an algorithm to find which 3 lines can form a triangle.
The coordinates of points are keept in generic lists List<Point> and lines of obstacles,workspaces and lines are separated kept in List<Line>

Thanks

#### Attached image(s)

Is This A Good Question/Topic? 0

## Replies To: How to find if three lines can form a triangle

### #2 tlhIn`toq

• Freelance developer

Reputation: 6211
• Posts: 13,713
• Joined: 02-June 10

## Re: How to find if three lines can form a triangle

Posted 01 December 2011 - 07:03 AM

I don't want code, just some ideas/help on the logic because I'm lost.

What you're really asking is for someone else to do all the heavy lifting of figuring out how your application should work: To do the actual engineering part of the software. Hence the job title Software Engineer.

Quote

but I can't find an algorithm to find which 3 lines can form a triangle.

Its not about *finding* an algorithm. Its about you developing one. Creating one, not plagiarizing one someone else put out on the net.

### #3 rapo

Reputation: 0
• Posts: 67
• Joined: 27-November 08

## Re: How to find if three lines can form a triangle

Posted 01 December 2011 - 07:09 AM

I don't need code, an idea, or a clue

### #4 tlhIn`toq

• Freelance developer

Reputation: 6211
• Posts: 13,713
• Joined: 02-June 10

## Re: How to find if three lines can form a triangle

Posted 01 December 2011 - 08:08 AM

Hence I gave you a link to the article "I don't need code, just an idea"

tlhIn`toq, on 01 December 2011 - 08:03 AM, said:

Did you read the article? The gist of it is that you at least need to make an effort of your own first. Just like when you need *help* with code.

The logic is the important part. The tough part. Once you have a plan in place the rest is just typing.

When you took on this project you must have had at least one plan in mind for how you were going to do it. To look at a project and say to yourself "I have no fraking clue. Sure I'll do it." would be idiotic.

We have all taken on tasks with a plan in mind, then had that plan fail us. It happens to everyone. Either the idea didn't work with the data... we didn't realize our original plan was going to require 18 hours of processing for every 6 hours of incoming data... After the plan was coded the boss then added on something else that was unknown to us and totally incompatible with the original logic. Etc. etc. But we all at least tried first before throwing up our hands and asking for help.

What I'm saying here is that you don't seem to have tried anything other than what you admit to: Trying to *find* a plan. Which I interpret as Googling for algorithm that someone else has given out.

If I'm wrong, then show it. What was your first couple ideas of how to approach this problem? How did those ideas fail in getting the job done.

I'm just trying to get you to make a good faith effort to devise a plan to do this before asking others to do your thinking for you.

This post has been edited by tlhIn`toq: 01 December 2011 - 08:08 AM