Points
-represent location
-written as (x,y,z…)
e.g. (2,-1)
Vectors
-represent change in location
-magnitude and direction
-written as [x,y,z…]
Common practice to interchange points and vectors
Technically different but often a useful shortcut
V=[-2, -3] P=(-2,-3)
P=(-4,-4), Q=(4,-2)
v=[-1,4],w=[-2,0]
class Vector(object):
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordinate = tuple(cordinates)
self.dimension = len(coordinates)
except ValueError:
raise ValueError('The coordinates must be nonempty')
except TypeError:
raise TypeError('The coordinate must be an iterable')
def __str__(self):
return 'Vector: {}'.format(self.coordinates)