We want to find circles inside a triangle, and there are specified tangency constraints among these circles and 3 sides of the triangle. We use the tangency graph to show the tangency constraints. Consider a graph G (V, E), V is the vertices which represents the circles or sides of triangles, and E represents the edge connecting vertices. When an edge connects two vertices, it means that these two geometric object tangent to each other. That is, circle externally tangent to circle if these two geometric objects are circles, or circle tangent to side of triangle. When a circle is tangent to two, one, or zero sides of a triangle, we call it a corner circles, edge circle or inner circle respectively.
The main idea of the new proposed algorithm is to generate the tangency graph, find solution radii for all circles satisfied the constraints specify by the tangency graph, and then display. The purpose of this algorithm is to find circles with small range of radii. In the very beginning, we need to set a value r, so that all circle we generate to pack inside the triangle has radius near r.
We will describe the above algorithm more detail, including the answer of the following 4 questions:
The above 4 questions will be described in section 2.1 to section 2.4.
2.1. Offset a Triangle
Consider three different terms, line, ray and line segment. There is no end point for line, and one end points for ray, and two end points for line segment. Consider the parametric form for a line, ray, and line segment passing through two points P1 and P2, they have the same parametric form (1-t)P1+tP2 with different range of the parameter. It is a line, ray, line segment when t∈R, t≥0 , 0≤t≤1 respectively. Notice that the ray has P1 as its end point, denote Ray(P1, P2) and with the orientation of Ray(P1, P2), we may define the left side and right side of Ray(P1, P2). Let L= Ray (P1, P2), we denotes the point P1′ is the point moving P1 to the left side of Ray(P1, P2) r distance, denotes P1′ =Move(P1, L, r). The Ray(P1′, P2′), also denote Rayr(P1, P2), is called the r-offset of Ray(P1,P2).
Before the more detail description for proposed algorithm, we have the following theorem:
Theorem 1. r-offset of a ray. Given Ray(P1, P2), where P1 = (x1, y1), P2=(x2, y2), the parametric form for Rayr(P1, P2) is (1-t)P1+tP2+r×nL, , where nL= (,). The implicit form for the line cover Rayr(P1, P2) is a′x+b′y+c′=0 where a′ = (y2-y1), b′ = (x1-x2), and c′=
Proof of Theorem 1. The direction of the ray is P2-P1=. The two vectors nL = and nR = are perpendicular to P2-P1. This two vectors points to its left (nL) and its right(nR). We can move points on Ray(P1, P2) along nL direction r distance, so the parametric form for Rayr (P1, P2) is (1-t)P1+tP2+r×nL. Consider two points P1′, P2′, which is the points P1, P2, move to its left. That is Pi′=(xi′,yi′)=Pi+r×nL, i=1,2. The implicit form for Ray(P1, P2) is: ax + by + c = 0, where a = y2 - y1, b = x1 – x2, c = . Let the r-offset of Ray(P1, P2) denote as Rayr = a′x + b′y + c′ = 0, where a'=y2′-y1′=a, b′=x1′–x2′=b, c′= =. So, the implicit form of Rayr is (y2-y1)x + (x1-x2)y - + = 0.
Example 1. Given two points P
1=(1,1), P
2=(5,2). Let L= Ray
1 (P
1, P
2), the points P
1′= Move(P
1, L, 1) =(0.757,1.970) and P
2′= Move(P
2, L, 1) =(4.757,2.970). In
Figure 9, the L is shown in blue with implicit form x+4y+3=0. Furthermore, the Ray
1(P
1,P
2) = Ray(P
1′,P
2′) is shown in orange with implicit form x+4y+7.123=0.
We call Ray(P1′,P2′) is the r-offset of Ray(P1,P2).
The following theorem is directly from [
11].
Theorem 2:
Intersection of two lines from 4 points [
11].
Given 4 points P
1(x
1, y
1), P
2(x
2, y
2), P
3 (x
3, y
3), P
4(x
4, y
4).
Two lines L
1, L
2,
where L
1 passing through P
1, P
2 and L
2 passing through P
3, P
4.
Then: If , L
1, L
2 are parallel to each other. Otherwise, these two lines intersect each other at (x,y)
where,
Theorem 3:
Intersection of two r-offset rays from 3 points. Given Ray(P
1, P
2), Ray(P
2, P
3),
where Pi=(x
i,y
i), i=1,2,3.
The intersection of Ray
r(P
1, P
2), Ray
r(P
2, P
3) is (x, y) = (
)
if ≠0
where
Proof of Theorem 3. Let L1=Ray(P1,P2), L2=Ray(P2, P3), L3=Rayr(P1, P2), L4=Rayr(P2, P3). Let P1′=Move(P1, L1, r), P2′=Move(P2,L1,r), P3′=Move(P2,L2,r) and P4′=Move(P3,L2,r), then: P1′ = P1 + r×n12, P2′ = P2+ r×n12, P3′ = P2+ r×n23, P4′= P3 + r×n23, where n12 = and n23 = (,. The proof can be easily derived by using theorem 2 with these 4 points P1′, P2′ ,P3′, P4′.
The intersection P (x, y) = (), when
Example 2. Given 3 points P
1=(1,1), P
2=(10,2), P
3=(3,5), then P
1′=(0.889,1.993), P
2′=(9.889, 2.993), P
3′=(9.606, 1.080) and P
4′=(2.606,4.080). The intersection points P for Ray
1(P
1,P
2) and Ray
1(P
2,P
3) is at (6.119, 2.575), As shown in
Figure 10.
We denote P=Ray1(P1,P2)∩Ray1(P2,P3).
From △ABC, we can find 3 points B′=Rayr(A,B) ∩Rayr(B,C), C′=Rayr(B,C)∩Rayr(C,A) and A′=Rayr(C,A) ∩Rayr(A,B). We call △A′B′C′ is the r-offset triangle for △ABC.
Example 3. Given A=(1,1), B=(10,2), C=(3,5), the 1-offset triangle for △ABC is a triangle with vertices A′=(2.716, 2.196), B′=(6.119,2.575) and C′=(3.472, 3.709), see
Figure 11.
2.3. How to Construct Edges on Two Consecutive Layer
Now is the time to generate edges between vertices on T1 and vertices on T2. Before we explain our strategy to connect vertices on these two triangles, we have the following theorem:
Theorem 4.
Find foot point of a point onto a line. Given a point g (x
3, y
3)
and a line L(g∉L)
passing through two points (x
1, y
1), (x
2, y
2).
The nearest points, also called the footpoint, of g
onto L
is at (Shown as
Figure 14)
Proof of Theorem 4. A point (x,y) on L, we can generate the square of the distance function from (x,y) to point g: f(t) = =. We want to find the value t, so that f(x) is minimum. That is, , the parameter value t can be computed from
Consider the correspondence edge
on T
1 and
on T
2. Assume the parameter values for the vertices on
are t
0, t
1, …, t
m and the parameter values for the footpoints of vertices on
onto
are t
0′, t
1′, …, t
n′. We explain the details with m=7 and n=3, as shown in
Figure 15. To simplify our description, we use the parameter values as its vertex name from now on. The vertex t
0 and t
7 are the vertices on
, it did not connect any vertices on
(T
2) yet. When we construct edges for △A′B′C′, we construct one edge from t
1 to the last vertex on
., and t
6 to the first vertex on
. Now, we need to construct the edges for t
i, i=1...,6 and t
j′, j=0,3. We use the following approach to connect edges between vertices generate on T
1 and T
2. Notice that we try to connect vertices in
to the vertices near it in
. We did the same process for vertices in
to the vertices near it in
and for vertices in
to the vertices near it in
.
We define floor and ceiling for the vertices as the following:
Where
, With the above definition, we connect vertices
to all vertices from
= 0, .., n. So, in
Figure 15,
connect vertices from
=t
1 to
=t
2, and
connect vertices from
=t
4 to
=t
6. So, vertex with parameter
has 3 edges connect vertices on
.
After connecting edges between T
1 and T
2, the result is shown on
Figure 13b. Continue to generate vertices on T
3=
r-offset(T
2), T
4=
r-offset(T
3), and generate vertices and edges for the tangency graph G(V,E), increase vertices on V, and edges connecting vertices on the same layer and previous layer, see
Figure 13c,d, it is time to think how to stop the process.