Esempio n. 1
0
    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)
Esempio n. 2
0
 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)        
Esempio n. 3
0
    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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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
Esempio n. 8
0
 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)
Esempio n. 9
0
 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)
Esempio n. 10
0
 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