A rectangle is a parallelogram that has all four angles equal 90°.
In order to check if the points create a rectangle, using their coordinates, we need to do the following:
1) Calculate the distance between the points and check if we have two pairs of equal distances.
The formula to calculate the distance between two points (x1, y1) and (x2, y2) is:
2) Calculate the slope of each segment and check if the connected segments are perpendicular.
The condition for two segments with slopes m1 and m2 being perpendicular is:
This way, we can ensure that we have two pairs of segments with the same length and all angles are 90°, therefore having a rectangle.