copy

Purpose

Create a copy of an object derived from the ConvexSet class.

Syntax

Snew = S.copy
Snew = copy(S)

Description

Create a copy of a set S and return a new object Snew with same properties as the original set. Changing one object does not affect the second one because the objects are not connected by reference.

Note that this method is different versus the equality assignment Snew = S which points to the same object. See the example for explanation.

Input Arguments

S

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

Class: ConvexSet

Output Arguments

Snew

New object which is an exact copy of the set S.

Class: ConvexSet

Example(s)

Example 1

Create a random polyhedron in V-representation.
 P=ExamplePoly.randVrep 
Polyhedron in R^2 with representations:
    H-rep               : Unknown (call computeHRep() to compute)
    V-rep (redundant)   : Vertices  10 | Rays   0
Functions : none
Create a new object Pnew that is a copy of the set P.
 Pnew = P.copy 
Polyhedron in R^2 with representations:
    H-rep               : Unknown (call computeHRep() to compute)
    V-rep (redundant)   : Vertices  10 | Rays   0
Functions : none
If we do any change on the new polyhedron Pnew, this will not affect the original polyhedron. For instance, we can convert it to H-representation:
 Pnew.H; 

 Pnew.hasHRep 
ans =

     1

The original polyhedron P remains in V-representation
 P.hasHRep 
ans =

     0

The different story is when a new object is a reference of the original set. This is achieved by equality assignment:
 Q = P; 
 When the polyhedron Q is changed, this also affects the original polyhedron 
 Q.H; 

 Q.hasHRep 
ans =

     1

 P.hasHRep 
ans =

     1

See Also

yset, polyhedron


© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk

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