A little vector math problem

This function would probably do what you want. link text