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 % E-mail: david.legland@inrae.fr 0019 % Created: 2005-02-21 0020 % Copyright 2005-2024 INRA - TPV URPOI - BIA IMASTE 0021 0022 n = sqrt(sum(v.*v, ndims(v)));