- return coord(self.x-other.x, self.y-other.y)
- def distance(self, other):
- return math.sqrt((self.x - other.x)**2 + (self.y - other.y)**2)
+ return coord(self.i-other.i, self.j-other.j)
+ def __mul__(self, other):
+ return coord(self.i*other, self.j*other)
+ def __rmul__(self, other):
+ return coord(self.i*other, self.j*other)
+ def __div__(self, other):
+ return coord(self.i/other, self.j/other)
+ def __rdiv__(self, other):
+ return coord(self.i/other, self.j/other)
+ def snaptogrid(self):
+ return coord(int(round(self.i)), int(round(self.j)))
+ def distance(self, other=None):
+ if not other: other = coord(0, 0)
+ return math.sqrt((self.i - other.i)**2 + (self.j - other.j)**2)
+ def bearing(self, other=None):
+ if not other: other = coord(0, 0)
+ return 1.90985*math.atan2(self.i-other.i, self.j-other.j)