-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbox2polytopic.m
43 lines (39 loc) · 1.29 KB
/
box2polytopic.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
36
37
38
39
40
41
42
43
% box2polytopic
%
% Technical University of Munich
% University of Toronto Institute for Aerospace Studies
% Learning Systems and Robotics Lab
%
% Author
% Lukas Brunke: [email protected]
function [L, l] = box2polytopic(Z_limits, dim)
% Turns box constraints to polytopic constraints
% This assumes that constraints contain the origin
L = [];
l = [];
eye_dim = eye(dim);
for constraint_id = 1 : size(Z_limits, 1)
entry_id = Z_limits(constraint_id, 1);
if Z_limits(constraint_id, 2) ~= -inf
if Z_limits(constraint_id, 2) == 0
l = [l; 0];
L = [L; - eye_dim(constraint_id, :)];
else
% Note: negative sign is in L matrix
l = [l; 1];
factor = 1 / Z_limits(constraint_id, 2);
L = [L; factor * eye_dim(entry_id, :)];
end
end
if Z_limits(constraint_id, 3) ~= inf
if Z_limits(constraint_id, 3) == 0
l = [l; 0];
L = [L; eye_dim(constraint_id, :)];
else
l = [l; 1];
factor = 1 / Z_limits(constraint_id, 3);
L = [L; factor * eye_dim(entry_id, :)];
end
end
end
end