grid

Purpose

Grid the convex set.

Syntax

x = grid(Set, N)
x = Set.grid(N)

Description

Gridding of the convex Set with respect to N linearly scaled gridding points. The output x consist of points sorted vertically that belonging to the Set. The principle of the algorithm is as follows:
  1. Compute outer bounding hypercube.
  2. Grid the hypercube.
  3. Test each point for inclusion in the set, discarding those outside.
Before running the algorithm, consider the number N of gridding points. If this number is very large then it takes algorithm longer to grid the space because an exhaustive search is done at the last step of the algorithm.

Input Arguments

Set

Any object derived from the ConvexSet class, e.g. Polyhedron, YSet, ...

Class: ConvexSet

N

The number of gridding point. It specifies with how many elements to scale the interval equidistantly.

Output Arguments

x

An array of points sorted vertically. The number of columns specifies the dimension.

Class: double

Example(s)

Example 1

The set is given as intersection of two sets.
 x = sdpvar(2,1);  

 F = [x(1)-x(2)<=1; 0.3*x'*x <= 0.5]; 

 Y = YSet(x,F); 
 Grid the set with 40 gridding points (can take some time). 
 x = Y.grid(30); 
 Plot each point 
 plot(x(:,1),x(:,2),'x','MarkerSize',7) 

../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/grid_img_1.png

Example 2

We have two polyhedra that intersect
 P(1) = Polyhedron('A',[1 -0.3; 0.5 0.7],'b',[2.3;3.1],'lb',[1;0.4]); 

 P(2) = Polyhedron('A',[1.6 -0.6; 0.2 0.4],'b',[2.1;2.8],'lb',[1.5;0.9]); 
 Plot the sets 
 P.plot 

../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/grid_img_2.png

Find the intersection and grid it
 Q = intersect(P(1),P(2)); 

 x = Q.grid(40); 
 Plot the grid points of the intersection 
 plot(x(:,1),x(:,2),'o','Color','r');axis([1 3.5 0 7]); 

../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/grid_img_3.png

See Also

plot, fplot, contains


© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch