code: def isRectangular(self):
          
  # if any two of the 4 corners are equal return false
          upper = (self.ur - self.ul).unit
          if not bool(upper):
              return False
          right = (self.lr - self.ur).unit
          if not bool(right):
              return False
          left  = (self.ll - self.ul).unit
          if not bool(left):
              return False
          lower = (self.lr - self.ll).unit
          if not bool(lower):
              return False
          eps = 1e-5
  # we now have 4 sides of length 1. If 3 of them have 90 deg angles,
  # then it is a rectangle -- we check via scalar product == 0
          return abs(sum(map(lambda x,y: x*y, upper, right))) <= eps and \
                 abs(sum(map(lambda x,y: x*y, upper, left))) <= eps and \
                 abs(sum(map(lambda x,y: x*y, left, lower))) <= eps
docs: Check if quad is rectangular.