def point(self, center=()): """Return the point that is the specified center point translated by this vector """ coords = [] for i in range(max(len(self), len(center))): coords.append(self[i] - Point._get_coord(center, i)) return Point(*coords)
def translate(self, other): """Return a new vector that is this vector translated by the other vector (parallelogram rule) """ coords = [] for i in range(max(len(self), len(other))): coords.append(self[i] + Point._get_coord(other, i)) return Vector(*coords)
def point(self, center=()): """Return the point that is the specified center point translated by this vector """ coords = [] for i in range(max(len(self), len(center))): coords.append(self[i] - Point._get_coord(center, i)) return Point(*coords)
def translate(self, other): """Return a new vector that is this vector translated by the other vector (parallelogram rule) """ coords = [] for i in range(max(len(self), len(other))): coords.append(self[i] + Point._get_coord(other, i)) return Vector(*coords)
def __sub__(self, other): coords = [] for i in range(max(len(self), len(other))): coords.append(self[i] - Point._get_coord(other, i)) return Vector(*coords)
def get_coord(self, i): """Get the i coordinate of this vector. Return 0 if past the end.""" return Point._get_coord(self.coordinates, i)
def dot(self, other): """Return the dot product of this vector with the other vector""" d = 0 for i in range(max(len(self), len(other))): d += self[i]*Point._get_coord(other, i) return d
def __sub__(self, other): coords = [] for i in range(max(len(self), len(other))): coords.append(self[i] - Point._get_coord(other, i)) return Vector(*coords)
def get_coord(self, i): """Get the i coordinate of this vector. Return 0 if past the end.""" return Point._get_coord(self.coordinates, i)
def dot(self, other): """Return the dot product of this vector with the other vector""" d = 0 for i in range(max(len(self), len(other))): d += self[i] * Point._get_coord(other, i) return d