distance

Purpose

Computes the closest distance between the convex set and given point.

Syntax

ret = distance(Set,x)
ret = Set.distance(x)

Description

Compute the closest distance between the convex Set and given point x The approach is based on solving the optimization problem

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

where ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/distance1.png is the given point in the same dimension as the set and ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/distance2.png is the point inside the Set. If the optimization terminated successfully, the output contains the distance ret.d and the points ret.y, ret.x. Otherwise, the output is empty. If the Set is an array of convex sets, the distance and the point y are returned in a cell arrays.

Input Arguments

Set

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

Class: ConvexSet

x

A point given as a real vector with the same dimension as the convex set.

Class: double

Output Arguments

ret

Structure that contains the information about the computed distance and the points ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/distance3.png, ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/distance4.png.

Class: struct

ret.exitflag

Termination status from the related optimization problem.

Class: double

ret.dist

Distance between the point x and the convex Set.

Class: double

ret.y

The point that is contained in the convex Set and is closest to x.

Class: double

ret.x

The point x that was provided.

Class: double

Example(s)

Example 1

Construct a convex set by intersecting a circle and random linear inequalities. Define variable first
 z = sdpvar(2,1); 
 Define a set S using YSet class  
 options = sdpsettings('solver','sedumi','verbose',0); 

 S = YSet(z, [norm(z)<=1; randn(2)*z<=0.5*ones(2,1)], options); 
 Compute the distance to a point [-5;8] 
 x = [-5; 8];

 d = S.distance(x)
d = 

    exitflag: 1
        dist: 8.43398113093422
           x: [2x1 double]
           y: [2x1 double]

We can plot the set and the points x, y
 S.plot('alpha',0.5,'color','green'); 
              hold on;  text(x(1),x(2),'x');
              axis([-3 2 -2 3]); text(d.y(1),d.y(2),'x');
        
Plotting...
27 of 40

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

See Also

outerapprox, support, separate


© 2010-2013 Colin Neil Jones: EPF Lausanne, colin.jones@epfl.ch

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