function y = get_unit_vec(x) %This functions divides a vector by its magnitude mag = norm(x); if(mag<1e-10) error("normalizing a very small vector"); else y = x/mag; end