New features of GBT 7.3
GBT 7.3 can compute with sets of nonconvex polytopes, which form a single object and can be referred to by a single name. Operations of union, intersection, volume (in 3D) and area (in 2D) computations are available. The new routines are an add on to GBT 7.1 and to distinguish them from routines which act only on convex polytopes, the new routine names are ended with '_'.
All routines with names ending by '_' work both with convex and nonconvex polytopes. The new routines are not standalone, they call existing GBT 7.1 routines. The most important new routines are:
defpoly_ - allows to define a set of nonconvex polytopes (in 2D,3D, 4D, etc.) which is the set difference of two sets of unions of convex polypes.
Usage: P=defpoly(Pplus,Pminus) where Pplus and Pminus are cell arrays of polytopes in a format as in GBT 7.1 . P is the new nonconvex polytope which is the set difference of the unions of polytopes in Pplus and Pminus. defpoly_ calls the auxiliary routine simplify_ to make the representation of the set of nonconvex polytopes more efficient.
polvol_ - allows the computation of the volumes (in >3D) and the area (in 2D) of polytopes and polygons.
Usage: vol=polvol_(P) where P is a set of nonconvex polytopes. If called by vol=polvol_(P,nodiv) then a uniform grid with nodiv number of divisions in each dimension is used to simplify the complexity of the volume computation. This works for 2D, 3D, 4D, ... .
union_ - allows the computation of the union of sets of nonconvex polytopes.
Usage: P=union_(P1,P2) where P1 and P2 are sets of nonconvex polytopes. This works for any dimension (2D, 3D, 4D, ...).
intersec_ - allows the computation of the intersection of sets of nonconvex polytopes.
Usage: P=intersec_(P1,P2) where P1 and P2 are sets of nonconvex polytopes.
perimeter_ - allows the computation of the perimeter length of a set of nonconvex 2D polygons.
Usage: length=perimeter_(P) where P is a set of non-convex polygons.
view2d_ - allows the display of 2D sets of noncovex polytopes or their projections onto 2D planes spanned by pairs of orthogonal coordinate axes.
Usage: axout=view2d_(P,a,c,axin); where P is a set of nonconvex polytopes, a indices of pairs of orthogonal axes for projection, c colour of the patch showing the set of nonconvex polygons, axin axis handle to be used to produce the plot, axout axis handle of plot produced.
Examples of these operations are illustrated on the following figures ("demo12" in the package):



The code to produce these figures is the following (file demo12.m on the disk):
% Definition of first random nonconvex set P1:
P1=cell(0,2); N=8; n=2;
for i=1:N,
offset=rand(1,n)*1;
V=rand(N,n)+ones(N,1)*offset;
Pi=convh(V);
z=rand(1); if z>0.1, P1=[P1;{Pi,'+'}];else P1=[P1;{Pi,'-'}];end;
end;
disp('The randomly generated area of P1 is displayed:');figure(1);
view2d_(P1,[1,2],'y');axis equal
title(['Area of P1 is ',num2str(polvol_(P1)),' km^2']);
% Definition of second random nonconvex set P2:
P2=cell(0,2);
for i=1:N,
offset=rand(1,n)*1;
V=rand(N,n)+ones(N,1)*offset;
Pi=convh(V);
z=rand(1); if z>0.1, P2=[P2;{Pi,'+'}];else P2=[P2;{Pi,'-'}];end;
end;
disp('The randomly generated area of P2 is displayed:'); figure(2);
view2d_(P2,[1,2],'b');axis equal
title(['Area of P2 is ',num2str(polvol_(P2)),' km^2']);
% Computing the intersection:
Pi=intersec_(P1,P2);
figure(3);ax1=view2d_(P1,[1,2],'y');
view2d_(P2,[1,2],'b',ax1);
view2d_(Pi,[1,2],'g');axis equal title(['Area of P1 and P2 intersection is ',num2str(polvol_(Pi,20)),' km^2']);
% Computing the union:
Pu=union_(P1,P2);
figure(4);ax2=view2d_(P1,[1,2],'y');
view2d_(P2,[1,2],'b',ax2);
view2d_(Pu,[1,2],[0.7 0.7 0.7],ax2);axis equal
title(['Area of P1 and P2 union is ',num2str(polvol_(Pu,20)),' km^2']);
Note that each run of demo12 produces different random nonconvex areas on which it computes the union, intersection and areas.
About | Authors | Contact