# Phi-Functions for 2D Objects Formed by Line Segments and Circular Arcs

Authors: N. Chernov; Yu. Stoyan; T. Romanova; A. Pankratov
Journal: Advances in Operations Research
 (2012)

---

## Abstract

We study the cutting and packing (C&P) problems in two dimensions by using phi-functions. Our phi-functions describe the layout of given objects; they allow us to construct a mathematical model
in which C&P problems become constrained optimization problems. Here we define (for the first time) a complete class of basic phi-functions which allow us to derive phi-functions forall 2D objects that are formed by linear segments and circular arcs. Our phi-functions support translations and rotations of objects. In order to deal with restrictions on minimal or maximal distances between objects, we also propose adjusted phi-functions. Our phi-functions are expressed by simple linear and quadratic formulas without radicals. The use of radical-free phi-functions allows us to increase efficiency of optimization algorithms. We include several model examples.


---

## Body

## 1. Introduction

We study the cutting and packing (C&P) problems. Its basic goal is to place given objects into a container in an optimal manner. For example, in garment industry one cuts figures of specified shapes from a strip of textile, and one naturally wants to minimize waste. Similar tasks arise in metal cutting, furniture making, glass industry, shoe manufacturing, and so forth. In shipping works one commonly needs to place given objects into a container of a smallest size or volume to reduce the space used or increase the number of objects transported.The C&P problem can be formally stated as follows: place a set of given objectsA1,…,An into a container Ω so that a certain objective function (measuring the “quality” of placement) will reach its extreme value.In some applications (as in garment industry) objects must be specifically oriented respecting the structure of the textile, that is, they can only be translated without turnings (or only slightly rotated within given limits). In other applications objects can be freely rotated. Some applications involve additional restrictions on the minimal or maximal distances between certain objects or from objects to the walls of the containerΩ (one example is packing of radioactive waste).While most researchers use heuristics for solving C&P problems, some develop systematic approaches based on mathematical modeling and general optimization procedures; see, for example, [1–3]. We refer the reader to recent tutorials [4, 5] presenting the history of the C&P problem and basic techniques for its solution.Standard existing algorithms are restricted to 2D objects of polygonal shapes; other shapes are simply approximated by polygons (a notable exception is [6] which also treats circular objects). The most popular and most frequently cited tools in the modern literature on the C&P problem are Minkowski sum [7] and the so-called No-Fit Polygon [4], which works with polygons only and does not support rotations. Rotations of polygons were considered in [8, 9], and in a very recent paper [10] the concept of No-Fit Polygon was extended to objects bounded by circular arcs.In this paper we develop tools that handle any 2D objects whose boundary is formed by linear segments and/or circular arcs (the latter may be convex or concave). All objects we had to deal with in real applications, without exception, belong to this category. Our tools support free translations and rotations of objects and can respect any restrictions on the distances between objects.We describe the layout of objects relative to each other by the so-calledphi-functions. For any placement of two objects Ai and Aj on the plane ℝ2, the corresponding phi-function ΦAiAj shows how far these objects are from each other, whether they touch each other, or whether they overlap (in the latter case it shows how large the overlap is). Phi-functions were introduced in [11–13] and fully described in our recent survey [14]. Phi-functions are also used for solving 3D packing problems [15] and covering problems [16].The arguments of the phi-functionΦAiAj are the translation and rotation parameters of the objects Ai and Aj; those parameters specify the exact position and orientation of the objects in the xy plane (or in the xyz space). All these parameters together, for all the given objects, constitute the solution space. Solving the cutting and packing problem then consists of minimization of a certain objective function defined on the solution space.Thus the solution of the C&P problem reduces to minimization of an objective function on a certain (multidimensional) space, which can be done by mathematical programming. A detailed description of the solution strategy is given in [14]. We emphasize that the minimization is performed with respect to all of the underlying variables, that is, all the objects can move and rotate simultaneously. In this respect our approach differs from many others that optimize the position of one object at a time. Illustrations and animated demonstrations of the performance of our methods can be found on our web page [17].The solution space consists of all admissible (nonoverlapping) positions of our objects, which correspond to inequalitiesΦAiAj≥0 for all i≠j. Our phi-functions ΦAiAj are defined by a combination of minima and maxima of various basic functions that represent mutual position of various elements of the underlying objects (their edges, their corner points, etc.) As a result, the solution space is described by a complicated tree in which each terminal node consists of a system of inequalities involving translation and rotation parameters of certain objects. This description is very complex, and one of our goals is to simplify it.The above-mentioned inequalities may be expressed via distances between various points, segments, and arcs on the boundaries of our objects. The resulting formulas often involve square roots, which may cause unpleasant complications—formulas describing the solution space develop singularities, and the minimization process becomes prohibitively slow.To remedy the situation, we redefine the phi-functions so that the solution space will be described by simpler formulas without radicals (thus avoiding related singularities), This speeds up the optimization process. By our rules, phi-functions only need to satisfy certain flexible requirements, they are not rigidly determined by the shapes of the given objects. In fact, one can often define phi-functions for fairly complicated objects by simple formulas that avoid square roots and other irrational functions.This strategy was employed in our previous works [14], but here we implement it to an utmost extent. We will show that for any objects bounded by linear segments and circular arcs phi-functions can be defined by algebraic formulas without radicals. This is the principal goal of our paper. It was announced in [14] without much details. Here we give explicit practical formulas for computing the phi-functions in all possible cases. Our radical-free phi-functions also incorporate additional constraints on the distances between objects (see Section 4).We demonstrate the efficiency of our new phi-functions by model examples. For the description of the solution space via phi-functions we refer the reader to [14]. For further details of local optimization algorithms used in our programs we refer the reader to [18].


## 2. Phi-Functions and Decomposition of Objects

Recall that a 2D object is a subsetA⊂ℝ2; it is usually specified by some equations or inequalities in the canonical coordinates x,y. Placing the object in ℝ2 means moving it without changing its shape or size. Rigid motions in ℝ2 consist of rotations and translations. If we rotate A by angle θA (say, clockwise) and translate it by vector νA=(νAx,νAy), then the resulting set (placed object) can be described by equation(2.1)A(νA,θA)=RθAA+νA,
where(2.2)Rθ=[cos⁡θsin⁡θ-sin⁡θcos⁡θ]
denotes the standard rotation matrix. We call νA and θA the placement parameters for the object A.Now letA,B⊂ℝ2 be two objects. We denote the corresponding placed objects by A′=A(νA,θA) and B′=B(νB,θB). The phi-function(2.3)Φ=ΦAB=ΦAB(νA,θA,νB,θB),
describes the mutual position (interaction) of the pair of sets A′ and B′. It must satisfy three basic requirements:(2.4)Φ>0ifA′∩B′=∅,Φ=0ifint⁡(A′)∩int⁡(B′)=∅and∂A′∩∂B′≠∅,Φ<0ifint⁡(A′)∩int⁡(B′)≠∅.
Here int(A′) denotes the interior of A′ and ∂A′ the boundary (frontier) of A′. We always assume that our objects are canonically closed sets, that is, each object is the closure of its interior. Also, the boundary ∂A′ should not have self-intersections [11, 14].Note thatΦAB is a function of six real variables νAx,νAy,θA,νBx,νBy,θB. An important requirement is that ΦAB is continuous in all these six variables [14]. We will also assume that ΦAB is “symmetric” in the sense that(2.5)ΦAB(νA,θA,νB,θB)=ΦBA(νB,θB,νA,θA)
and translation invariant, that is, for any vector ν(2.6)ΦAB(νA,θA,νB,θB)=ΦAB(νA+ν,θA,νB+ν,θB).
Our phi-functions are also rotation invariant in a natural sense. In our formulas, the superscripts of Φ will always refer to given objects, while the arguments of Φ (the placement parameters) will be often omitted for brevity.The general meaning of (2.4) is that when the placed objects are disjoint, that is, a positive distance apart, then Φ>0. When those objects just touch each other (on their boundaries), but do not overlap, then Φ=0. When they overlap, then Φ<0.We emphasize that the exact value of the phi-function is not subject to any rigid constraints. If two placed objectsA′ and B′ are disjoint, then Φ should just roughly approximate the distance between them. If they overlap, then the absolute value |Φ| should just roughly measure the extent of overlap. This flexibility allows us to construct relatively simple phi-functions for rather complex objects, which is the main goal of our paper.For example, letC1 and C2 be two circles (disks) of radii r1 and r2, respectively, defined by(2.7)Ci={(x,y):x2+y2≤ri2}.
Now by translating C1 and C2 through some vectors ν1 and ν2, we get two placed circles C1′ and C2′ with centers (ν1x,ν1y) and (ν2x,ν2y), respectively, and the same radii r1 and r2 (rotations are redundant for circles). Now the distance between C1′ and C2′ is d=max{ϕ,0}, where(2.8)ϕ=(ν1x-ν2x)2+(ν1y-ν2y)2-(r1+r2).
Note that ϕ>0 if the circles are disjoint and ϕ<0 if they overlap, thus we could set ΦC1C2=ϕ. But we define ΦC1C2 differently:(2.9)ΦC1C2=(ν1x-ν2x)2+(ν1y-ν2y)2-(r1+r2)2.
Note that the sign of ΦC1C2 coincides with that of ϕ (and ΦC1C2=0 whenever ϕ=0). But the formula (2.9) allows us to avoid radicals, thus improving the performance of our optimization algorithms.Next suppose(2.10)A=A1∪⋯∪Ap,B=B1∪⋯∪Bq
are two objects, each of which is a union of some smaller (and simpler) components Ai and Bj, respectively. Those do not have to be disjoint, that is, some Ai’s may overlap, and so may some of the Bj’s. When the object A is rotated and translated, all its parts are rotated by the same angle and translated through the same vector, so the placement parameters for A and for all its parts Ai are the same. This applies to B and its parts, too.Now we can define(2.11)ΦAB=min⁡1≤i≤pmin⁡1≤j≤qΦAiBj.
This simple fact can be verified by direct inspection, see also [11, 14].In this paper we consider objects whose boundary is formed by linear segments and/or circular arcs (the latter may be convex or concave); see an example in Figure1. Such objects can be partitioned into simpler components of four basic types: (a) convex polygons, (b) circular segments, (c) “hats”, and (d) “horns”; see Figure 2.Figure 1
A partition of an object into 15 basic objects: 8 convex polygons, 3 circular segments (marked byD), 3 hats (marked by H), and one horn (marked by V).Basic objects: (a) convex polygonK, (b) circular segment D, (c) hat H, and (d) horn V.
(a)(b)(c)(d)A convex polygon is an intersection ofm≥3 half-planes. More generally, an intersection of m≥1 half-planes will be called a generalized convex polygon, or phi-polygon. It may be a regular (bounded) polygon, or an unbounded region, such as a region between two rays (half-lines) emanating from a common vertex (see illustrations in [11]).A circular segment is a region bounded by a circular arc (smaller than a semicircle) and the respective chord. One can also describe a circular segment as the convex hull of a circular arc. Ahat is formed by a circular arc (smaller than a semicircle) and two tangent lines at its endpoints (Figure 2(c)). A horn is made by two circular arcs (one convex and one concave) that are tangent to each other at the point of contact and a line crossing both arcs and tangent to the concave one (Figure 2(d)). We will denote these four types by K, D, H, and V, as in Figure 2.Figure1 shows a division of an object into basic subobjects. It consists of 8 convex polygons, 3 circular segments, 3 hats, and one horn.Decomposition of a given object into basic subobjects can be done by a computer algorithm based on the following steps.(1)
Locate “beaks,” that is, points on the boundary ofA where two arcs (one concave and one convex) terminate with a common tangent line. At each beak, cut off a small piece that is shaped as a horn (by a line tangent to the concave arc). After the detachment of horns, the resulting object will have no beaks.(2)
Locate all concave arcs and carve out hats so that each concave arc will be replaced with a polygonal line. After the detachment of hats, the resulting object will have no concave arcs.(3)
Locate all convex arcs and cut off circular segments so that each convex arc will be replaced with one or more chords. After the detachment of segments, the resulting object will have no convex arcs.(4)
If the resulting phi-polygon is convex, keep it. If not, decompose it into two or more convex ones.We note that if the given objectA is simple enough, it may not be necessary to divide it into basic objects. For example, if A is a circle (or a ring), there is no need to cut it artificially into some polygons and circular segments, as phi-functions for circles (and rings) are quite simple; see (2.9) and other formulas below, as well as [11–13].Next, recall that our basic goal is to place given objectsA1,…,An into a container Ω with respect to a given objective. To ensure that the placed objects Ai(νAi,θAi) do not overlap, we can just verify that ΦAiAj≥0 for all i≠j. To ensure that Ai(νAi,θAi)⊂Ω, we verify that ΦAiΩ*≥0, where Ω*=cl(ℝ2∖Ω) is the closure of the complement to the container Ω. This is a part of our optimization algorithm; see [14].The necessity of treatingΩ*=cl(ℝ2∖Ω) as a (rather special) object leads us to considering unbounded objects, too. Given a bounded object B, we denote by B*=cl(ℝ2∖B) the unbounded complementary object. If B* is delimited by line segments and circular arcs, then it can be decomposed into basic objects of the same four types, except one or more basic objects are unbounded phi-polygons as described above.


## 3. Basic Phi-Functions

Due to the decomposition principle (2.11) our problem reduces the construction of phi-functions for all pairs of basic objects. As there are four types of basic objects, there are a total of 4+(42)=10 possible pairs of types of basic objects to treat. These will form a complete class of basic phi-functions.


### 3.1. Two Convex Polygons

A convex polygon is an intersection of several half-planes. A half-plane can be defined byαx+βy+γ≤0 so it is completely specified by three parameters (α,β,γ). Without loss of generality we assume in what follows that α2+β2=1. A convex polygon (phi-polygon) K that is the intersection of m half-planes can be specified by(3.1)K=((α1,β1,γ1),…,(αm,βm,γm)).
Alternatively, K can be specified by a sequence of vertices(3.2)K=((x1,y1),…,(xm,ym))
listed in the counterclockwise direction. If the polygon K is moved (rotated and translated), its parameters αi,βi,γi and xi,yi can be recomputed in terms of the rotation angle θK and translation vector νK, according to (2.1). Thus the placement parameters of K can be incorporated into αi,βi,γi, and xi,yi.Now letK be a convex m-gon and K′ another convex m′-gon whose parameters we denote by (αi′,βi′,γi′) and whose vertices are denoted by (xi′,yi′) for 1≤i≤m′. Denote(3.3)uij=αixj′+βiyj′+γi,vji=αi′xj+βi′yj+γi′.
Now we define the “polygon-polygon” phi-function as(3.4)ΦKK′=max⁡{max⁡1≤i≤mmin⁡1≤j≤m′uij,max⁡1≤j≤m′min⁡1≤i≤mvji},
see [14] for a detailed analysis of this formula. We note that ΦKK′ does not involve quadratic functions. It is defined by linear expressions only if rotational angles are not used.In particular, ifP is a half-plane defined by αx+βy+γ≤0 and K′ a polygon with vertices (xi′,yi′), then (3.4) takes a much simpler form(3.5)ΦPK′=min⁡1≤j≤m′αxj′+βyj′+γ.


#### 3.1.1. Convex Polygon and Circle

LetK be a convex polygon with sides Ei and vertices (xi,yi) for 1≤i≤m. Let αix+βiy+γi=0 be the equation of the line containing the side Ei. We assume that αi2+βi2=1 and the vertices and sides are numbered counterclockwise and the ith side joins the ith and (i+1)st vertices (if i=m, then we set i+1=1). Let C be a circle with center (xC,yC) and radius rC. Then we define(3.6)ΦKC=max⁡1≤i≤mmax⁡{χi,ψi},ψi=min⁡{ωi,μi},
where χi=αixC+βiyC+γi-rC (see Figure 3(a)), ωi=(xi-xC)2+(yi-yC)2-rC2 (see Figure 3(b)), and μi=(αi-1-αi)(yi-yC)-(βi-1-βi)(xi-xC)+rC(αi-1βi-αiβi-1) (see Figure 3(b)). See [14] for more details.A convex polygon and a circle.
(a)(b)In particular, ifP is a half-plane αx+βy+γ≤0 and C a circle with center (xC,yC) and radius rC, then (3.6) takes a much simpler form(3.7)ΦPC=αxC+βyC+γ-rC.


### 3.2. Convex Polygon and Circular Segment

LetK be again a convex polygon. Let D be a circular segment D=C∩T, where C is a circle and T a triangle made by the chord (the base of the segment) and the two tangents drawn at its endpoints. Now we define(3.8)ΦKD=max⁡{ΦKC,ΦKT},
where ΦKC was defined by (3.6) and ΦKT by (3.4).


### 3.3. Two Circular Segments

LetD=C∩T and D′=C′∩T′ be two circular segments. We define(3.9)ΦDD′=max⁡{ΦCC′,ΦTC′,ΦT′C,ΦTT′},
where ΦCC′ was defined by (2.9), ΦTC′ and ΦT′C by (3.6), and ΦTT′ by (3.4).This takes care of all possible pairs of convex basic objects, that is, types (a) and (b). It remains to deal with concave objects, that is, “hats” and “horns.” We first consider a simple object with a concave arc—the complement to a circle. This case is practically important because in many applications one places objects into a circular container.


#### 3.3.1. Convex Objects inside a Circular Container

LetC* denote the (closure of the) complement to a circle C with center (xC,yC) and radius rC. Now let C′ be a circular object with center (xC′,yC′) and radius rC′≤rC that we want to place inside the circle C. Then we define(3.10)ΦC*C=(rC-rC′)2-(xC-xC′)2-(yC-yC′)2.
If rC′>rC, then we set ΦC*C=-∞.Next letK be a polygon (not necessarily convex) with vertices (x1,y1),…,(xm,ym) that we want to place in our circle C. Then we set(3.11)ΦC*K=min⁡1≤i≤m{rC2-(xi-xC)2-(yi-yC)2}.IfH=T∩C1* is a “hat,” that is, the intersection of a triangle T and the complement to a circle C1 (see Figure 6), we simply put ΦC*H=ΦC*T, where ΦC*T is given by (3.11).Now letD=C′∩T be a circular segment, where C′ is a circle with center (xC′,yC′) and radius rC′ and T a triangle as before, and qi=(xi,yi), i=1,2, the endpoints of the chord bounding D; see Figure 4(a). We put(3.12)ψ0=min⁡i=1,2{rC2-(xi-xC)2-(yi-yC)2},
then(3.13)ΦC*D=ψ0(forrC≤rC′).
Note that ψ0=ΦC*K subject to m=2, see Figure 4(a). Now we define(3.14)ΦC*D=min⁡⁡{ψ0,max⁡{ΦC*C′,φ1,φ2}}(forrC>rC′),
where ψ0 is given by (3.12) and(3.15)φ1=(y1-yC′)(xC′-xC)-(x1-xC′)(yC′-yC),φ2=-(y2-yC′)(xC′-xC)+(x2-xC′)(yC′-yC).NonoverlappingC* and D.
(a)(b)(c)(d)Formula (3.14) results from the following observations: ΦC*D≥0 if ψ0≥0 subject to ΦC*C′≥0 (see Figure 4(b)), or φ1≥0 (Figure 4(c)), or φ2≥0 (Figure 4(d)).To clarify the role of the functionsφ1 and φ2 we introduce vectors e=(xC-xC′,yC-yC′), a1=(x1-xC′,y1-yC′), a2=(x2-xC′,y2-yC′), e1=(-(y1-yC′),x1-xC′), and e2=(y2-yC′,-(x2-xC′)), as shown in Figure 5(a). Note that a1⊥e1 and a2⊥e2. In these notations,(3.16)φ1=〈e,e1〉,φ2=〈e,e2〉.
We call φ1 and φ2 “switch” functions. Note that max{ΦC*C′,φ1,φ2}<0 if ΦC*C′<0 and φ1<0 and φ2<0, see Figure 5(a). However, there exist tree cases, where ΦC*C′<0 but max{ΦC*C′,φ1,φ2}≥0. First, φ1≥0 and φ2<0 (see Figure 5(b)). Second, φ2≥0 and φ1<0 (Figure 5(c)). Lastly, φ1≥0 and φ2≥0 (Figure 5(d)).Role of the functionsφ1, φ2.
(a)(b)(c)(d)Figure 6
The domainG (grey) and three triangles T, T1, and T2.


### 3.4. Polygon and Hat

LetH=T∩C* be a hat, that is, the intersection of the complement to a circle C and a triangle T as shown in Figure 6. Let G denote the domain lying above the circle C and above the line L containing the chord forming the base of the triangle T; see the grey area in Figure 6. Note that H=G∩T.Now ifB is any convex object, then it overlaps with H if and only if it overlaps with both T and G; hence, we can define the phi-function as(3.17)ΦHB=max⁡{ΦTB,ΦGB}
provided we have properly defined ΦTB and ΦGB. This formula applies when B is either a convex polygon or a circular segment. In these two cases ΦTB is given by either (3.4) or (3.8), respectively. Thus it remains to define function ΦGB. Here we assume that B is a convex polygon.LetT1 and T2 denote two triangles adjacent to T; one side of each is a tangent to the circle C, and another side of each is a segment of the line L adjacent to the chord; see Figure 6 (the choice of the third side is not important). Let the circle C have center (xC,yC) and radius rC. Let the half-plane P below the line L be defined by inequality αPx+βPy+γP≥0. Note that G=(C∪P)*=C*∩P*.Now letK be any polygon (not necessarily convex) with vertices (x1,y1), …, (xm,ym). Note that K does not overlap with G if and only if two conditions are met: (i) every vertex (xi,yi) lies either in the circle C or below the line L; (ii) the polygon K does not overlap with T1 and T2. Accordingly, we define(3.18)ΦGK=min⁡{ΦT1K,ΦT2K,Ψ},
where(3.19)Ψ=min⁡1≤i≤mmax⁡{rC2-(xC-xi)2-(yC-yi)2,αPxi+βPyi+γP}.
Therefore,(3.20)ΦHK=max⁡{ΦTK,ΦGK},
which completes the analysis of the “polygon-hat” pair.


### 3.5. Circular Segment and Hat

LetH=T∩C*=T∩G be a hat as before and D a circular segment. The above analysis applies, up to the formula (3.17), because D is a convex object. It remains to define ΦGD.We again use the notationsP,C, and so forth, for objects associated with the hat H, as defined above. We denote by p1=(x1,y1) and p2=(x2,y2) the endpoints of the arc bounding H, as shown in Figure 8, that is, the points of intersection of ∂C with ∂P=L. The point pi=(xi,yi) is a vertex of the triangle Ti for i=1,2.The circular segmentD=C′∩T′ is the intersection of a circle C′ and a triangle T′, as before. Let rC′ denote the radius of the circle C′ and (xC′,yC′) its center. Let q1=(x1′,y1′) and q2=(x2′,y2′) denote the endpoints of the chord bounding D (as shown in Figure 4) and L′ the line passing through these points. Let the half-plane P′ below the line L′ (away from D) be defined by inequality α′x+β′y+γ′≥0. Note that D=C′∩(P′)*.IfrC′>rC, then we set(3.21)ΦGD=max⁡{ΦP*T′,ΦC*D,ΦGC′,φ1,φ2},
where ΦP*T′ is defined by (3.5), ΦC*D by (3.14), and for i=1,2 we set(3.22)φi=min⁡{ΦT3-iD,rC2-(xi′-xC)2-(yi′-yC)2,α′xi+β′yi+γ′,-(α′x3-i+β′y3-i+γ′)ΦT3-iD}.
Thus, ΦGD≥0 if ΦP*T′≥0 (see Figure 7(a)) or ΦC*D≥0 (see Figure 7(b)) or ΦGC′≥0 (see Figure 7(c)), φ1≥0 (see Figure 7(d)) or φ2≥0 (see Figure 7(e)).A circular segmentD versus the region G.
(a)(b)(c)(d)(e)Figure 8
The linesL1 and L2 for a segment-hat pair.The functionΦGC′ in (3.21) is defined as follows:(3.23)ΦGC′=max⁡{ΦC*C′,ΦP*C′,min⁡{ω1,ψ1,ω2,ψ2}},
where ΦC*C′ was defined by (3.10) and ΦP*C′ by (3.7). We also denote(3.24)ωi=(xi-xC′)2+(yi-yC′)2-rC′2
for i=1,2, and the functions ψ1,ψ2 are defined so that ψi=0 is the equation of the line Li (see Figure 8), and ψi≥0 is the half-plane below that line in Figure 8. The line Li passes through points pi1 and pi2. The line segment pipi1, i=1,2, is perpendicular to the line p1p2, the line segment pipi2 is perpendicular to the line pip3, and we have ∥pipij∥=rC′ for all i,j=1,2. The functions ψi, i=1,2, come from the application of (3.6) to Ti and C′.IfrC′≤rC, we need to replace φi, i=1,2, in (3.21) with φi′ defined by(3.25)φi′=min⁡{φi,α′(xC′-xC)+β′(yC′-yC)}.Finally, combining (3.17) and (3.21) gives(3.26)ΦHD=max⁡{ΦTD,ΦGD}.
Indeed, ΦHD≥0 if ΦTD≥0 (see Figure 9(a)) or ΦGD≥0 (see Figure 9(b)).A hatH and a circular segment D.
(a)(b)


### 3.6. Two Hats

LetH′=G′⋂T′ be a hat and H′′=G′′⋂T′′ another hat. Equivalently, H′=(C′)*⋂T′ and H′′=(C′′)*⋂T′′. For the hat H′ we use notation G′,C′,T′, and so forth, as defined above, and for the hat H′′ the respective notation G′′,C′′,T′′, and so forth. Now our phi-function is defined by(3.27)ΦH′H′′=max⁡{ΦT′H′′,ΦG′T′′,ω,τ},
where ΦT′H′′, ΦG′T′′ are given by (3.17), (3.18), respectively, and we denote(3.28)ω=min⁡{(yC′′-y1′)2α2′x1′′+β2′y1′′+γ2′,α2′′x1′+β2′′y1′+γ2′′,(rC′)2-(xC′-x3′′)2-(yC′-y3′′)2,(rC′′)2-(xC′′-x3′)2-(yC′′-y3′)2},τ=min⁡{(yC′′-y1′)2α1′x3′′+β1′y3′′+γ1′,α1′′x3′+β1′′y3′+γ1′′,(rC′)2-(xC′-x1′′)2-(yC′-y1′′)2,(rC′′)2-(xC′′-x1′)2-(yC′′-y1′)2},
where (xi′,yi′) are the coordinates of the vertices and αi′x+βi′y+γi′=0, i=1,2, are the equations of lines containing the two straight sides of H′, respectively; (xC′,yC′) and rC′ are the coordinates of the center and the radius of the arc bounding H′. Similar notation applies to the hat H′′.The hatsH′ and H′′ do not overlap if ΦT′H′′≥0 (see Figure 10(a)), or ΦG′T′′≥0 (Figure 10(b)), or ω≥0 (Figure 10(c)), or τ≥0 (Figure 10(d)).Four cases of nonoverlapping hatsH′ and H′′.
(a)(b)(c)(d)


### 3.7. Horns

A hornV=H∩(D∪T) is the intersection of a hat H and the union of a circular segment D and a triangle T; see Figure 11, where the triangle T has vertices p1,p2,p3, and the hat H has vertices p1,p2,p4.Figure 11
A hornV (grey) and the respective hat H (with vertices p1,p2,p4), circular segment D, and triangle T (with vertices p1,p2,p3).Now for any convex polygonK we define(3.29)ΦVK=max⁡{ΦHK,min⁡{ΦKD,ΦKT}}.
Similarly, for any circular segment D′,(3.30)ΦVD′=max⁡{ΦHD′,min⁡{ΦDD′,ΦTD′}}
and for any hat H′(3.31)ΦVH′=max⁡{ΦHH′,min⁡{ΦH′D,ΦH′T}}.
Now let V′=H′∩(D′∪T′) be another horn. Then we define(3.32)ΦVV′=max⁡{ΦHH′,min⁡⁡{ΦHD′,ΦHT′},min⁡⁡{ΦH′D,ΦH′T},min⁡⁡{ΦDD′,ΦTT′,ΦTD′,ΦT′D}}.Some formulas for the phi-functions may appear quite complex. Note, however, that they all can be programmed off-line and stored in a computer library. In practical applications, one can just call the respective functions, and their evaluation proves to be fast and efficient.


## 3.1. Two Convex Polygons

A convex polygon is an intersection of several half-planes. A half-plane can be defined byαx+βy+γ≤0 so it is completely specified by three parameters (α,β,γ). Without loss of generality we assume in what follows that α2+β2=1. A convex polygon (phi-polygon) K that is the intersection of m half-planes can be specified by(3.1)K=((α1,β1,γ1),…,(αm,βm,γm)).
Alternatively, K can be specified by a sequence of vertices(3.2)K=((x1,y1),…,(xm,ym))
listed in the counterclockwise direction. If the polygon K is moved (rotated and translated), its parameters αi,βi,γi and xi,yi can be recomputed in terms of the rotation angle θK and translation vector νK, according to (2.1). Thus the placement parameters of K can be incorporated into αi,βi,γi, and xi,yi.Now letK be a convex m-gon and K′ another convex m′-gon whose parameters we denote by (αi′,βi′,γi′) and whose vertices are denoted by (xi′,yi′) for 1≤i≤m′. Denote(3.3)uij=αixj′+βiyj′+γi,vji=αi′xj+βi′yj+γi′.
Now we define the “polygon-polygon” phi-function as(3.4)ΦKK′=max⁡{max⁡1≤i≤mmin⁡1≤j≤m′uij,max⁡1≤j≤m′min⁡1≤i≤mvji},
see [14] for a detailed analysis of this formula. We note that ΦKK′ does not involve quadratic functions. It is defined by linear expressions only if rotational angles are not used.In particular, ifP is a half-plane defined by αx+βy+γ≤0 and K′ a polygon with vertices (xi′,yi′), then (3.4) takes a much simpler form(3.5)ΦPK′=min⁡1≤j≤m′αxj′+βyj′+γ.


### 3.1.1. Convex Polygon and Circle

LetK be a convex polygon with sides Ei and vertices (xi,yi) for 1≤i≤m. Let αix+βiy+γi=0 be the equation of the line containing the side Ei. We assume that αi2+βi2=1 and the vertices and sides are numbered counterclockwise and the ith side joins the ith and (i+1)st vertices (if i=m, then we set i+1=1). Let C be a circle with center (xC,yC) and radius rC. Then we define(3.6)ΦKC=max⁡1≤i≤mmax⁡{χi,ψi},ψi=min⁡{ωi,μi},
where χi=αixC+βiyC+γi-rC (see Figure 3(a)), ωi=(xi-xC)2+(yi-yC)2-rC2 (see Figure 3(b)), and μi=(αi-1-αi)(yi-yC)-(βi-1-βi)(xi-xC)+rC(αi-1βi-αiβi-1) (see Figure 3(b)). See [14] for more details.A convex polygon and a circle.
(a)(b)In particular, ifP is a half-plane αx+βy+γ≤0 and C a circle with center (xC,yC) and radius rC, then (3.6) takes a much simpler form(3.7)ΦPC=αxC+βyC+γ-rC.


## 3.1.1. Convex Polygon and Circle

LetK be a convex polygon with sides Ei and vertices (xi,yi) for 1≤i≤m. Let αix+βiy+γi=0 be the equation of the line containing the side Ei. We assume that αi2+βi2=1 and the vertices and sides are numbered counterclockwise and the ith side joins the ith and (i+1)st vertices (if i=m, then we set i+1=1). Let C be a circle with center (xC,yC) and radius rC. Then we define(3.6)ΦKC=max⁡1≤i≤mmax⁡{χi,ψi},ψi=min⁡{ωi,μi},
where χi=αixC+βiyC+γi-rC (see Figure 3(a)), ωi=(xi-xC)2+(yi-yC)2-rC2 (see Figure 3(b)), and μi=(αi-1-αi)(yi-yC)-(βi-1-βi)(xi-xC)+rC(αi-1βi-αiβi-1) (see Figure 3(b)). See [14] for more details.A convex polygon and a circle.
(a)(b)In particular, ifP is a half-plane αx+βy+γ≤0 and C a circle with center (xC,yC) and radius rC, then (3.6) takes a much simpler form(3.7)ΦPC=αxC+βyC+γ-rC.


## 3.2. Convex Polygon and Circular Segment

LetK be again a convex polygon. Let D be a circular segment D=C∩T, where C is a circle and T a triangle made by the chord (the base of the segment) and the two tangents drawn at its endpoints. Now we define(3.8)ΦKD=max⁡{ΦKC,ΦKT},
where ΦKC was defined by (3.6) and ΦKT by (3.4).


## 3.3. Two Circular Segments

LetD=C∩T and D′=C′∩T′ be two circular segments. We define(3.9)ΦDD′=max⁡{ΦCC′,ΦTC′,ΦT′C,ΦTT′},
where ΦCC′ was defined by (2.9), ΦTC′ and ΦT′C by (3.6), and ΦTT′ by (3.4).This takes care of all possible pairs of convex basic objects, that is, types (a) and (b). It remains to deal with concave objects, that is, “hats” and “horns.” We first consider a simple object with a concave arc—the complement to a circle. This case is practically important because in many applications one places objects into a circular container.


### 3.3.1. Convex Objects inside a Circular Container

LetC* denote the (closure of the) complement to a circle C with center (xC,yC) and radius rC. Now let C′ be a circular object with center (xC′,yC′) and radius rC′≤rC that we want to place inside the circle C. Then we define(3.10)ΦC*C=(rC-rC′)2-(xC-xC′)2-(yC-yC′)2.
If rC′>rC, then we set ΦC*C=-∞.Next letK be a polygon (not necessarily convex) with vertices (x1,y1),…,(xm,ym) that we want to place in our circle C. Then we set(3.11)ΦC*K=min⁡1≤i≤m{rC2-(xi-xC)2-(yi-yC)2}.IfH=T∩C1* is a “hat,” that is, the intersection of a triangle T and the complement to a circle C1 (see Figure 6), we simply put ΦC*H=ΦC*T, where ΦC*T is given by (3.11).Now letD=C′∩T be a circular segment, where C′ is a circle with center (xC′,yC′) and radius rC′ and T a triangle as before, and qi=(xi,yi), i=1,2, the endpoints of the chord bounding D; see Figure 4(a). We put(3.12)ψ0=min⁡i=1,2{rC2-(xi-xC)2-(yi-yC)2},
then(3.13)ΦC*D=ψ0(forrC≤rC′).
Note that ψ0=ΦC*K subject to m=2, see Figure 4(a). Now we define(3.14)ΦC*D=min⁡⁡{ψ0,max⁡{ΦC*C′,φ1,φ2}}(forrC>rC′),
where ψ0 is given by (3.12) and(3.15)φ1=(y1-yC′)(xC′-xC)-(x1-xC′)(yC′-yC),φ2=-(y2-yC′)(xC′-xC)+(x2-xC′)(yC′-yC).NonoverlappingC* and D.
(a)(b)(c)(d)Formula (3.14) results from the following observations: ΦC*D≥0 if ψ0≥0 subject to ΦC*C′≥0 (see Figure 4(b)), or φ1≥0 (Figure 4(c)), or φ2≥0 (Figure 4(d)).To clarify the role of the functionsφ1 and φ2 we introduce vectors e=(xC-xC′,yC-yC′), a1=(x1-xC′,y1-yC′), a2=(x2-xC′,y2-yC′), e1=(-(y1-yC′),x1-xC′), and e2=(y2-yC′,-(x2-xC′)), as shown in Figure 5(a). Note that a1⊥e1 and a2⊥e2. In these notations,(3.16)φ1=〈e,e1〉,φ2=〈e,e2〉.
We call φ1 and φ2 “switch” functions. Note that max{ΦC*C′,φ1,φ2}<0 if ΦC*C′<0 and φ1<0 and φ2<0, see Figure 5(a). However, there exist tree cases, where ΦC*C′<0 but max{ΦC*C′,φ1,φ2}≥0. First, φ1≥0 and φ2<0 (see Figure 5(b)). Second, φ2≥0 and φ1<0 (Figure 5(c)). Lastly, φ1≥0 and φ2≥0 (Figure 5(d)).Role of the functionsφ1, φ2.
(a)(b)(c)(d)Figure 6
The domainG (grey) and three triangles T, T1, and T2.


## 3.3.1. Convex Objects inside a Circular Container

LetC* denote the (closure of the) complement to a circle C with center (xC,yC) and radius rC. Now let C′ be a circular object with center (xC′,yC′) and radius rC′≤rC that we want to place inside the circle C. Then we define(3.10)ΦC*C=(rC-rC′)2-(xC-xC′)2-(yC-yC′)2.
If rC′>rC, then we set ΦC*C=-∞.Next letK be a polygon (not necessarily convex) with vertices (x1,y1),…,(xm,ym) that we want to place in our circle C. Then we set(3.11)ΦC*K=min⁡1≤i≤m{rC2-(xi-xC)2-(yi-yC)2}.IfH=T∩C1* is a “hat,” that is, the intersection of a triangle T and the complement to a circle C1 (see Figure 6), we simply put ΦC*H=ΦC*T, where ΦC*T is given by (3.11).Now letD=C′∩T be a circular segment, where C′ is a circle with center (xC′,yC′) and radius rC′ and T a triangle as before, and qi=(xi,yi), i=1,2, the endpoints of the chord bounding D; see Figure 4(a). We put(3.12)ψ0=min⁡i=1,2{rC2-(xi-xC)2-(yi-yC)2},
then(3.13)ΦC*D=ψ0(forrC≤rC′).
Note that ψ0=ΦC*K subject to m=2, see Figure 4(a). Now we define(3.14)ΦC*D=min⁡⁡{ψ0,max⁡{ΦC*C′,φ1,φ2}}(forrC>rC′),
where ψ0 is given by (3.12) and(3.15)φ1=(y1-yC′)(xC′-xC)-(x1-xC′)(yC′-yC),φ2=-(y2-yC′)(xC′-xC)+(x2-xC′)(yC′-yC).NonoverlappingC* and D.
(a)(b)(c)(d)Formula (3.14) results from the following observations: ΦC*D≥0 if ψ0≥0 subject to ΦC*C′≥0 (see Figure 4(b)), or φ1≥0 (Figure 4(c)), or φ2≥0 (Figure 4(d)).To clarify the role of the functionsφ1 and φ2 we introduce vectors e=(xC-xC′,yC-yC′), a1=(x1-xC′,y1-yC′), a2=(x2-xC′,y2-yC′), e1=(-(y1-yC′),x1-xC′), and e2=(y2-yC′,-(x2-xC′)), as shown in Figure 5(a). Note that a1⊥e1 and a2⊥e2. In these notations,(3.16)φ1=〈e,e1〉,φ2=〈e,e2〉.
We call φ1 and φ2 “switch” functions. Note that max{ΦC*C′,φ1,φ2}<0 if ΦC*C′<0 and φ1<0 and φ2<0, see Figure 5(a). However, there exist tree cases, where ΦC*C′<0 but max{ΦC*C′,φ1,φ2}≥0. First, φ1≥0 and φ2<0 (see Figure 5(b)). Second, φ2≥0 and φ1<0 (Figure 5(c)). Lastly, φ1≥0 and φ2≥0 (Figure 5(d)).Role of the functionsφ1, φ2.
(a)(b)(c)(d)Figure 6
The domainG (grey) and three triangles T, T1, and T2.


## 3.4. Polygon and Hat

LetH=T∩C* be a hat, that is, the intersection of the complement to a circle C and a triangle T as shown in Figure 6. Let G denote the domain lying above the circle C and above the line L containing the chord forming the base of the triangle T; see the grey area in Figure 6. Note that H=G∩T.Now ifB is any convex object, then it overlaps with H if and only if it overlaps with both T and G; hence, we can define the phi-function as(3.17)ΦHB=max⁡{ΦTB,ΦGB}
provided we have properly defined ΦTB and ΦGB. This formula applies when B is either a convex polygon or a circular segment. In these two cases ΦTB is given by either (3.4) or (3.8), respectively. Thus it remains to define function ΦGB. Here we assume that B is a convex polygon.LetT1 and T2 denote two triangles adjacent to T; one side of each is a tangent to the circle C, and another side of each is a segment of the line L adjacent to the chord; see Figure 6 (the choice of the third side is not important). Let the circle C have center (xC,yC) and radius rC. Let the half-plane P below the line L be defined by inequality αPx+βPy+γP≥0. Note that G=(C∪P)*=C*∩P*.Now letK be any polygon (not necessarily convex) with vertices (x1,y1), …, (xm,ym). Note that K does not overlap with G if and only if two conditions are met: (i) every vertex (xi,yi) lies either in the circle C or below the line L; (ii) the polygon K does not overlap with T1 and T2. Accordingly, we define(3.18)ΦGK=min⁡{ΦT1K,ΦT2K,Ψ},
where(3.19)Ψ=min⁡1≤i≤mmax⁡{rC2-(xC-xi)2-(yC-yi)2,αPxi+βPyi+γP}.
Therefore,(3.20)ΦHK=max⁡{ΦTK,ΦGK},
which completes the analysis of the “polygon-hat” pair.


## 3.5. Circular Segment and Hat

LetH=T∩C*=T∩G be a hat as before and D a circular segment. The above analysis applies, up to the formula (3.17), because D is a convex object. It remains to define ΦGD.We again use the notationsP,C, and so forth, for objects associated with the hat H, as defined above. We denote by p1=(x1,y1) and p2=(x2,y2) the endpoints of the arc bounding H, as shown in Figure 8, that is, the points of intersection of ∂C with ∂P=L. The point pi=(xi,yi) is a vertex of the triangle Ti for i=1,2.The circular segmentD=C′∩T′ is the intersection of a circle C′ and a triangle T′, as before. Let rC′ denote the radius of the circle C′ and (xC′,yC′) its center. Let q1=(x1′,y1′) and q2=(x2′,y2′) denote the endpoints of the chord bounding D (as shown in Figure 4) and L′ the line passing through these points. Let the half-plane P′ below the line L′ (away from D) be defined by inequality α′x+β′y+γ′≥0. Note that D=C′∩(P′)*.IfrC′>rC, then we set(3.21)ΦGD=max⁡{ΦP*T′,ΦC*D,ΦGC′,φ1,φ2},
where ΦP*T′ is defined by (3.5), ΦC*D by (3.14), and for i=1,2 we set(3.22)φi=min⁡{ΦT3-iD,rC2-(xi′-xC)2-(yi′-yC)2,α′xi+β′yi+γ′,-(α′x3-i+β′y3-i+γ′)ΦT3-iD}.
Thus, ΦGD≥0 if ΦP*T′≥0 (see Figure 7(a)) or ΦC*D≥0 (see Figure 7(b)) or ΦGC′≥0 (see Figure 7(c)), φ1≥0 (see Figure 7(d)) or φ2≥0 (see Figure 7(e)).A circular segmentD versus the region G.
(a)(b)(c)(d)(e)Figure 8
The linesL1 and L2 for a segment-hat pair.The functionΦGC′ in (3.21) is defined as follows:(3.23)ΦGC′=max⁡{ΦC*C′,ΦP*C′,min⁡{ω1,ψ1,ω2,ψ2}},
where ΦC*C′ was defined by (3.10) and ΦP*C′ by (3.7). We also denote(3.24)ωi=(xi-xC′)2+(yi-yC′)2-rC′2
for i=1,2, and the functions ψ1,ψ2 are defined so that ψi=0 is the equation of the line Li (see Figure 8), and ψi≥0 is the half-plane below that line in Figure 8. The line Li passes through points pi1 and pi2. The line segment pipi1, i=1,2, is perpendicular to the line p1p2, the line segment pipi2 is perpendicular to the line pip3, and we have ∥pipij∥=rC′ for all i,j=1,2. The functions ψi, i=1,2, come from the application of (3.6) to Ti and C′.IfrC′≤rC, we need to replace φi, i=1,2, in (3.21) with φi′ defined by(3.25)φi′=min⁡{φi,α′(xC′-xC)+β′(yC′-yC)}.Finally, combining (3.17) and (3.21) gives(3.26)ΦHD=max⁡{ΦTD,ΦGD}.
Indeed, ΦHD≥0 if ΦTD≥0 (see Figure 9(a)) or ΦGD≥0 (see Figure 9(b)).A hatH and a circular segment D.
(a)(b)


## 3.6. Two Hats

LetH′=G′⋂T′ be a hat and H′′=G′′⋂T′′ another hat. Equivalently, H′=(C′)*⋂T′ and H′′=(C′′)*⋂T′′. For the hat H′ we use notation G′,C′,T′, and so forth, as defined above, and for the hat H′′ the respective notation G′′,C′′,T′′, and so forth. Now our phi-function is defined by(3.27)ΦH′H′′=max⁡{ΦT′H′′,ΦG′T′′,ω,τ},
where ΦT′H′′, ΦG′T′′ are given by (3.17), (3.18), respectively, and we denote(3.28)ω=min⁡{(yC′′-y1′)2α2′x1′′+β2′y1′′+γ2′,α2′′x1′+β2′′y1′+γ2′′,(rC′)2-(xC′-x3′′)2-(yC′-y3′′)2,(rC′′)2-(xC′′-x3′)2-(yC′′-y3′)2},τ=min⁡{(yC′′-y1′)2α1′x3′′+β1′y3′′+γ1′,α1′′x3′+β1′′y3′+γ1′′,(rC′)2-(xC′-x1′′)2-(yC′-y1′′)2,(rC′′)2-(xC′′-x1′)2-(yC′′-y1′)2},
where (xi′,yi′) are the coordinates of the vertices and αi′x+βi′y+γi′=0, i=1,2, are the equations of lines containing the two straight sides of H′, respectively; (xC′,yC′) and rC′ are the coordinates of the center and the radius of the arc bounding H′. Similar notation applies to the hat H′′.The hatsH′ and H′′ do not overlap if ΦT′H′′≥0 (see Figure 10(a)), or ΦG′T′′≥0 (Figure 10(b)), or ω≥0 (Figure 10(c)), or τ≥0 (Figure 10(d)).Four cases of nonoverlapping hatsH′ and H′′.
(a)(b)(c)(d)


## 3.7. Horns

A hornV=H∩(D∪T) is the intersection of a hat H and the union of a circular segment D and a triangle T; see Figure 11, where the triangle T has vertices p1,p2,p3, and the hat H has vertices p1,p2,p4.Figure 11
A hornV (grey) and the respective hat H (with vertices p1,p2,p4), circular segment D, and triangle T (with vertices p1,p2,p3).Now for any convex polygonK we define(3.29)ΦVK=max⁡{ΦHK,min⁡{ΦKD,ΦKT}}.
Similarly, for any circular segment D′,(3.30)ΦVD′=max⁡{ΦHD′,min⁡{ΦDD′,ΦTD′}}
and for any hat H′(3.31)ΦVH′=max⁡{ΦHH′,min⁡{ΦH′D,ΦH′T}}.
Now let V′=H′∩(D′∪T′) be another horn. Then we define(3.32)ΦVV′=max⁡{ΦHH′,min⁡⁡{ΦHD′,ΦHT′},min⁡⁡{ΦH′D,ΦH′T},min⁡⁡{ΦDD′,ΦTT′,ΦTD′,ΦT′D}}.Some formulas for the phi-functions may appear quite complex. Note, however, that they all can be programmed off-line and stored in a computer library. In practical applications, one can just call the respective functions, and their evaluation proves to be fast and efficient.


## 4. Adjusted Phi-Functions

Some applications involve restrictions on the distances between certain pairs of objects, or between objects and the walls of the container. For example, when one is packing radioactive waste, discarded pieces cannot be placed too close together. On the other hand, when one designs a printed circuit board (PCB), then certain electronic components cannot be placed too far apart. Cutting mechanical parts out of a metal sheet is another example where minimal distances have to be maintained, because one has to take into account the physical size of the cutter.In other words, some upper and/or lower limits on the distances between certain placed objects may be set, that is, given two objectsA,B, the corresponding placed objects A′=A(νA,θA) and B′=B(νB,θB) must satisfy(4.1)dist⁡(A′,B′)≥ρAB-ordist⁡(A′,B′)≤ρAB+,
where(4.2)dist⁡(A′,B′)=min⁡X∈A′,Y∈B′dist⁡(X,Y).
Here ρAB- denotes the minimal allowable distance and ρAB+ the maximal allowable distance between A′ and B′.To fulfil (4.1), it has been a common practice to compute the actual distance between A′ and B′ at every step during the optimization process and check if (4.1) holds. But the computation of geometric distances (especially for complex objects) involves complicated formulas with radicals, see a variety of examples detailed in [11]. We avoid the computation of geometric distances by using so called adjusted phi-functions defined below.Suppose we have to maintain a minimal distanceρ=ρAB- for a pair of objects A,B. We will construct an adjusted phi-function Φ̂AB satisfying(4.3)Φ̂AB>0ifdist⁡(A′,B′)>ρ,Φ̂AB=0ifdist⁡(A′,B′)=ρ,Φ̂AB<0ifdist⁡(A′,B′)<ρ.
Then we work with it a just like with the regular phi-function ΦAB in the previous sections, where no restrictions on distances were imposed. Indeed, all allowable placements of the objects A,B now correspond to Φ̂AB≥0 and prohibited placements correspond to Φ̂AB<0. Thus our optimization algorithms can proceed the usual routine, but with the new (adjusted) phi-function Φ̂AB instead of ΦAB.Given an objectA and ρ>0 we define its ρ-expansion (Figure 12) by(4.4)Â=Âρ=A⊕Cρ,
where (C,ρ) denotes a circle of radius ρ centered on the origin and the symbol ⊕ stands for the so-called Minkowski sum [19], which is defined by(4.5)A1⊕A2={(x1+x2,y1+y2):(x1,y1)∈A1,(x2,y2)∈A2}
for any two sets A1,A2⊂ℝ2. In other words, the ρ-expanded object Â in (4.4) consists of points that are either inA or at distance≤ρ  fromA. We will not need to use Minkowski sum for computing our phi-functions.An objectA (a), its ρ-expansion Â (b), and the ρ-expansion δA of its boundary ∂A (c).
(a)(b)(c)Now we construct the adjusted phi-function byΦ̂AB=ΦÂB, and it will satisfy the requirements (4.3). Note that instead of expanding the object A we can expand the other object B and define Φ̂AB=ΦAB̂. This extra flexibility can be used in practice to minimize the cost of computation.Suppose we have to maintain a maximal allowable distanceρ=ρ+ for a pair of objects A,B. This means that the objects have to be positioned so that ΦAB≥0 (to avoid overlaps) and Φ̂AB≤0, where Φ̂AB is the adjusted function constructed above (the latter condition will keep the distance ≤ρ). Thus we can define another adjusted phi-function as(4.6)Φ̌AB=min⁡{ΦAB,-Φ̂AB}.
Now we have(4.7)Φ̌AB>0if0<dist⁡(A′,B′)<ρ,Φ̌AB=0if(int⁡(A′)∩int⁡(B′)=∅and∂A′∩∂B′≠∅)ordist⁡(A′,B′)=ρ,Φ̌AB<0ifint⁡(A′)∩int⁡(B′)≠∅ordist⁡(A′,B′)>ρ.
Thus all allowable positions of A and B correspond to Φ̌AB≥0.We see that the adjusted phi-functions can always be defined as (ordinary) phi-functions, but for expanded objects. It remains to define phi-functions for expanded objects. For any objectA we have Â=A∪δA, where δA=∂A⊕Cρ is the expansion of the boundary of A; see Figure 12(b). One can think of δA as a “fattened” boundary of A (whose “thickness” is 2ρ). Then by the decomposition principle (2.11) we define(4.8)Φ̂AB=ΦÂB=min⁡⁡{ΦAB,ΦδAB}.Now recall that∂A consists of linear segments and circular arcs, that is, ∂A=∪i=1mγi, where each γi is either a segment of a line or a circular arc. Therefore, δA=∪i=1mγ̂i, where γ̂i=γi⊕Cρ denotes the expansion of γi (as described below). Now by the decomposition principle (2.11) we define(4.9)ΦδAB=min⁡1≤i≤mΦγ̂iB.
The domain γ̂i=γi⊕Cρ is shown in Figure 13 for three different cases: γi is a line segment (a), γi is an arc of radius >ρ (b), and γi is an arc of radius ≤ρ (c); see a detailed analysis below.Expansion of boundary components.
(a)(b)(c)In all these three cases we haveγ̂i=C1∪C2∪R, where C1 and C2 are disks of radius ρ centered on the endpoints of γi. If γi is a line segment, then R is a rectangle (Figure 14(a)). If γi is a circular arc of radius ri>ρ, then R is a “bent rectangle” (Figure 14(b)). If γi is a circular arc of radius ri≤ρ, then R degenerates to a circular segment (Figure 14(c)). Thus we define(4.10)Φγ̂iB=min⁡{ΦC1B,ΦC2B,ΦRB},
where R denotes the corresponding rectangle, or bent rectangle, or circular segment.Various domainsγ̂=C1∪C2∪R.
(a)(b)(c)We note that∂A consists of m components, so δA will consist of m disks of radius ρ and m rectangles or “bent rectangles” (some of the latter may degenerate to circular segments). Rectangles and circular segments are objects of basic types, for which phi-functions were defined in Section 3. Bent rectangles are objects of a new type, so we need to handle them separately.We have two cases shown in Figure15. On (a), the “bent rectangle” is the union of two “wedges” W1, W2 and a hat H. Every wedge Wi is in turn the union of a triangle Ti and a circular segment Di (see Figure 16), hence(4.11)ΦRB=min⁡{ΦHB,ΦT1B,ΦD1B,ΦT2B,ΦD2B}.
In the second case (Figure 15(b)) the bent rectangle R can be decomposed as R=W1∪W2∪(H∩C). Accordingly, we define(4.12)ΦRB=min⁡{ΦW1B,ΦW2B,max⁡{ΦHB,ΦCB}}.A “bent rectangle”R=W1∪W2∪H (a) and R=W1∪W2∪(H∩C) (b).
(a)(b)Figure 16
A wedgeWi=Ti∪Di.


## 5. Numerical Examples

We illustrate our method by several model examples. In these examples we describe each object by listing elements of its boundary∂A={l1,…,ln}. Each boundary element li is completely described by its numerical code (which is 0 for straight line segments, +1 for convex arcs, and −1 for concave arcs), the coordinates of the two endpoints (x1,y1) and (x2,y2), and (for circular arcs only) the coordinates of the center (xC,yC).Our goal is to place a given object or two given objects into a circle of minimal radius or into a rectangle of minimal area. The rectangle is always properly oriented, that is, its sides are parallel to thex and y axes. Accordingly, our objective function (to be minimized) is F(u1,u2,…)=r in case of a circular container of radius r and F(u1,u2,…)=ab in case of a rectangular container with sides a and b.The argumentsu1,u2,… of the objective function include the translation vectors ν=(ν1,ν2) for all the objects and rotation angles θ, where appropriate; compare (2.1). If we place a single object into a circle, no rotation is needed. If two objects are placed into a circle, it is enough to rotate one of them to achieve the optimal placement. When one or two objects are placed into a rectangle, each of them may have to be rotated in order to find the best placement.Example 5.1.
The goal is to place a given object into a circle of minimal radius. The object is a dolphin-like domainA shown in Figure 17(a); its boundary is described in Table 1. The optimal placement is also shown in Figure 17(a). The radius of the optimal circle is r*=4.015234. This example took 3.61 sec of the computer running time (we processed our examples on a PC with an AMD Athlon 64X2 2.6 GHz CPU).Table 1
The boundary of the dolphin-like has 13 elements.
Codex1,y1xC,yCx2,y213.753993,2.2794511.586533,0.5247441.233706,3.29104011.233706,3.2910401.197359,-1.021342-1.57802,2.2794511-1.578020,2.279451-0.164213,0.362623-1.15153,-1.804929−1-1.151532,-1.804929-5.628434,-17.6411771.905534,-3.01008901.905534,-3.0100892.781521,-4.28350702.781521,-4.2835073.018245,-3.22814903.018245,-3.2281492.493878,-2.61936102.493878,-2.6193613.122744,-2.33896903.122744,-2.3389693.546228,-1.38965303.546228,-1.3896531.313080,-1.873368−11.313080,-1.8733681.127739,0.139935-0.84345,0.589527−1-0.843455,0.5895270.696106,-0.5502541.384174,1.23745711.384174,1.2374571.595781,3.9720473.753993,2.279451A dolphin-like object placed into (a) a circle of minimal radius and (b) a rectangle of minimal area.
(a)(b)Example 5.2.
The goal is to place the given object (same as in Example5.1) into a rectangle of minimal area. The optimal placement is shown in Figure 17(b). The rectangle has sides a*=7.132090 and b*=6.416804. We note that our algorithm supports rotation of objects. The optimal rectangle is found when the object A is rotated by angle θA=1.31245. This example took 104 sec.Example 5.3.
The goal is to place two given objects,A and B, into a circle of minimal radius. The objects are identical copies of the dolphin-like object in Example 5.1. The optimal placement is shown in Figure 18(a). The radius of the circle is r*=5.251253. Again, the objects are subject to rotation, and the optimal circle is found when the object B is rotated by angle θB=3.141593. This example took 4298 sec.(a) Two dolphin-like objects placed into a circle of minimal radius and (b) two staple-like objects placed into a circle of minimal radius.
(a)(b)Example 5.4.
The goal is to place two given objects,A and B, into a circle of minimal radius. The objects have identical shape, they look like thick metal staples and their boundary is described in Table 2. The optimal placement is shown in Figure 18(b). The radius of the optimal circle is r*=2.455866. Again, the objects are subject to rotation, and the optimal circle is found when the object B is rotated by angle θB=3.141593. This example took 31 sec.Table 2
The boundary of the “thick staple” object has 8 elements, all straight line segments.
Codex1,y1xC,yCx2,y201.182742,1.7084761.278823,1.6948100-1.278823,1.694810-1.278823,-1.4824970-1.278823,-1.4824971.175904,-1.48249701.175904,-1.4824971.175904,-0.63521501.175904,-0.635215-0.499328,-0.6352150-0.499328,-0.635215-0.499328,1.1755080-0.499328,1.1755081.196417,1.17550801.196417,1.1755081.182742,1.708476Example 5.5.
The goal is to place two given objects,A and B, of different shape into a circle of minimal radius. The object A is made by three arcs (two concave and one convex) described in Table 3. The object B=H1∪H2 is the union of two overlapping hats specified in Table 4. The optimal placement is shown in Figure 19(a). The radius of the circle is r*=5.322824. Again, the objects are subject to rotation, and the optimal circle is found when the object B is rotated by angle θB=2.309901. This example took 1147 sec.Table 3
The objectA (Figure 19) bounded by three arcs.
Codex1,y1xC,yCx2,y2−1-2.555404,-2.0667130.651314,-15.3722214.266788,-2.17192014.266788,-2.171920-0.740153,-1.703527-2.19745,3.109491−1-2.197449,3.109491-5.005667,0.703211-2.55540,-2.066713Table 4
The objectB=H1∪H2 (Figure 19) is the union of two overlapping hats. Each hat is specified by the coordinates of the two endpoints (x1,y1) and (x2,y2) and the center (xC,yC) of the circular arc bounding it and by the coordinates (xv,yv) of its third vertex. We note that both circular arcs bounding H1 and H2 have radius r=5.0.
Hatx1,y1x2,y2xC,yCxv,yvH1-2.878715,-1.1163152.088654,4.400499-2.884564,3.8836812.661289,-1.109835H2-1.442662,-4.818566-1.442654,2.605045-4.792658,-1.1067582.670029,-1.106765(a) Two objects of different shape placed into (a) a circle of minimal radius and (b) a rectangle of minimal area.
(a)(b)Example 5.6.
The goal is to place the two given objects,A and B (same as in Example 5.5), into a rectangle of minimal area. The optimal placement is shown in Figure 19(b). The rectangle has sides a*=13.294256 and b*=5.603828. Again, the objects are subject to rotation, and the optimal rectangle is found when the object A is rotated by angle θA=-0.118376 and the object B is rotated by angle θB=0.715346. This example took 443 sec.Example 5.7.
The goal is to place two very irregular (star-shaped) objects,A and B, into a circle of minimal radius. The objects have identical shape, each is the union of four overlapping hats specified in Table 5. The optimal placement is shown in Figure 20(a). The radius of the circle is r*=7.031531. Again, the objects are subject to rotation, and the optimal circle is found when the object B is rotated by angle θB=0.634543. This example took 996 sec.Table 5
The objectA=H1∪H2∪H3∪H4 (Figure 20) is the union of four overlapping hats. Hats are specified as in Table 4. We note that all the circular arcs bounding these four hats have radius r=5.0.
Hatx1,y1x2,y2xC,yCxv,yvH1-4.284755,-1.2806570.682614,4.236157-4.290604,3.7193391.255249,-1.274177H2-2.848702,-4.982908-2.848694,2.440703-6.198698,-1.2711001.263989,-1.271107H34.249704,-0.281005-0.717661,-5.797824.255557,-5.281-1.2903,-0.287489H42.813649,3.4212452.813646,-4.0023666.163647,-0.29056-1.29904,-0.290559(a) Two objects of different shape placed into (a) a circle of minimal radius and (b) a rectangle of minimal area.
(a)(b)Example 5.8.
The goal is to place two very irregular (star-shaped) objects,A and B, into a rectangle of minimal area. The objects are the same as in Example 5.7. The optimal placement is shown in Figure 20(b). The rectangle has sides a*=8.856350 and b*=14.292623. Again, the objects are subject to rotation, and the optimal rectangle is found when the object A is rotated by angle θA=0.470376 and the object B is rotated by angle θB=3.611969. This example took 154 sec.Example 5.9.
This is a modification of Example5.5: we place two objects A and B into a circle C of minimal radius, but now the object A must be at least the distance of 0.7 away from the object B and from the edge of the circle C; that is, we need dist(A,B)≥0.7 and dist(A,C*)≥0.7. In this example we use adjusted phi-functions (Section 4). The optimal placement is shown in Figure 21. Note that the object A does not touch the object B or the boundary of C*, to maintain the required distance from both. The radius of the optimal circle is r*=5.823507. The objects are subject to rotation, and the optimal circle is found when the object B is rotated by angle θB=2.322388. This example took 7725 sec.Figure 21
Two objectsA and B placed into a circle C of minimal radius, with additional restriction on distances from A to B and C.



---

*Source: 346358-2012-05-06.xml*