HYPOT3 Diagonal length of a cuboidal 3D box . h = hypot3(a, b, c) computes the quantity sqrt(a^2 + b^2 + c^2), by avoiding roundoff errors. Example % Compute diagonal of unit cube hypot3(1, 1, 1) ans = 1.7321 % Compute more complicated diagonal hypot3(3, 4, 5) ans = 7.0711 See also hypot, vectorNorm3d ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2012-04-29, using Matlab 7.9.0.529 (R2009b) Copyright 2012 INRA - Cepia Software Platform.
0001 function h = hypot3(dx, dy, dz) 0002 %HYPOT3 Diagonal length of a cuboidal 3D box . 0003 % 0004 % h = hypot3(a, b, c) 0005 % computes the quantity sqrt(a^2 + b^2 + c^2), by avoiding roundoff 0006 % errors. 0007 % 0008 % Example 0009 % % Compute diagonal of unit cube 0010 % hypot3(1, 1, 1) 0011 % ans = 0012 % 1.7321 0013 % 0014 % % Compute more complicated diagonal 0015 % hypot3(3, 4, 5) 0016 % ans = 0017 % 7.0711 0018 % 0019 % See also 0020 % hypot, vectorNorm3d 0021 % 0022 % ------ 0023 % Author: David Legland 0024 % e-mail: david.legland@grignon.inra.fr 0025 % Created: 2012-04-29, using Matlab 7.9.0.529 (R2009b) 0026 % Copyright 2012 INRA - Cepia Software Platform. 0027 0028 h = hypot(hypot(dx, dy), dz);