import operator
import math


def unit_vector(vec1, vec2):
    """ Return a unit vector pointing from vec1 to vec2 """
    diff_vector = map(operator.sub, vec2, vec1)
    
    scale_factor = math.sqrt( sum( map( lambda x: x**2, diff_vector ) ) )
    if scale_factor == 0:
        scale_factor = 1 # We don't have an actual vector, it has zero length
    return map(lambda x: x/scale_factor, diff_vector)