# Compute the intersection of convex sets in Matlab

I'm aware of a Matlab function which take a set of point as an input and select the points which compose the convex hull.

Exemples from Mathworks website :

xx = -1:.05:1;
yy = abs(sqrt(xx));
[x,y] = pol2cart(xx,yy);
k = convhull(x,y);
plot(x(k),y(k),'r-',x,y,'b*')


Now, my question is : does there exists a Matlab function or what could be the method to follow in order to compute the intersection of two convex sets defined by the set of points of their convex hull ?

• I don't understand. Do you want the intersection of two sets, or the convex hull of two sets? Apr 16 '15 at 12:57
• The intersection of the two sets.
– Tanj
Apr 16 '15 at 13:18

Let the $x$-coordinates for the points in the convex hull of the first convex region be stored in the array x1, and let the $y$-coordinates of those same points be stored in the array y1. Let the arrays x2 and y2 store analogous information for the second convex region.
If you have MATLAB's Mapping Toolbox, you can use the polybool function to return the coordinates of a polygonal approximation of the intersection of your two regions via [x, y] = polybool('intersection', x1, y1, x2, y2). I'm not familiar with the algorithm behind the function, so I can't comment on that.
There is a polygon_intersection script on the Matlab file exchange which will compute the intersection of one or more polygons. In your case the convex hulls of your two sets are the polygons you wish to intersect.