I have this piece of code for finding out whether 4 x,y coordinates make a rectangle which works perfectly well, but, I need to make it so that it only works if the points are entered in the correct order, ie: Point #1: 0 0 Point #2: 20 0 Point #3: 20 50 Point #4: 0 50 would say "Is a rectangle" but: Point #1: 0 0 Point #2: 20 0 Point #3: 0 50 Point #4: 20 50 Would say "Is not a rectangle" (because the points arent in the right order)
It sounds like you're defining "correct" order as counter-clockwise starting from the lower left. If that's true then x3>x1 and y3>y1. In other words, the point 3 is above and to the right of point 1. Also, once you know points 1 and 3, you know where points 2 and 4 should be, so you can check if they are where they should be.