-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpler.m
35 lines (30 loc) · 888 Bytes
/
simpler.m
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
32
33
34
35
N = 1;
R = E = 2;
S = 3;
L = W = 4;
walls = [ ...
horizontal( 01 ), ...
vertical( 02 ), ...
horizontal( 03 ), ...
vertical( 04 ), ...
];
constraints = [ ...
origin( walls, 01, L); ...
thickness( walls, 01, .25 ); ...
thickness( walls, 02, .25 ); ...
thickness( walls, 03, .25 ); ...
thickness( walls, 04, .25 ); ...
... % Connections
connect( walls, 01, R, 02, N); ...
connect( walls, 02, S, 03, R); ...
connect( walls, 03, L, 04, S); ...
connect( walls, 04, N, 01, L); ...
... % Distances
distance( walls, 01, S, 03, N, 4.50); ...
distance( walls, 04, R, 02, L, 4.50 - 0.85); ...
];
constraints_M = constraints(:, 1:end-1);
constraints_v = constraints(:, end);
raw_sol = constraints_M \ constraints_v;
sol = reshape(raw_sol, 4, size(raw_sol, 1) / 4)';
rects = draw_plan(walls, sol);