Inner Products(Dot Products)
v*w = ||v||*||w||*cosΘ
def dot(self, v): return sum([x*y for x,y in zip(self.coordinates, v.coordinates)]) def angle_with(self, v, in_degrees=False) try: u1 = self.normalized() u2 = v.normalized() angle_in_raddians = acos(u1.dot(u2)) if in_degrees: degrees_per_radian = 180./ pi return angle_in_radians * degrees_per_radian else: return angle_in_radians except Exception as e: if str(e) == self.CANNOT_NORMALIZE_ZERO_VECTOR_MSG: raise Exception('Cannot compute an angle with the zero vector') else: raise e