""" This module provides functions to perform standard vector operations. Vectors are represented as lists of numbers (floats or ints). Functions that take two vector arguments may give arbitrary output if the vectors are not compatible, i.e. of the same dimension. """ #------------------------------------------------------------------------------ # import standard library modules #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # function definitions #------------------------------------------------------------------------------ def add(u, v): # end add() def negate(u): # end negate() def sub(u, v): # end sub() def scalarMult(c, u): # end scalarMult() def zip(u, v): # end zip() def dot(u, v): # end dot() def length(u): # end length() def unit(v): # end unit() def angle(u, v): """ Return the angle (in degrees) between vectors u and v. """ return math.degrees(math.acos(dot(unit(u),unit(v)))) # end angle() def randVector(n, a, b): # end randomVector()