VECTORNORM3D Norm of a 3D vector or of set of 3D vectors. N = vectorNorm3d(V); Returns the norm of vector V. When V is a N-by-3 array, compute norm for each vector of the array. Vectors are given as rows. Result is then a N-by-1 array. NOTE: Computes only the Euclidean norm. See also: vectors3d, normalizeVector3d, vectorAngle3d, hypot3
0001 function n = vectorNorm3d(v) 0002 %VECTORNORM3D Norm of a 3D vector or of set of 3D vectors. 0003 % 0004 % N = vectorNorm3d(V); 0005 % Returns the norm of vector V. 0006 % 0007 % When V is a N-by-3 array, compute norm for each vector of the array. 0008 % Vectors are given as rows. Result is then a N-by-1 array. 0009 % 0010 % NOTE: Computes only the Euclidean norm. 0011 % 0012 % See also: 0013 % vectors3d, normalizeVector3d, vectorAngle3d, hypot3 0014 % 0015 0016 % --------- 0017 % author : David Legland 0018 % INRA - TPV URPOI - BIA IMASTE 0019 % created the 21/02/2005. 0020 0021 % HISTORY 0022 % 19/06/2009 rename as vectorNorm3d 0023 0024 n = sqrt(sum(v.*v, ndims(v)));