📄 con_list6.m
字号:
function [BC,Hi,Ki] = con_list6(Hi,Ki)
% Syntax
%
% [BC,Hi,Ki] = con_list(Hi,Ki)
%
% Description
%
% Generate a list of conections among polyhedra
% in (minimal representation) form
% Hi{i} * x <= Ki(i), 1<=i<=N,
%
% where
% x - n x 1, state vector,
% n - number of states,
% N - total number of polyhedra,
% Hi{i} - nb(i) x n, boundaries, 1<=nb(i)<=N-1,
% Ki{i} - nb(i) x 1, boundary shift, 1<=nb(i)<=N-1,
% BC{i} - nb(i) x 1, conections between polyhedron 'i' and other polyhedra.
% BC{i}(a)==j => polyhedron 'i' and polyhedron 'j' have common (n-1)
% dimensional boundary. I don't count (n-2) and less dimensional
% faces as conections !!!
% PC{i} - nb(i) x 1, position of corresponding boundary in connected polyhedron
% boundary list.
%
%
% (C) 2000 by M. Baotic, Zurich, 05/12/00
% Version 1.6
% contact baotic@aut.ee.ethz.ch
%
% Take care that the list of boundary conections is complete!
%
% | |
% A | | B
% ____\/____ <--- ONE constraint on C can corespond to TWO neighbors
%
% C
% __________
EPSILON=1000*eps;
%%%%%%%%%%%%%%%%%%
% INITIALIZATION %
%%%%%%%%%%%%%%%%%%
N = length(Hi); % number of polyhedra
n = size(Hi{1},2); % number of states
nb = zeros(N,1); % number of boundaries trough all polyhedra
BC = {}; % boundary conections list
%%%%%%%%%%%%%%%
% CHECK SIZES %
%%%%%%%%%%%%%%%
if N<1,
error('Number of polyhedra must be grater than zero!')
end
for i=1:N,
[nb(i),aux2]=size(Hi{i});
if aux2~=n,
error('Number of states must be the same for all polyhedra!')
end
if nb(i)==0,
error('Polyhedron must have at least one facet!')
end
%if nb(i)>N-1
% error('Polyhedron can not have more facets than neighbors!')
%end
[aux1,aux2]=size(Ki{i});
if aux1~=nb(i) | aux2~=1
error('Wrong size of vector Ki!')
end
end
% more init
for i=1:N,
BC{i}=zeros(nb(i),1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NORMALIZE BOUNDARIES EQUATIONS %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:N
% Use: Euclidean norm
% better performance during later (possible)
% checking of distance from a boundary
norm = sqrt(sum((Hi{i}.*Hi{i})'));
% Optional: Infinity norm
% norm = max((abs(Hi{i}))');
if min(norm) == 0,
error('There is at least one badly defined polyhedron boundary!')
end
for j = 1:nb(i),
Hi{i}(j,:) = Hi{i}(j,:) / norm(j);
Ki{i}(j) = Ki{i}(j) / norm(j);
end
end
%%%%%%%%%%%%%%%%%
% BUILD BC LIST %
%%%%%%%%%%%%%%%%%
for i=1:N, % through all polyhedra
for j=1:nb(i), % through all boundaries
found=0;
for r=1:N,
if r~=i,
for s=1:nb(r),
aux1 = sum(abs(Hi{i}(j,:)+Hi{r}(s,:)));
aux2 = abs(Ki{i}(j)+Ki{r}(s));
if (aux1 < EPSILON) & (aux2 < EPSILON), % candidate (+/- tolerance)
%if AreNeighbors(i,j,r,s),
% found=1;
% BC{i}(j)=r;
%end
found=1;
BC{i}(j)=r;
break;
end
end
if found==1,
break;
end
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -