the code to obtain the unit vector from water dipole moment


Dear all, I am trying to obtain the unit vector of the dipole moment (a vector) using sub Normalize.

 # get dipole moment
     my \\\$dipoleMoment = \\\$setMolecule->DipoleMoment;
       # get the unit vector of dipole moment
     my \\\$direction=Normalize(\\\$dipoleMoment);

sub Normalize {}


The logic is unit vector=±a/|a|. For example, if I want to have the unit vector of (2,-3,6), the calculation process is unit vector=±(2,-3,6)/√4+9+36=±(2/7,-3/7,6/7).

\\\$dipoleMoment is a vector with (X, Y, Z), I am trying to have the unit vector of \\\$dipoleMoment, would you please write sub Normalize to fulfill this calculation?