function [A,Ix,Iy,xc,yc] = CrossSection(type,b,h,t) % [A,Ix,Iy,xc,yc] = CrossSection(type,b,h,t) % % CrossSection % % Ix = moment of inercia in x direction; % Iy = moment of inercia im y direction; % A = cross-section area; % xc = horizontal distance to the centroid from the left border; % yc = vertical distance to the centroid from the bottom; % type = cross-section type: {'U'|'S'|'R'|'C'|'T'|'I'|'L'|'Z'}; % b = cross-section width or diameter for circular shape; % h = cross-section height; % t = wall thickness. % % Walter Ponge-Ferreira % Cotia, 18.06.2018 if nargin<4, t = 0; endif if nargin<3, h = b; end if nargin<2, b = 1; end if nargin<1, type = 'S'; end switch (type), case {'U' 'u' 'U-shape' 'u-shape'}, A = (b-2*t)*t + 2*h*t; xc = b/2; yc = ((b-2*t)*t*t/2 + (2*h*t)*h/2)/A; Ix = (b-2*t)*t^3/3 + 2*t*h^3/3 - A*yc^2; Iy = t*(b-2*t)^3/12 + (2*h*t)*(xc-t/2)^2 + 2*h*t^3/12; case {'S' 's' 'Square' 'square'}, A = b^2 - (b-2*t)^2; xc = b/2; yc = b/2; Ix = b*b^3/12 - (b-2*t)*(b-2*t)^3/12; Iy = Ix; case {'R' 'r' 'Retangular' 'retangular'}, A = b*h - (b-2*t)*(h-2*t); xc = b/2; yc = h/2; Ix = h*b^3/12 - (h-2*t)*(b-2*t)^3/12; Iy = b*h^3/12 - (b-2*t)*(h-2*t)^3/12; case {'C' 'c' 'circular' 'circular'}, A = pi*b^2/4 - pi*(b-t)^2/4; xc = b/2; yc = b/2; Ix = pi*b^4/64 - pi*(b-t)^4/64; Iy = Ix; case {'T' 't' 'T-shape' 't-shape'}, A = b*t + (h-t)*t; xc = b/2; yc = ((b*t)*(h-t/2) + (h-t)*t*(h-t)/2)/A; Ix = b*t^3/12 + b*t*(h-t/2)^2 + t*(h-t)^3/3 - A*yc^2; Iy = t*b^3/12 + (h-t)*t^3/12; case {'I' 'i' 'I-shape' 'i-shape'}, A = 2*b*t + t*(h-2*t); xc = b/2; yc = h/2; Ix = 2*t*b^3/12 + (h-2*t)*t^3; Iy = 2*b*t^3/12 + b*t*(h-t)^2 + t*(h-2*t)^3/12; case {'L' 'l' 'L-shape' 'l-shape'}, A = (h-t)*t + b*t; xc = ((h-t)*t*t/2 + b*t*b/2)/A; yc = ((h-t)*t*(h/2+t) + b*t*t/2)/A; Ix = t*(h-t)^3/12 + t*(h-t)*(h/2+t)^2 + b*t^3/3 - A*yc^2; Iy = (h-t)*t^3/3 + t*b^3 - A*xc^2; case {'Z' 'z' 'Z-shape' 'z-shape'}, A = 2*b*t + (h-2*t)*t; xc = b - t/2; yc = h/2; Ix = 2*(b*t^3/12 + b*t*(h/2-t/2)^2) + t*(h-2*t)^2/12; Iy = 2*(t*b^3/12 + t*b*(b/2-t/2)^2) + (h-2*t)*t^3/12; otherwise error('Incorrect cross-section shape: { U | S | R | C | T | I | L | Z }') endswitch endfunction