function [bayX, bayY, FloorCoord, bayx_num, bayy_num, nx, ny, columnLine] = GeometricSetup(s, h, Bx, By, dx, dy) %% Setting up BayXMain, BayYMain and FloorCoord nx = (Bx/dx); % Number of bays along x direction on one gridline ny = (By/dy); % Number of bays along y direction on one gridline bayx_num = nx*(ny + 1); % Total number of bays along x direction bayy_num = ny*(nx + 1); % Total number of bays along y direction columnLine = cell(((nx + 1)*(ny + 1)),(s + 1)); % Cell array number of column lines by number of stories + 1. % Each cell element to contain coordinate of point at that % column-line and story as [x,y,z] % Populating columnLine cell for story_count = 0:s counter = 1; for i1 = 1:(ny + 1) for i2 = counter:(counter + nx) if i2 > (nx + 1) if rem(i2,(nx + 1)) == 0 columnLine{i2,story_count + 1}(1) = nx*dx; columnLine{i2,story_count + 1}(2) = ((i2/(nx + 1)) - 1)*dy; else columnLine{i2,story_count + 1}(1) = ((rem(i2,(nx + 1))) - 1)*dx; columnLine{i2,story_count + 1}(2) = ((i2 - (rem(i2,(nx + 1))))/(nx + 1))*dy; end columnLine{i2,story_count + 1}(3) = story_count*h; end if i2 <= (nx + 1) columnLine{i2,story_count + 1}(1) = (i2 - 1)*dx; columnLine{i2,story_count + 1}(2) = 0; columnLine{i2,story_count + 1}(3) = story_count*h; end end counter = counter + (nx + 1); end end bayX_columnLine = zeros(bayx_num,2); bayY_columnLine = zeros(bayy_num,2); % Assigning bays along x-direction to appropriate column lines (1 = left, 2 = right) for i = 1:bayx_num if i <= nx bayX_columnLine(i,1) = i; bayX_columnLine(i,2) = i + 1; else if rem(i,nx) == 0 bayX_columnLine(i,1) = ((i/nx)*(nx + 1)) - 1; bayX_columnLine(i,2) = ((i/nx)*(nx + 1)); else bayX_columnLine(i,1) = (1 + (nx + 1)*((i - (rem(i,nx)))/nx)) + (rem(i,nx)) - 1; bayX_columnLine(i,2) = (1 + (nx + 1)*((i - (rem(i,nx)))/nx)) + (rem(i,nx)); end end end % Assigning bays along x-direction to appropriate column lines (1 = bottom, 2 = top) for i = 1:bayy_num if i <= ny bayY_columnLine(i,1) = (i*(nx + 1)) + 1 - (nx + 1); bayY_columnLine(i,2) = (i*(nx + 1)) + 1; else if rem(i,ny) == 0 bayY_columnLine(i,1) = (i/ny) + (nx + 1)*(ny - 1); bayY_columnLine(i,2) = (i/ny) + (nx + 1)*ny; else bayY_columnLine(i,1) = (((i - (rem(i,ny)))/ny) + 1) + (rem(i,ny))*(nx + 1) - (nx + 1); bayY_columnLine(i,2) = (((i - (rem(i,ny)))/ny) + 1) + (rem(i,ny))*(nx + 1); end end end bayX = cell(bayx_num,s,4); bayY = cell(bayy_num,s,4); for i = 1:bayx_num for j = 1:s bayX{i,j,1}(1) = columnLine{(bayX_columnLine(i,1)),j}(1); % x coord. of bottom-left point bayX{i,j,1}(2) = columnLine{(bayX_columnLine(i,1)),j}(2); % y coord. of bottom-left point bayX{i,j,1}(3) = columnLine{(bayX_columnLine(i,1)),j}(3); % z coord. of bottom-left point bayX{i,j,2}(1) = columnLine{(bayX_columnLine(i,2)),j}(1); % x coord. of bottom-right point bayX{i,j,2}(2) = columnLine{(bayX_columnLine(i,2)),j}(2); % y coord. of bottom-right point bayX{i,j,2}(3) = columnLine{(bayX_columnLine(i,2)),j}(3); % z coord. of bottom-right point bayX{i,j,3}(1) = bayX{i,j,2}(1); % x coord. of top-right point bayX{i,j,3}(2) = bayX{i,j,2}(2); % y coord. of top-right point bayX{i,j,3}(3) = bayX{i,j,2}(3) + h; % z coord. of top-right point bayX{i,j,4}(1) = bayX{i,j,1}(1); % x coord. of top-left point bayX{i,j,4}(2) = bayX{i,j,1}(2); % y coord. of top-left point bayX{i,j,4}(3) = bayX{i,j,1}(3) + h; % z coord. of top-left point end end for i = 1:bayy_num for j = 1:s bayY{i,j,1}(1) = columnLine{(bayY_columnLine(i,1)),j}(1); % x coord. of bottom-left point bayY{i,j,1}(2) = columnLine{(bayY_columnLine(i,1)),j}(2); % y coord. of bottom-left point bayY{i,j,1}(3) = columnLine{(bayY_columnLine(i,1)),j}(3); % z coord. of bottom-left point bayY{i,j,2}(1) = columnLine{(bayY_columnLine(i,2)),j}(1); % x coord. of bottom-right point bayY{i,j,2}(2) = columnLine{(bayY_columnLine(i,2)),j}(2); % y coord. of bottom-right point bayY{i,j,2}(3) = columnLine{(bayY_columnLine(i,2)),j}(3); % z coord. of bottom-right point bayY{i,j,3}(1) = bayY{i,j,2}(1); % x coord. of top-right point bayY{i,j,3}(2) = bayY{i,j,2}(2); % y coord. of top-right point bayY{i,j,3}(3) = bayY{i,j,2}(3) + h; % z coord. of top-right point bayY{i,j,4}(1) = bayY{i,j,1}(1); % x coord. of top-left point bayY{i,j,4}(2) = bayY{i,j,1}(2); % y coord. of top-left point bayY{i,j,4}(3) = bayY{i,j,1}(3) + h; % z coord. of top-left point end end FloorCoord = cell(s,3); % Matrix containing corner points of each floor % Populating floorCoord matrix for i = 1:s FloorCoord{i,1}(1) = 0; FloorCoord{i,1}(2) = Bx; FloorCoord{i,1}(3) = Bx; FloorCoord{i,1}(4) = 0; FloorCoord{i,2}(1) = 0; FloorCoord{i,2}(2) = 0; FloorCoord{i,2}(3) = By; FloorCoord{i,2}(4) = By; FloorCoord{i,3}(1) = i*h; FloorCoord{i,3}(2) = i*h; FloorCoord{i,3}(3) = i*h; FloorCoord{i,3}(4) = i*h; end end