> C programming help?

C programming help?

Posted at: 2014-12-18 
What is the definition of a rectangle? triangle?

A rectangle for example has 2 sets of parallel lines and if it does then check to see that the parallel lines are at a right angle from the other parallel lines.

Step 1: Sort the points given by the x coordinate...

The first two points are connected to each other and the last two points are connected to each other.

If the slope between the first two points and the slope between the last two points is not the same then return false.



Step 2: If the slope is the same keep track of the slope (slope1). Sort by the y coordinate, repeat the step above...

Step 3. check if the slope from step 1 is the reciprocal of slope from step 2: if ( pow(slope1, -1.0) ) == slope2 ) if so then it's a rectangle if not return false.

I'll let you figure out the triangle thing. Basically sort the points find the outer points and check if the leftover point is inside or on the line of the triangle..

How to know if the given points can form a 2d rectangle? Assume that the user has to put 4 inputs:

Point 1: 0 0

Point 2: 20 0

Point 3: 20 50

Point 4: 0 50

How do I know if these given points form a 2d triangle or not? Please explain to me!

thank you!