Adding JavaScript vector math code