The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted as rectangles
Coordinates for rectangles can be given in any order, for example this:
A----B | | D----C and this:
A---B | | | | | | C---D are both rectangles.
Rectangles can be rotated, so they won't always be parallel to x and y axis.
You may take input in any form you like as long as the order for each coordinate is not mixed: [x,x,x,x,y,y,y,y] is not acceptable, where as [x,y,x,y,x,y,x,y] or [(x,y),(x,y),(x,y),(x,y)] is fine.
Complex numbers are a valid form of input
This is codegolf, so lowest byte count wins.
Test cases:
[0,2, 3,2, 3,0, 0,0] Truthy [3,5, 2,0, 0,2, 5,3] Truthy [6,3, 3,5, 0,2, 3,0] Falsy [1,4, 5,2, 4,0, 0,2] Truthy [0,0, 0,0, 3,2, 4,0] Falsy [1,1, 1,1, 1,1, 1,1] Truthy [1,4, 100,1, 100,1, 1,4] Truthy
[6,3,3,5,0,2,2,0]really a rectangle? \$\endgroup\$