CYLINDERSURFACEAREA Surface area of a cylinder. S = cylinderSurfaceArea(CYL) Computes the surface area of the cylinder defined by: CYL = [X1 Y1 Z1 X2 Y2 Z2 R], where [X1 Y1 Z1] and [X2 Y2 Z2] are the coordinates of the cylinder extremities, and R is the cylinder radius. The surface area of the cylinder comprises the surface area of the two disk-shape end caps. Example cyl = [0 0 0 1 0 0 1]; cylinderSurfaceArea(cyl) ans = 12.5664 % equals to 4*pi See also geom3d, ellipsoidSurfaceArea, intersectLineCylinder
0001 function S = cylinderSurfaceArea(cyl) 0002 %CYLINDERSURFACEAREA Surface area of a cylinder. 0003 % 0004 % S = cylinderSurfaceArea(CYL) 0005 % Computes the surface area of the cylinder defined by: 0006 % CYL = [X1 Y1 Z1 X2 Y2 Z2 R], 0007 % where [X1 Y1 Z1] and [X2 Y2 Z2] are the coordinates of the cylinder 0008 % extremities, and R is the cylinder radius. 0009 % The surface area of the cylinder comprises the surface area of the two 0010 % disk-shape end caps. 0011 % 0012 % Example 0013 % cyl = [0 0 0 1 0 0 1]; 0014 % cylinderSurfaceArea(cyl) 0015 % ans = 0016 % 12.5664 0017 % % equals to 4*pi 0018 % 0019 % See also 0020 % geom3d, ellipsoidSurfaceArea, intersectLineCylinder 0021 0022 % ------ 0023 % Author: David Legland 0024 % e-mail: david.legland@inra.fr 0025 % Created: 2017-11-02, using Matlab 9.3.0.713579 (R2017b) 0026 % Copyright 2017 INRA - Cepia Software Platform. 0027 0028 H = distancePoints3d(cyl(:, 1:3), cyl(:, 4:6)); 0029 R = cyl(:,7); 0030 0031 S1 = 2*pi*R .* H; 0032 S2 = 2 * (pi * R.^2); 0033 0034 S = S1 + S2;