-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlayout.m
More file actions
31 lines (26 loc) · 764 Bytes
/
layout.m
File metadata and controls
31 lines (26 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% HEXAGONAL LAYOUT GENERATOR %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all % Close all open figures
clear % Reset variables
clc % Clear the command window
%% Generate hexagonal grid
N = 19; % NxN grid
Rad3Over2 = sqrt(3)/2;
[X, Y] = meshgrid(0:1:N);
n = size(X,1);
X = (Rad3Over2 * X)/N;
Y = (Y + repmat([0 0.5],[n,n/2]))/N;
radius = (1/sqrt(3))/N;
hold on
plot(X,Y,'b.'); % BS center
for i = 1:N;
for j = 1:N
xTemp = X(i,j);
yTemp = Y(i,j);
[xunit,yunit] = hexagon(xTemp,yTemp,radius);
plot(xunit, yunit,'k'); % Hexagonal Cell borders
end
end
axis equal, zoom on