5.4.7. nvector.util.unit¶
- unit(vector, norm_zero_vector=1)[source]¶
Convert input vector to a vector of unit length.
- Parameters
- vector3 x m array
m column vectors
- Returns
- unitvector3 x m array
normalized unitvector(s) along axis==0.
Notes
The column vector(s) that have zero length will be returned as unit vector(s) pointing in the x-direction, i.e, [[1], [0], [0]]
Examples
>>> import numpy as np >>> import nvector as nv >>> np.allclose(nv.unit([[1, 0],[1, 0],[1, 0]]), [[ 0.57735027, 1], ... [ 0.57735027, 0], ... [ 0.57735027, 0]]) True