You are on page 1of 57

# UNIVERSITY

OF WEST BOHEMIA

DIPLOMA THESIS

## The use of Piecewise Circular Curves in Geometric

Modeling
Ulugbek Khudayarov

Pilsen 2007

UNIVERZITA

DIPLOMOV PRCE

## Pouzit po cstech kruhovch krivek v geometrickm

modelovn
Ulugbek Khudayarov
Obor: Matematika

Plze
n 2007

Prohlsen
Prohlasuji, ze jsem diplomovou prci vypracoval samostatne s pouzitm odborn literatury
a pramenu uvedench v seznamu, kter je soucst tto prce.

V Plzni dne . . .

. . . . . . . . . . . . . .
Podpis

Pod
ekovn
Tmto bych chtel podekovat vedoucmu diplomov prce RNDr. M. Lvickovi, Ph.D. za
odborn veden, cetn rady a korektury tto prce.
Dekuji tak sv rodine a prtelm za trpelivost a podporu, kterou mi dvali behem mho
studia.

CONTENTS

Contents
1 Introduction

## 2 Fundamentals of Piecewise Circular Curves

2.1 Biarc formulation . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Construction and representation of Piecewise Circular Curves

8
8
17

## 2.3 Tangent vectors of the polygon . . . . . . . . . . . . . . . . .

2.4 Approximation of curves by smooth PCCs. . . . . . . . . . .

21
22

3 NURBS approximation
3.1 B-spline curve . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 NURBS curve . . . . . . . . . . . . . . . . . . . . . . . . . .

24
24
26

## 3.3 PCC approximation of NURBS curve . . . . . . . . . . . . .

3.4 The implementation of the algorithm . . . . . . . . . . . . .

29
33

## 4 Applications of PCCs in geometric modeling

4.1 Circular pipe connections . . . . . . . . . . . . . . . . . . . .

35
35

## 4.2 Blending of canal surfaces . . . . . . . . . . . . . . . . . . . .

4.3 Approximation of surface/surface intersections . . . . . . . .

39
41

5 Conclusion

47

Introduction

## PCC (Piecewise Circular curve) is a kind of geometric curve made of circular

arcs and line segments. It is easy to use, computationally efficient in shape
modeling, and well used as the description of tool path of CNC machines.
In CNC tool path programming, fewer arc segments can help to improve the
production efficiency by reducing the number of instructions and tool motions.
Therefore, approximating points, polylines, or arbitrary curves with PCCs is
of particular importance. Approximations to point data by G1 arc splines
have been investigated in the past [1, 2, 4 and 5]. Approximations to given
curves by G1 arc splines have also been extensively researched [4], [5],[7] and
[15]. The curves are mostly assumed to be compatible with NURBS [7] and
[15]. They are often restricted either in confined degrees [15] or in specially
bounded shapes such as spiral, convex, or monotone curvature segments.
This work presents a method of approximating a NURBS curve by PCCs to
within a user specified tolerance. The ideas of this method are summarized
as follows:
approximate the NURBS curve by a polygon to within a certain tolerance;
approximate the polygon with biarcs whose end points lie on the curves,
and whose end tangents are the tangents of the curve taken at the end
points of the biarc; and
hook up the biarcs into a G1 curve that lies from the given curve within
tolerance.
A biarc consists of two circular arcs with G1 continuity at a joining point.
Given two end points and two end tangents, a biarc can be constructed which
matches the points and tangents but an additional constraint is required to
6

make the biarc unique. The conventional approach to this biarc construction
which has been widely adopted in arc spline approximation, introduces various
constraints to uniquely determine the biarc [7]. The difference of the radii of
the two circular arcs can be minimized, with the result that the angles of the
two arcs are equal [15]. The difference of the curvatures of the two arcs can
be minimized, with the result that the joining point is on the bisector of the
line segment joining the two end points [11]. Also, the ratio of the two radii
can be made as close to one as possible, with the result that the tangent at
the joining point is parallel to the line joining the two end points.
Instead of imposing such constraints to make the biarc unique, the approach
proposed herein exploits the inherent freedom in the choice of the biarc to
achieve a better fit minimizing the distance between the polygon and the biarc.
This is called optimal single biarc fitting. A similar approach exploiting the
freedom was proposed for arc spline fitting of a B-spline curve, but it requires
much computation since it has to solve a non-linear optimization problem of
minimizing the area between the B-spline curve and the fitted curve.
The rest of the thesis is organized as follows. In section 2 we describe fundamentals of Piecewise Circular Curves, biarc formulation. Section 3 describes
the details on the biarc approximation method. In Section 4, applications of
PCCs in geometric modeling: Circular pipe connections, Blending of canal
surfaces and approximation of intersection edges of surfaces.

## Fundamentals of Piecewise Circular Curves

2.1

Biarc formulation

Definition 2.1. The two circular arcs c1 , c2 (in R3 ) are said to form a biarc
interpolating given oriented G1 data, represented by end points P1 , P2 and
unit tangent vectors T1 , T2 if the two circular arcs share one common end
point J called joint and satisfy the following properties:
1. The arc c1 has the end points P1 and J, and T1 is tangent to c1 with
orientation corresponding to a parametrization of c1 from P1 to J.
2. The arc c2 has the end points J and P2 and T2 is tangent to c2 with
orientation corresponding to a parametrization of c2 from J to P1 .
3. The two arcs have a common unit tangent vector at J, with orientation
corresponding to a parametrization of c1 from P1 to J and of c2 from J
to P2 .
y

y
C1

T1

C2

T1

T2

C1

2
C2

T2
(b)

(a)

Figure 1: Biarcs for given data (P1 , T1 ) and (P2 , T2 ): (a) C-shaped biarc, (b) S-shaped
biarc.

The shape of the biarc depends on the direction of the tangent vectors (or
the angles 1 and 2 ) as shown in Figure 1. A positive angle is defined
as counterclockwise direction from the vector P2 P1 to the corresponding
8

2.1

Biarc formulation

## tangent vectors Ti . For instance, 1 is positive angle while 2 is negative in

Figure 1(a). If both angles 1 and 2 are zero, the associated solution is a
straight line segment. If the angles 1 and 2 have different signs, the biarc
curve is C-shaped, as shown in Figure 1(a). If 1 and 2 have the same sign,
the biarc is S-shaped biarc as shown in Figure 1(b).
Theorem 2.1. All (P1 , T1 ) and (P2 , T2 ) (kT1 k = kT2 k = 1) pairs of data
can be connected by biarc.
Proof. Let (P1 , T1 ) and (P2 , T2 ) (kT1 k = kT2 k = 1) be given data. The line
passes through P1 and parallel to T1 we will denote 1 and the line passes
through P2 and parallel to T2 we will denote 2 .
Let P10 1 and P10 = P1 + T1 , where is constant. Then we can find point
P20 on the line 2 , which satisfy these conditions:
P20 = P2 T2 ,

kP20 P10 k = | + |

## where is constant. Second condition is equivalent to the equation:

(P20 P10 ) (P20 P10 ) = ( + )2
Substituting P10 and P20 into the last equation, we will gets
(V T1 T2 ) (V T1 T2 ) = ( + )2
where V = P2 P1 . Computing the dot products in this equation, after
simplification one gets
2(T1 T2 1) 2V T1 2V T2 + V V = 0

(2.1)

## We use as the parameter and express in the terms of .

T1 V 21 V V
=
(T2 T1 1) + V T2
9

(2.2)

2.1

Biarc formulation

10

For any exists and thus we can always obtain the point P2 satisfying
conditions P20 = P2 T2 , kP20 P10 k = | + |.
P'

c
1

J
1

c2
P'

## Then we can find a point

J=

P1 + P2 + (T1 T2 )
P10 +
P20 =
+
+
+

(2.3)

## which is a joint point. Because the point J satisfies these conditions:

kP1 P10 k = kP10 Jk = ||, kP2 P20 k = kP20 Jk = ||
There are one arc c1 (The arc c1 has the end points P1 and J, and T1 is tangent
to c1 with orientation corresponding to a parametrization of c1 from P1 to J.)
satisfying property (1) of biarc definition and one arc c2 (The arc c2 has the
end points J and P2 and T2 is tangent to c2 with orientation corresponding
to a parametrization of c2 from J to P1 .) satisfying second property. These
two arcs have a common tangent at J with orientation corresponding to a
parametrization of c1 from P1 to J and of c2 from J to P2 (see Figure 2).

Biarcs for the given data (P1 , T1 ) and (P2 , T2 ) are many, because in the
10

2.1

Biarc formulation

11

## proof of theorem is an arbitrary constant. For any we can construct one

biarc. All this biarcs are composed family of biarcs for given data (P1 , T1 )
and (P2 , T2 ) .
The proof of Theorem 2.1 can be used for computing the control polygon
of biarc. Excellent results are obtained by choosing = which produces
regular curves and leads to an efficient evaluation of . Because biarc with
= is very close to Bezier cubic curve that interpolates the same boundary
conditions as the biarc and passes through the junction of the two arcs [11].
with = equation (2.1) can be written as:
1
2 (T1 T2 1) V (T1 + T2 ) + V V = 0
2

(2.4)

## Equation (2.4) is equivalent to the equation:

2 (kTk2 4) 2(V T) + kVk2 = 0

(2.5)

## where T = T1 + T2 . This is a second degree equation in and has for

discriminant
D = (V T)2 + kVk2 (4 kTk2 )

(2.6)

Because kTk 2, D is the sum of two nonnegative terms and therefore must
be positive or null. If kTk 6= 4, we have two real solutions. Of the two roots
we chose

DVT
(2.7)
=
4 kTk2
Since D (V T)2 , is always positive. The spacial case where kTk2 = 4 is
equivalent to T1 = T2 . If V T1 6= 0 then
=

kVk2
4(V T1 )

(2.8)

## and if V T1 = 0, becomes infinite and we use semicircles, as shown in

11

2.1

Biarc formulation

12

Figure3.
T

P
1

## Figure 3: Biarc for given data (P1 , T1 ), (P2 , T2 ) when is infinite.

For any we can find joint point J and unit tangent vector TJ at J as follows:
J = P1 +

(T2 T1 ) + V
(T1 T2 ) + V
= P2
,
2
2

V (T1 + T2 )
2
Algorithm 1. Procedure Biarc1 ((P1 , T1 )(P2 , T2 ))
Input: Pair of data (P1 , T1 ), (P2 , T2 )
Output: Biarc composed of two arcs c1 , c2 .
TJ =

(2.9)
(2.10)

## 1. Compute V = P2 P1 and check if the vectors V, T1 , T2 are collinear. If

they are collinear then biarc is a line segment P1 P2 and STOP, otherwise
GO TO N 2.
2. Check if vector sum T1 + T2 =2, if equal then GO TO N 3, otherwise GO
TO N 4.
3. Check V T = 0 if true J = P1 + 21 V and GO TO N 6 otherwise compute
D and from equations (2.6), (2.8) and GO TO N 5.
4. compute D and from equations (2.6), (2.7).
12

2.1

Biarc formulation

13

5. Find the joint point J and the tangent vector TJ at J using (2.9), (2.10).
6. Find the unique arcs c1 , c2 satisfying properties (1),(2) of Definition 2.1.
Example 1. Let be given two points P1 = [0, 0], P2 = [4, 0] and two unit
tangent vectors T1 = (0, 1), T2 = (0, 1) at this points. Construct the biarc
for these given data.
a) To be constructed biarc for the given data first we will generate the vector
V = (P2 P1 ) = (4, 0). The vectors T1 , T2 , V are noncolinear. We choose
y
P'2

TJ
P'1
T1

c2

J
c1

P2

P1

T2

Figure 4: Biarc for the given data P1 = [0, 0], P2 = [4, 0], T1 = (0, 1), T2 = (0, 1) when
= 1.

## = 1 and compute using equation (2.2).

T1 V 21 V V
(0, 1) (4, 0) 12 16
=
=
=4
(T2 T1 1) + V T2
(0, 1) (0, 1) 1 + (4, 0) (0, 1)
Then we will find points P10 and P20 as:
P10 = P1 + T1 = [0, 1],

P20 = P2 T2 = [4, 4]
13

2.1

Biarc formulation

14

## The joint point J lie on the line P10 , P20




4
1
4
8
J=
P10 +
P20 = [0, 1] + [4, 4] = ,
+
+
5
5
5 5
and the vector TJ = P20 P10 = (4, 3) we can use as tangent vector at J.
Then we will construct two arcs c1 , c2 which are satisfying first and second
conditions of biarc definition, respectively (see Figure 4).
b) If = 4 then = 1 and points P10 = [0, 4], P20 = [4, 1]. The joint point
8
J = [ 16
5 , 5 ] and tangent vector TJ = (4, 3) at J (see Figure 5.).
y
P'1

c1

TJ
c2 P'2

T1

P2

P1

T2

Figure 5: Biarc for the given data P1 = [0, 0], P2 = [4, 0], T1 = (0, 1), T2 = (0, 1) when
= 4.

c) Let be = . Using equation (2.4) for these given data we gets following
equation
2 4 = 0
and we chose = 2.

14

2.1

Biarc formulation

15

J = P1 +

(T1 T2 ) + V
2(0, 2) + (4, 0)
= [0, 0] +
= [2, 2]
2
2

## and unit tangent vector at this point

TJ =

V (T1 + T2 )
= (1, 0)
2

TJ
J
c1

c2

T1
P2

P1

T2

Figure 6: Biarc for the given data P1 = [0, 0], P2 = [4, 0], T1 = (0, 1), T2 = (0, 1) when
= .

then it is easy construct two arcs c1 , c2 which are satisfying the first and the
second conditions of biarc definition, respectively (see Figure 6.).
Theorem 2.2. The two data (P1 , T1 ), (P2 , T2 ) can be connected by one arc
which passes through end points P1 , P2 and tangent to T1 , T2 at the end points
respectively, if the data (P1 , T1 ), (P2 , T2 ) lie in the same plane and they are
line symmetric.
Proof. Let be given two line symmetric data (P1 , T1 ), (P2 , T2 ) lying in the
same plane. If we choose = and we get P10 = P20 . Then can be construct
isosceles triangle P1 P10 P2 and always can be constructed arc into this triangle
15

2.1

Biarc formulation

16

## which has end points P1 , P2 and tangent to vectors T1 , T2 at P1 , P2 (see

Figure7).

T1

-T

P1

P2
T2

Figure 7: Biarc for the line symmetric data (P1 , T1 ), (P2 , T2 ) on the plane.

For the given planar data (P1 , T1 ), (P2 , T2 ) we will introduce following theorem.
Theorem 2.3. All joint points J of the family of biars are lies on the same
circle k, which is passing through P1 ,P2 and the having same oriented angles
with the vectors T1 and T2 .
Proof. For any data there is precisely one circle k passing through the points
P1 , P2 and having the same (oriented) angles with the vectors T1 , T2 . It is
obtained as the trajectory of the point P1 under the unique rotation transforming the data P1 , T1 into the data P2 , T2 . If the vectors are parallel, then
k degenerates into the straight line passing though P1 , P2 .
For any joint point J in the plane there are one arc c1 satisfying property (1)
of biarc definition and one arc c2 satisfying second property. These two arcs
have a common tangent at J if and only if J k. In fact, if J k, then
the angle between the circle k and the arc c1 at the point J is the same as
angle between the circle k and the vector T1 . Similarly the angle between k
16

2.2

17

Ji

T1

Ji+1
P2

P1

T2
k

## Figure 8: Family of biarcs for given data (P1 , T1 ) and (P2 , T2 ).

and the arc c2 at the point J equal to the angle between the circle k and the
vector T2 . Since the circle k has the same angle with T1 and T2 , the two arcs
c1 , c2 join with G1 continuity at J. The orientations coincide also, since one
of the arcs c1 , c2 will be inside and one outside the circle k. Suppose, on the
other hand, that a G1 interpolating biarc is constructed. The circle passing
though P1 , J and P2 must have the same angle with both circular arcs c1 ,
c2 and therefore also with the vectors T1 , T2 . It is hence identical with the
in [14].
circle k and J k. This proof produced by Zbynek Sr

2.2

## Definition 2.2. Piecewise circular curve is just a finite sequence of circular

arc segments.
To construct a piecewise circular curve, recall that it is possible to construct
17

2.2

18

## a circular arc that passes through three noncollinear points. Therefore, by

providing a sequence of points {P1 , P2 , ..., Pn } with n 1 = 2m an even
number, one can construct a circular curve by finding the circle that passes
through each set of three points P2k1 , P2k and P2k+1 with k = 1, 2.., m and
then finding the circular arc with end points P2k1 , P2k+1 and passes through
P2k . We note it is not necessary to require that the points P2k1 , P2k and P2k+1
to be noncollinear. The case of three collinear points is covered by noticing
in the construction of a circle through three noncollinear points as the the
points get closer to being collinear the circle produced approaches a straight
line. Therefore, for three collinear points the circle through the three points
is a straight line. The circular arc is then the line segment [P2k1 , P2k+1 ].
P3

P6

P2
P4

P5

P7

P1
Figure 9: Nonsmooth piecewise circular curve

The advantage of piecewise circular curves is that one may with the appropriate choice of the points {Pi } obtain a smooth model. It is important that the
appropriate choice of the points follow simple rules that is easy to compute.
To develop these rules, we make the following observations.
For a piecewise circular curve to be smooth, we need the tangent vectors
Ti at the each of points Pi (i = 1, 2, ..., n).
It is possible to construct a piecewise circular curve consisting of two
circular arcs (biarc) by giving the two points P1 , P2 and the tangent

18

2.2

19

## vectors T1 , T2 at P1 , P2 . (see: Construction of G1 continuity biarc for

given data.
Generalizing the observation, one can construct a smooth circular arc
consisting of n 1 arcs by giving n points P1 , P2 , ..., Pn and a tangent
vector T1 at P1 . First construct the circular arc starting at P1 and ending
at P2 using the tangent vector T1 . Compute the tangent vector at P2
from this first arc, and use that tangent vector to construct the circular
arc from P2 to P3 .
Theorem 2.4. All given data (P1 , T1 ), (P2 , T2 ), ..., (Pn , Tn ) can be connected
by smooth PCC.
Proof. For all pair (Pi , Ti ), (Pi+1 , Ti+1 ) we will construct biarcs bi,i+1 , with
the end points Pi , Pi+1 and tangent to the vectors Ti , Ti+1 at the end points.
All these biarcs bi,i+1 will compose the PCC.

P2
T1

T2

Pi

Ti

P1
Pn
Tn
Figure 10: Smooth Piecewise Circular Curve for the given data (Pi , Ti )

19

2.2

20

## Input: data (Pi , Ti ), i = 1, ..., n, n 2

Output: PCC (Biarc spline) bn = {bn1 , ..., bnn }
1. Construct the sequence of biarc interpolants of the pair of data
(Pi , Ti ), (Pi+1 , Ti+1 ):
bni = Biarc((Pi , Ti ), (Pi+1 , Ti+1 )) f or i = 1, ..., n
and collect them to form the PCC (biarc spline) bn .
Example 2. Let be given points P1 = [2, 0], P2 = [0, 0], P3 = [2, 2], P4 =
[4, 0], P5 = [4, 1] and unit tangent vectors T1 = (1, 0), T2 = ( 53 , 45 ), T3 =
(1, 0), T4 = (1, 0), T5 = (1, 0) at these points. Using the Algorithm 2 we
y

T5

P5
J4

J1
P1

T1

P2

P4

T2

T4

J3

J2
P3

T3

Figure 11: Smooth Piecewise Circular Curve for the given data (Pi , Ti ) where i = i

will construct smooth PCC (where i = i i = 1, ..., 4, see Figure 11) which
is composed by four biarcs given by:
1 =

21 4,

2 =

46 6,

20

3 = 1,

4 =

1
2

2.3

21

and
"
J1 =

21 9 2 21 8
,
,
5
5

#
11 46 7 2 46
J2 =
,
,
5
5
"

9 1
J4 = ,
2 2

J3 = [3, 1],

## In Figure 12 shown PCC, where i 6= .i ,

i = 1, ..., 4

y
J1
P1

T1

T5

P5
J4

P2

P4

J2 T 2

T4

J3

P3

T3

Figure 12: Smooth Piecewise Circular Curve for the given data (Pi , Ti ) where 6= .

2.3

## Tangent vectors of the polygon

In spatial cases we are given only set vertices of polygon and we need to obtain
tangent vectors at these points. In this subsection we will introduce how to
compute tangent vectors for the given set vertices of polygon.
In [5], a technique was discussed to interpolate the tangent vectors to ensure
that the circular are passing through the adjacent points. In this work, we used
an interpolation method discussed in [5] to find the corresponding tangent
vectors. The tangent vector Ti at the point Pi can be approximated as a

21

2.4

## Approximation of curves by smooth PCCs.

22

vector:
Ti = (Pi Pi1 )

kPi+1 Pi k
kPi Pi1 k
+ (Pi+1 Pi )
kPi Pi1 k
kPi+1 Pi k

(2.11)

Equation (2.11) gives the tangent vector Ti at Pi such that the circular arc
y

y
C1

T1

C2

T1

T2

C1
O2

O2

T2

C2

O1

O1

(b)

(a)

Figure 13: (a) C-shaped biarc, (b) S-shaped biarc in the plane

will pass through the three points Pi1 , Pi , Pi+l . The angles 1 and 2 can be
found between the tangent vectors Ti at the knot points and the chord line
(see Figure 13).
2.4

## Given a user defined tolerance , a piecewise circular curve is sought so that

the PCC does not deviate from the given curve more than . That is, for any
given point P lying on the piecewise circular curve,
kc (tp ) P k < ,

(c (tp ) P ) c0 (tp ) = 0

## where tp is the parameter corresponding to the projection of P onto the given

curve. To obtain such an approximation, the following two conceptual procedures are applied.
22

2.4

23

## Let be given a C 1 continuous curve c(t), t [t1 , t2 ]. Suppose, that the G1

data are taken from a C 1 continuous curve c(t).
c0 (t1 )
P1 = c(t1 ), T1 = 0
kc (t1 )k

c0 (t2 )
P2 = c(t2 ), T2 = 0
kc (t2 )k

(2.12)

## By using construction of biarc we will construct biarc for this data.

Algorithm 3. Procedure Biarc2 (c(t), t [t1 , t2 ])
Input: A C 1 continuous curve c(t) defined in a closed interval c(t), t [t1 , t2 ],
having a right derivative at t1 and a left derivative at t2 .
Output: Biarc composed of two arcs c1 , c2 .
1. Compute the boundary data (P1 , T1 ), (P2 , T2 ) using (2.12).
2. Using Algorithm 1 construct biarc for the data (P1 , T1 ), (P2 , T2 ).
Algorithm 3 can be used to formulate an efficient conversion procedure of
arbitrary (piecewise) G1 continuous curves into arc splines. In the sequel we
present a simple non-adaptive algorithm for the conversion of C 1 continuous
curves.
Algorithm 4. Procedure PCC2 (c(t), t [0, 1])
Input: A C 1 curve c(t), t [0, 1], tolerance 
Output: PCC (Biarc spline) bn = {bn1 , ..., bnn } approximating c(t)
1. Set n = 1
2. Construct the sequence of Biarc interpolants:



i

1
i
bni = Biarc0 c(t),
,
f or i = 1, ..., n
n n
and collect them to form the biarc spline bn .
3. Evaluate the distance of the curve c(t), t [0; 1] from the spline bn . If
the distance is greater than  then set n = 2n and GOTO (2). Otherwise
STOP.
23

24

NURBS approximation

3.1

B-spline curve

Definition 3.1. The B-spline [8] curve of degree k defined by control points
V1 , ..., Vn , n k and knot vector U = (u1 , ..., um ) is
c(u) =

n
X

Ni,k (u)Vi

3.1

i=1

## where Ni,k are B-spline basis functions (polynomials) of degree k.

for k = 1

(
Ni,1 =

1, if ui u < ui+1
0, otherwise.

for k > 1
Ni,k =

u ui
ui+k u
Ni,k1 (u) +
Ni+1,k1 (u)
ui+k1 ui
ui+k ui+1

3.2

The knot vector uniquely determines the B-splines as it is obvious from (3.2).
The relation between the number of knots m, the degree k of Ni,k and the
number of control points n is given by m = n + p + 1. The sequence of
knots in the knot vector U is assumed to be nondecreasing, i.e. ui ui+1 .
Each successive pair of knots represents an interval [ui , ui+1 ) for the parameter
values to calculate a segment of a shape.
Since the knot spacing could be nonuniform, the B-splines are no longer the
same for each interval [ui , ui+1 ) and the degree of the B-Spline can vary. Considering the whole range of parameter values represented by the knot vector,
the different B-splines build up continuous (overlapping) blending functions
Ni , p(u), as defined in (3.2), over this range. These blending functions have
the following properties:
24

3.1

B-spline curve

25

## 1. Ni,k (u) 0, for all i, k, u;

2. Ni,k (u) = 0, if u not in [ui , ui+k+1 ), meaning local support of k + 1 knot
spans, where Ni,k (u) is nonzero;
3. if u in [ui , ui+1 ), the non-vanishing blending functions are Nik,k (u), . . . ,
Ni,k (u)
4.

i
P

Nj,k (u) =

j=ik

n
P

i=0

## 5. in case of multiple knots, 0/0 is deemed to be zero.

Important properties of B-spline curves
1. B-spline curve c(u) is a piecewise curve with each component a curve of
degree k.
2. Equality m = n + k + 1 must be satisfied.
3. Clamped B-spline curve c(u) passes through the two end control points
V1 and Vn .
4. Strong Convex Hull Property: A B-spline curve is contained in the convex
hull of its control polygon. More specifically, if u is in knot span [ui , ui+1 ),
then c(u) is in the convex hull of control points Vik , Vik+1 , ..., Vi .
5. Local Modification Scheme: changing the position of control point Vi
only affects the curve c(u) on interval [ui , ui+k+1 ).
6. c(u) is continuous curve of order C k at knots of multiplicity on curves
of degree k

25

3.2

3.2

NURBS curve

26

NURBS curve

NURBS (Non Uniform Rational B-spline [8]) are industry standard tools for
the representation and design of geometric objects . Some reasons for the use
of NURBS are:
offer one common mathematical form for both, standard analytical shapes
(e.g. conics) and free form shapes;
provide the flexibility to design a large variety of shapes;
can be evaluated reasonably fast by numerically stable and accurate algorithms;
are invariant under affine as well as perspective transformations;
are generalizations of non-rational B-splines and non-rational and rational Bezier curves and surfaces.
Let us consider the way of introducing homogeneous coordinates to a B-spline
curve and derive the NURBS definition.
Given n control points V1 , ..., Vn , n k and knot vector U = (u1 , ..., um ) of
m knots, the B-spline curve of degree k defined by these parameters is the
following:
n
X
c(u) =
Ni,k (u)Vi
i=1

## Let control point Vi be rewritten as a column vector with four components

with the fourth one being 1:
Vi = [xi , yi , zi , 1]T .
We can treat this Vi as a homogeneous coordinate. Since multiplying the
coordinates of a point (in homogeneous form) with a non-zero number does
26

3.2

NURBS curve

27

not change its position, let us multiply the coordinates of Vi with a weight wi
to obtain a new form in homogeneous coordinates:
Viw = [wi xi , wi yi , wi zi , wi ]T .
Note that Viw and Vi represent the same point in homogeneous coordinate.
Plugging this new homogeneous form into the equation of the above B-spline
curve, we obtain the following:
P

n
Ni,k (u)(wi xi )

i=1
P

wi xi
n

n
n
Ni,k (u)(wi yi )

X
X

wi yi i=1

cw (u) =
Ni,k (u)Viw =
Ni,k (u)
.
n
P
wz =

i i (u)(wi zi )
i=1
i=1

i=1
wi
n
P

Ni,k (u)wi
i=1

Therefore, point cw (u) is the original B-spline curve in homogeneous coordinate form. Now, let us convert it back to Cartesian coordinates by dividing
cw (u) with the fourth coordinate:

w
c (u) =

n
P

Ni,k (u)(wi xi )

i=1
n
P

Ni,k (u)wi

i=1
n
P

Ni,k (u)(wi yi )

i=1
n
P

Ni,k (u)wi

i=1
n
P

Ni,k (u)(wi zi )

i=1
n
P

Ni,k (u)wi

i=1

P
n

Ni,k (u)wi

i=1

= P
n

Ni,k (u)wi

i=1

1
Finally, we have a clean form as follows:

27

xi

yi
.
zi

3.2

NURBS curve

28

n
P

Ni,k (u)wi Vi

c(u) = i=1
n
P

Ni,k (u)wi

i=1

## Definition 3.2. A NURBS curve c(u), which is a vector-valued piecewise

rational polynomial function, is defined as:
n
P

c(u) =

Ni,k (u)wi Vi

i=1
n
P

3.3
Ni,k (u)wi

i=1

where wi are weights, Vi are control points (vector) and Ni,k are normalized
B-spline basis functions of degree k.
We will present description for some of curves in terms of NURBS theory,
which are often using in Computer-Aided Design system.
1. Line segment
Open line segment can be described as NURBS with order k = 2, weights
wi = 1 and knot vector U = (0, 0, 1, ..., j 2, j 1, j 1).
For closed line segment reducing knot vector: U = (0, 1, ..., j 1, j).

## 2. Circle and ellipse

Circle with center at [0, 0, 0], radius r in the plane xy.
V1 = (r, 0, 0, 1),

V2 = (0, r, 0, 0),

V3 = (r, 0, 0, 1),

V4 = (0, r, 0, 0)

## and order k=2, knot vector U = (0, 0, 0, 1, 2, 2, 2).

Ellipse with polyaxis a, b, and axis lie on line x and y:
V1 = (a, 0, 0, 1),

V2 = (0, b, 0, 0),
28

V3 = (a, 0, 0, 1),

V4 = (0, b, 0, 0)

3.3

29

## and order k = 2, knot vector U = (0, 0, 0, 1, 2, 2, 2).

3. Biarc
For a biarc curve let u be a parameter value computed as
u=

kP1 Jk
kP1 Jk + kJP2 k

## then the knot vector is simply

U = (0, 0, 0, u, u, 1, 1, 1)
which can be rescaled to any other span to yield a more general from
U = (u1 = u2 = u3 , u4 = u5 , u6 = u7 = u8 )
The weights are assigned as follows [8]:
w0 = w2 = w4 = 1 w1 = cos(1 ) w3 = cos(2 )
where 1 and 2 denote the half sweep angles of the first and the second
arc, respectively.
3.3

## Given a user defined tolerance , a piecewise circular curve is sought so that

the PCC does not deviate from the NURBS curve more than . That is, for
any given point P lying on the piecewise circular curve,
kc (up ) P k < ,

(c (up ) P ) c0 (up ) = 0

29

(3.4)

3.3

30

## where up is the parameter corresponding to the projection of P onto the

NURBS curve. To obtain such an approximation, the following two conceptual procedures are applied.
Algorithm 5. Polygonal decomposition of NURBS ((c(u), U = (u1 , ..., un ))
Input: Control points, weights, knot vector of NURBS curve Vi , wi , U =
(u1 , ..., un ), tolerance .
Output: Vertices of the polygon.
1. Initialize a stack whith the curve c(u)
2. If the stack is empty then STOP. Otherwise GO TO N 3.
3. B Pop the stack.
4. Set l[P1 , Pk ] straight between P1 , Pk .
5. M = max[distance(l[P1 , Pk ], Pi )], i = 1, ..., k. Pi B
6. If M <  output P1 , Pk , otherwise subdivide B at one-half the parameter
range.
7. Add the right and left pieces to the stack.
8. GO TO N 2.
Algorithm 6. Procedure PCC approximation of NURBS ((c(u), U = (u1 , ..., un ))
Input: Control points, weights, knot vector of NURBS curve Vi , wi , U =
(u1 , ..., un ), tolerance 
Output: PCC (Biarc spline) approximating c(u).
1. Decompose the NURBS to line segments with tolerance .
2. Compute the unit end tangent vectors at the end points of this line
segments using (2.11), and get boundary data.
30

3.3

31

## 3. Construct the PCC for these data.

The process of working of the algorithm is shown into example (3).
Example 3. Let be given NURBS curve which have the following data:
Points : P0 = [0.1, 0.2], P1 = [0.25, 0.4], P2 = [0.4, 0.2], P3 = [0.5, 0.9],
P4 = [0.6, 0.2], P5 = [0.7, 0.5], P6 = [0.8, 0.2], P7 = [0.9, 0.2].
Weights at these points : w0 = 1, w1 = 1, w2 = 1, w3 = 3, w1 = 4,
w5 = 1, w6 = 1, w7 = 1.
The knot vector : U = {0, 0, 0, 1, 2, 3, 4, 5, 6, 6, 6}.
Let be given tolerance  = 1. Using Algorithm 6 we will find PCC which
approximate the given NURBS curve with gien tolerance.

## This NURBS curve is drawn in Figure 14.

Applying the polygonal decomposition Algorithm 5 we approximate the given
NURBS curve with the polygon with given tolerance, which is shown in Figure 15. Then we find unit tangents on the vertices of the obtained polygon.
So, we will have the data for biarcs. And then we can build biarcs for these
data which represent PCC. (see Figure 16). In the Figure 17 shown diffenence between NURBS curve and biarc.
31

3.3

32

32

3.4

3.4

33

## Algorithm 6 was implemented in Java programming language. This program

compute (and draw) approximation of NURBS curve by PCC with the given
tolerance. The initializing parameters of the program are:
Number of control points and degree of NURBS curve.
(x, y)-coordinates and weight for every control point.
knot vector.
The program constructs polygonal decomposition of NURBS curve to segments with the tolerance. This tolerance is possible to change in runtime by
slider-control which is located in the left of the screen. After constructing
of the polygon the Java program are computed corresponding unit tangent
vectors at every vertex of the polygon. Using Algorithm 2 we construct PCC
which passes through vertices of the polygon and tangent to corresponding
unit tangent vectors at these vertices. The output of the program are 6 graphs
(Figure18):
1. NURBS curve and control polygon.
2. Basis functions of NURBS curve.
3. Polygonal decomposition of NURBS curve.
4. Difference between the polygon and NURBS curve.
5. Biarc approximation of NURBS curve.
6. Difference between the PCC and NURBS.
In the first graph the vertices of the control polygon of NURBS can be changed
in runtime by mouse. Similarly, in the second graph the weights of the control
points can be also changed.
33

3.4

34

NURBS curve

10

0.1
Tolerance

34

35

## PCCs have many potential applications in geometric modeling. Some of these

applications are described in this section.
4.1

## Definition 4.1. Let be a developable ruled surface and let be a curve in

one of s tangent planes, say T . The surface traced out by while T rolls
on (without gliding along ) is called a generalized surface of revolution.
The curve is called generator, profile curve, or meridian curve. We call
the axial developable.
Choosing a circle for a meridian (or profile) curve T we obtain a pipe
surface [6].
Technical designers need connections of central curves of pipes. These connections have better aerodynamical properties when connecting central curve
has a constant curvature. PCC has piecewise constant curvature, therefore
we can use PCC in these connections for getting better results. And further
pipe elements with a circular central curve are much easer produced than pipe
connections based on arbitrary spatial curves. They are clearly represented
in Figures 19, 20
Application of PCC in pipe connections can be seen in the following example:
Example 4. Let be given two cylinders 1 and 2 .
1 :
2 :

x2 + z 2 = 0.3,
y 2 + z 2 = 0.3,

y [2, 0]
x [2, 4]

We need connections of central curves of these cylinders. We will use the biarc
for connection of central curves. The central curves of these cylinders are line

35

4.1

36

## Figure 19: Two pipes and their connecting biarc

Figure 20: Two given pipes (blue) and their connecting pipe (red).

36

4.1

## Circular pipe connections

37

segments:
y [2, 0],

x [2, 4]

First we choose two points P1 = [0, 0, 0], P2 = [2, 0, 0] lying on the central
curves respectively and which must be connected. then we will choose two
unit tangent T1 = (0, 1, 0), T2 = (1, 0, 0) vectors at P1 , P2 which have the
same direction with the central curves. Then we will compute the vector
V = (P2 P1 ) = (2, 0, 0). Using Algorithm 1 we can construct biarc with the
joint point
!

3 3 31
J=
,
2
2
and with the tangent vector
!
3 3 1 3

,
2 32 2 32

TJ =

at J (see Figure 21). Then we can construct pipe around biarc with radius
r = 0.3 and obtain pipe connection of two given cylinders (see Figure 22).
There was used the software Rhinoceros (version 3.0) in this example.

Figure 21: Two given cylinders (blue and red) and connecting their axis.

37

4.1

## Circular pipe connections

38

Figure 22: Two given cylinders (blue and red) and their connecting pipe (yellow).

Figure 23: Two given cylinders (blue and red) and their connecting pipe (yellow) on perspective.

38

4.2

4.2

39

## The envelope of a one-parameter family t of spheres with variable radius

is called canal surface [6]. The curve s of the spheres centers is called spine
curve. Any sphere of the family t touches along a circle c which is called
characteristic. The class of canal surfaces contains the class of pipe surfaces
as well. The radius function of the spheres t is constant for a pipe surface.
Let be given two canal surfaces S and S 0 , we want to find a surface Sb that
can smoothly join the given surfaces together. This process is called blending
and the third surface is a blending surface of the given surfaces. Of course, the
blending surface is not uniquely defined. It is shown in following Figure 24
(in yellow) that blends the green and the blue surfaces. The blending surface
provides a smooth transition from the green surface to the blue one.

## Figure 24: Two canal surfaces and their blending surface

To find this blending surface we will use PCCs. First we need edges
S, 0 S 0 of this surfaces which should be connected. These edges are for
39

4.2

## Blending of canal surfaces

40

canal surfaces circles. We will find a point P1 on the edge which has a
minimum distance from edge 0 and point P10 on edge 0 which has a minimum
distance from point P1 . We generate n 1 points Pi , i = 2, ..., n on , and
n 1 points Pi0 , where i = 2, ..., n on 0 as:
kP1 P2 k = kP2 P3 k = ... = kPn1 Pn k = kPn P1 k = = const
0
kP10 P20 k = kP20 P30 k = ... = kPn1
Pn0 k = kPn0 P10 k = 0 = const

## We generate unit vectors Ti , T0i on surfaces S, S 0 at points Pi , Pi0 with

the same basic direction with minimum curvature of surfaces at points Pi ,
Pi0 respectively. Then biarcs bn can be constructed for all pairs of data
(Pi , T), (Pi0 , T0 ). Then we generate points on this biarcs as:
kP1 P11 k = kP11 P12 k = ... = kP1n P10 k = 1 = const,

## P21 , P22 , ..., P2n b2 ,

...
kPn Pn1 k = kPn1 Pn2 k = ... = kPnn Pn0 k = n = const,

## Pn1 , Pn2 , ..., Pnn bn ,

then for all sets of points {Pj1 }, {Pj2 }, ..., {Pjn }, where j = 1, ..., n we will
construct smooth PCCs denoted by pn . All constructed biarcs bn , Piecewise
circular curves pn and two circles , 0 generate a net of blending surface,
which blends two given canal surfaces.
Example 5. Let be given two canal surfaces, ie. cylinder S and cone S 0 .
S:

y 2 + z 2 = 1,

x [5, 1]

y2 z2
x2
+
= ,
x [1, 4]
9
9
16
Using biarcs we will find their blending surface. First of all we will choose
S0 :

one point P1 on surface S and find a point P10 on surface S 0 which has the
40

4.3

41

## minimum distance from P1 .

Let be P1 = [1, 1, 0] then we obtain P10 = [1, 34 , 0]. To construct the biarc we
need unit tangent vectors T1 , T01 at points P1 , P10 respectively. We will choose
the unit tangent vectors on the same basic direction of surfaces S, S 0 which
has the minimum curvature at points P1 , P10 respectively. Then we will get


4 3
0
, ,0
T1 = (1, 0, 0),
T1 =
5 5
Using Algorithm 1 we will construct biarc for data (P1 , T1 ) and (P10 , T01 )
(see Figure 25). The axes of the given canal surfaces lie on the same line.
Around that line by rounding the constructed biarc we will obtain corresponding blending surface (see Figure 26).

Figure 25: Two given surfaces and biarc joining of these surfaces.

4.3

## Approximation of surface/surface intersections

PCC can be also used in approximation of surface intersections. Approximation intersection edges have been investigated in the past by Jaroslaw
Rossignac and A. G. Requicha [11]. We will introduce their work.
41

4.3

## Approximation of surface/surface intersections

42

Figure 26: Two given surfaces (blue and red) and their blending surface (yellow).

Figure 27: Two given surfaces (blue and red) and their blending surface (yellow) on perspective.

42

4.3

43

## This section discusses the computation of PCC approximations for intersection

edges between any two natural faces (i.e., faces of natural primitives: blocks,
spheres, cylinders, cones, and tori, shown in Figure 29). Their method is a
variation of the parametric grid method [12] and is composed of three steps:
1. Generate intersection points and tangents.
2. Sort the points along the edges.
3. Interpolate the points with PCCs.

Figure 28: Natural primitives: block, sphere, cylinder, cone, and tori

## To meet accuracy requirements, one may have to iterate this sequence by

recursively refining the approximation in selected intervals.
We describe the steps in more detail, let us summarize their effect and indicate
how they differ from techniques reported elsewhere.
The first step requires the computation of curve/surface intersections. For the
faces of natural primitives, such computations are reduced to the intersection
of lines or circles with natural surfaces. An efficient implementation of such
computations is described in [10]. For each intersection point, the tangent to
43

4.3

## Approximation of surface/surface intersections

44

the intersection curve is derived from the cross product of the normals to both
surfaces at the intersection point.

Figure 29: Constant-parametr curves on faces of natural primitives: Lines and circles.

## The second step is the source of inefficiencies in the algorithms discussed in

[16] and [12]. they map intersection points to an array of cells in the twodimensional parameter space of one primitive face. (Hereafter, for brevity we
refer to primitive faces as patches.) This method locates consecutive points
practically without searching. Because heuristic methods are inadequate, rare
matching ambiguities are addressed by recursively subdividing certain cells
into four subcells.
In the last step, they interpolate pairs of consecutive intersection points and
tangents with twisted biarcs, thus generating a PCC that interpolates the
actual edge at all intersection points. Computation of twisted biarcs and
representation of the PCC were discussed earlier.
To obtain a continuous parametrization of the whole curve, they must maintain consistency between the orientation of two consecutive biarcs. A consistent orientation of the biarcs may be propagated along the PCC curve by
44

4.3

## Approximation of surface/surface intersections

45

F1

P1 P2 P3 P4 P5 P6

P7
F2

Figure 30: Intersection point lying in one face only: The point P2 is out of F2 , but is
needed to specify the biarc (P2 , P3 ) with in partly lies on F2 .

F1

F2

Figure 31: Intersection allmost parallel to u-curves: Using only u-curves of F1 , we miss the
intersection edge.

Figure 32: Parametric grid: Intersection points (left) are mapped into cells of the parametric grid (right).

45

4.3

## Approximation of surface/surface intersections

P4

46

P4

P1
P1
P3
P3

P2

P2

Figure 33: Errors of heuristic matching: Given four intersection points P1 to P4 , and the
associated tangents, most heuristic approaches would match P1 with P4 (left), and not
with P2 (right), which might be the correct solution.

matching the ending point of one biarc with the starting point of the next
biarc along the curve. Self-intersecting edges are approximated by PCCs that
do not reflect their singularities and therefore can be consistently oriented.
Singularities
Several singularities may arise:
1. Two surfaces may be coincident.
2. Two surfaces may be tangent at isolated points.
3. Two surfaces may be tangent along a curve.
4. Intersection curves may self-intersect.

46

47

Conclusion

## As mentioned in the introduction, the basis of this thesis consists in studying

and applications the piecewise circular curves (PCC) in geometric modeling.
It has five sections. The first section is introduction. In the second section
we introduce fundamentals of PCCs, their construction and representation.
The third section contains definitions of B-spline and NURBS curves and the
algorithm of NURBS approximation by PCCs. In the next section we introduce three applications of PCCs in geometric modeling. The first application
solves problem of pipe connections by using PCCs. The second application
presents the PCC blending operation of canal surfaces. And the last describes
approximation of surfaces intersections by PCCs.
The tasks that were determined before the author are mentioned in the beginning of the thesis. These tasks have solved mainly. The self theoretic results
contained in the Theorems 2.1, 2.2 and 2.4, which prove that the given data
(points and unit tangent vectors at these points) can be always connected by
smooth PCCs. The algorithms to construct biarc, PCC and to approximate
NURBS curves with PCC are presented in the Algorithms 1, 2, 5, 6, respectively. In the appendix we have introduced a program which implements the
Algorithm 6. This program has been written in JAVA language as JAVA
applet (see www-page http://home.zcu.cz/ ulugbek). The first and the second applications which are presented in the fourth section of the thesis have
proposed for the first time in geometric modeling.
Other resources that close with the themes can be found in [9], [16], [13],
[3]. Thus our future aim is expand this thesis in several areas, for example
application of PCCs in sphere geometries (Laguerre, Mobius, Lie geometry).

47

48

Appendix
public void Fun()
{
double step = (ti[nt-1]-ti[0])/(w2-.9), t = ti[0];
Tmin = (int)((ti[k-1]-ti[0])/step) + 1;
Tmax = (int)((ti[n1]-ti[0])/step);
int i1 = 0;
for (int l = 0; l < w2; l++)
{
while (t >= ti[i1] ) i1++;
int i = i1-1;
col[l] = iColor[(i+8-k) % 7];
for (int j = 0; j < nt; j++) N[j][l] = 0;
N[i][l] = 1;
for (int m = 2; m <= k; m++){
int jb = i-m+1; if (jb < 0) jb = 0;
for (int j = jb; j <= i; j++){
N[j][l] = N[j][l]*(t - ti[j])/(ti[j+m-1] - ti[j]) +
N[j+1][l]*(ti[j+m] - t)/(ti[j+m] - ti[j+1]);}}
t += step;
}
}
public void drawSpline()
{
int X,Y;
buffGraphics.setColor(Color.blue);
buffGraphics.drawLine(15, h1+h1, 15, h1);
buffGraphics.drawRect(15-1, h1-tolPos, 3, 3);
buffGraphics.drawString("10", 18, h1);
buffGraphics.drawString("0.1", 18, h1+h1);
buffGraphics.drawString("Tolerance", 0, h1+h1+30);
for (int i = 0; i < n1; i++)
{
X = (int)Px[i]; Y = h1-(int)Py[i];
buffGraphics.drawRect(X-1,Y-1, 3,3);
}
if ( k > 2 )
{

48

49

buffGraphics.setColor(Color.gray);
Stroke oldStroke = buffGraphics.getStroke();
buffGraphics.setStroke(new BasicStroke(1,
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10,
new float[] { 3, 8 }, 0));
int Xo = (int)Px[0], Yo = h1-(int)Py[0];
for (int i = 1; i < n1; i++)
{
X = (int)Px[i]; Y = h1-(int)Py[i];
buffGraphics.drawLine(Xo,Yo, X,Y);
Xo = X; Yo = Y;
}
buffGraphics.setStroke(oldStroke);
}
double sX = 0, sY = 0, sW = 0;
for (int j = 0; j < n1; j++)
{
sX += Px[j]*wi[j]*N[j][Tmin];
sY += Py[j]*wi[j]*N[j][Tmin];
sW += wi[j]*N[j][Tmin];
}
double Xold = (sX/sW), Yold = h1-(sY/sW);
double x,y;
polygon.clear();
points.clear();
Color cl = col[Tmin+1];
for (int k = Tmin+1; k <= Tmax; k++)
{
sX = 0; sY = 0; sW = 0;
for (int j = 0; j < n1; j++)
{
sX += Px[j]*wi[j]*N[j][k];
sY += Py[j]*wi[j]*N[j][k];

49

50

sW += wi[j]*N[j][k];
}
x = (sX/sW); y = h1-(sY/sW);
if(col[k] != cl)
{
subdivide();
cl = col[k];
points.clear();
}
if ( (x < w2) && (Xold < w2) )
{
buffGraphics.setColor(col[k]);
buffGraphics.drawLine((int)Xold,(int)Yold, (int)x,(int)y );
buffGraphics.setColor(Color.BLUE);
buffGraphics.drawLine((int)Xold+w2, (int)Yold+h1,
(int)x+w2,(int)y+h1);
buffGraphics.drawLine((int)Xold+w2,(int)Yold+h1+h1,
(int)x+w2,(int)y+h1+h1 );
}
Xold = x; Yold = y;
}
subdivide();
GeneralPath path = new GeneralPath();
double Xnew, Ynew;
double T1x,T1y, T2x,T2y;
double d1,d2,s,r;
double a,b,c,D,alfa;
DPoint P0 = new DPoint(0,0);
DPoint P1 = new DPoint(0,0);
DPoint P2 = new DPoint(0,0);
DPoint P3 = new DPoint(0,0);
DPoint P4 = new DPoint(0,0);
DPoint V = new DPoint(0,0);
DPoint O = new DPoint(0,0);
DPoint Ctrl1 = new DPoint(0,0);

50

51

## DPoint Ctrl2 = new DPoint(0,0);

int size = polygon.size();
DPoint dp = (DPoint)polygon.get(0);
Xold = dp.x; Yold = dp.y;
dp = (DPoint)polygon.get(1);
x = dp.x; y = dp.y;
dp = (DPoint)polygon.get(2);
Xnew = dp.x; Ynew = dp.y;
d1 = Math.sqrt((Xnew-x)*(Xnew-x) + (Ynew-y)*(Ynew-y));
d2 = Math.sqrt((Xold-x)*(Xold-x) + (Yold-y)*(Yold-y));
T1x = (x-Xold)*d1/d2 + (Xnew-x)*d2/d1;
T1y = (y-Yold)*d1/d2 + (Ynew-y)*d2/d1;
D = Math.sqrt(T1x*T1x + T1y*T1y);
T1x /= D; T1y /= D;
buffGraphics.setColor(Color.black);
for(int i=2;i<size-1;i++)
{
Xold = x; Yold = y;
x = Xnew; y = Ynew;
dp = (DPoint)polygon.get(i+1);
Xnew = dp.x; Ynew = dp.y;
// tangents vector calculations
d2 = d1;
d1 = Math.sqrt((Xnew-x)*(Xnew-x) + (Ynew-y)*(Ynew-y));
T2x = (x-Xold)*d1/d2 + (Xnew-x)*d2/d1;
T2y = (y-Yold)*d1/d2 + (Ynew-y)*d2/d1;
D = Math.sqrt(T2x*T2x + T2y*T2y);
T2x /= D; T2y /= D;
P0.x = Xold; P0.y = Yold;
P4.x = x; P4.y = y;
V.x = P0.x - P4.x; V.y = P0.y - P4.y;
a = 2*(T1x*T2x+T1y*T2y - 1);
b = 2*(V.x*(T1x+T2x)+V.y*(T1y+T2y));
c = V.x*V.x + V.y*V.y;

51

52

## if(Math.abs(a) < 0.01) alfa = -c/b;

else
{
D = Math.sqrt(b*b-4*a*c);
alfa = (-b+D)/(a+a);
if(alfa < 0) alfa = (-b-D)/(a+a);
}
P1.x = P0.x + alfa*T1x; P1.y = P0.y + alfa*T1y;
P3.x = P4.x - alfa*T2x; P3.y = P4.y - alfa*T2y;
P2.x = (P1.x+P3.x)/2; P2.y = (P1.y+P3.y)/2;
s = (P0.x + T1y/T1x*P0.y - T1y/T1x*P2.y - P2.x)/(1 T1y*(P2.x-P1.x)/(T1x*(P2.y-P1.y)));
O.x = P2.x + s; O.y = P2.y - (P2.x-P1.x)/(P2.y-P1.y)*s;
r=Math.sqrt((O.x-P0.x)*(O.x-P0.x) + (O.y-P0.y)*(O.y-P0.y));
a = (P0.x+P2.x)/2 - O.x;
b = (P0.y+P2.y)/2 - O.y;
c = Math.sqrt(a*a + b*b);
Ctrl1.x = r*a/c + O.x; Ctrl1.y = r*b/c + O.y;
s = (P4.x + T2y/T2x*P4.y - T2y/T2x*P2.y P2.x)/(1 - T2y*(P2.x-P3.x)/(T2x*(P2.y-P3.y)));
O.x = P2.x + s; O.y = P2.y - (P2.x-P3.x)/(P2.y-P3.y)*s;
r = Math.sqrt((O.x-P4.x)*(O.x-P4.x) + (O.y-P4.y)*(O.y-P4.y));
a = (P4.x+P2.x)/2 - O.x;
b = (P4.y+P2.y)/2 - O.y;
c = Math.sqrt(a*a + b*b);
Ctrl2.x = r*a/c + O.x; Ctrl2.y = r*b/c + O.y;
//biarc aproximations drawing
path.reset();
path.moveTo((float)P0.x, (float)P0.y+h1+h1);

52

53

## Ctrl1.y+h1+h1, (float)P2.x, (float)P2.y+h1+h1);

(float)P4.x, (float)P4.y+h1+h1);
buffGraphics.setColor(Color.black);
buffGraphics.draw(path);
path.reset();
path.moveTo((float)P0.x+w2, (float)P0.y+h1+h1);
(float)P2.x+w2, (float)P2.y+h1+h1);
(float)P4.x+w2, (float)P4.y+h1+h1);
buffGraphics.setColor(Color.red);
buffGraphics.draw(path);
buffGraphics.drawRect((int)Xold+w2-1, (int)Yold+h1+h1-1, 3, 3);
//polygons drawing
buffGraphics.setColor(Color.black);
buffGraphics.drawLine((int)Xold,(int)Yold+h1, (int)x,(int)y+h1);
buffGraphics.setColor(Color.red);
buffGraphics.drawRect((int)Xold-1,
(int)Yold+h1-1, 3, 3);
buffGraphics.drawLine((int)Xold+w2,(int)Yold+h1,
(int)x+w2,(int)y+h1);
buffGraphics.drawRect((int)Xold+w2-1,
(int)Yold+h1-1, 3, 3);
T1x = T2x; T1y = T2y;
}
buffGraphics.setColor(Color.black);
buffGraphics.drawString("NURBS curve", w2/2-30, h1);
buffGraphics.drawString("Polygonal decomposition of
NURBS (Segments: "+size+")", w2/3-20, h1+h1);
buffGraphics.drawString("Biarc approximation of

53

54

## NURBS (Arcs: "+(size+size)+")", w2/3+10, h1+h1+h1);

buffGraphics.drawString("Difference between the
polygon and NURBS", w2+w2/3, h1+h1);
buffGraphics.drawString("Difference between the PCC
and NURBS", w2+w2/3+10, h1+h1+h1);
}
public void subdivide()
{
DPoint dp;
double x0,y0,x1,y1;
double vx,vy;
double t,c;
int idx0, idx1;
double x,y;
list.clear();
stack.clear();
while(!stack.isEmpty())
{
idx1 = ((Integer)stack.removeLast()).intValue();
dp = (DPoint)points.get(idx1);
x1 = dp.x; y1 = dp.y;
idx0 = ((Integer)stack.removeLast()).intValue();
dp = (DPoint)points.get(idx0);
x0 = dp.x; y0 = dp.y;
vx = x1-x0;
vy = y0-y1;
t = Math.sqrt(vx*vx+vy*vy);
c = x0*y1 - x1*y0;

54

55

## boolean isLine = true;

for(int i=idx0+1;i<idx1;i++)
{
dp = (DPoint)points.get(i);
x = dp.x;
y = dp.y;
if(Math.abs((vy*x + vx*y + c)/t) > tolerance)
{
int k = (idx0+idx1)/2;
isLine = false;
break;
}
}
if(isLine)
{
}
}
int old = -10, idx;
Collections.sort(list);
int size = list.size();
for(int i=0;i<size;i++)
{
idx = ((Integer)list.get(i)).intValue();
if(idx != old)
{
old = idx;
}
}
}
}

55

REFERENCES

56

References
[1] Bolton K.M. "Biarc curves".Computer-Aided Design 1975;7(2):89-92.
[2] Carlson W. E. "An Algorithm and Data Structure for 3D Object Synthesis Using Surface Patch Intersection," Proceedings of ACM SigGraph 82, Boston, July 26-30, 1982, pp. 255-263.
[3] Fuhs W. and Stachel H., "Circular Pipe-Connections". Institute fur
Geometrie,Technische Universitat Wien, Wiedner Hauptstr. 8-10/113,
A-1040 Wien, Austria.
[4] Hoschechek J.,
1992;11:611-8.

"Circular

splines".

Computer-Aided

Design

## [5] Meek, D.S. and Walton, D.J., "Approximation of discrete data by G1

arc splines," Computer Aided Design, Volume 24, Number 6, 1992,
pp. 301-306.
[6] Odehnal B., "Ortho-circles". Wiedner Hauptstrae 8-10, A-1040
Wien, Austria.
[7] Piegl L. , Tiller W., "Biarc approximation of NURBS curves". Computer Aided Geometric Design 34 (2002), 807-814.
[8] Piegl L. , Tiller W., "The NURBS book". 2nd ed. New York: SpingerVerlag, 1997.
[9] Potman H., Peternell M., "Applications of Laguerre geometry in
CAGD". Computer Aided Geometric Design 15 (1998), 168-186.
[10] Rossignac J. R. and Requicha A. G., "Piecewise Constant Curvature Approximations for Geometric Modelling," Research Report RC12171, IBM Thomas J. Watson Research Center, Yorktown Heights,
NY, October 1986.
56

REFERENCES

57

[11] Rossignac J.R., Requicha A.G., "Piecewise circular curves for geometric modelling". IBM J. Res. Develop. Vol. 31. No. 3 (1987)
[12] Sabin M., "Contouring-A Review of Methods for Scattered Data,"
Mathematical Methods in ComputeGr raphics and Design, K. W.
Brodlie, Ed., Academic Press, Inc.N, ew York, 1980.
[13] Sabin M., "The Use of Piecewise Forms for the Numerical Representation of Shape". Report No. 60, Computer and Automation Institute,
Hungarian Academy of Science, Budapest, 1977.
Z., Feichtinger R. and J
[14] Sr
uttler B., "Approximating Curves and
Their Offsets using Biarcs and Pythagorean Hodograph Quintics". Altenberger Str. 69, 4040 Linz, Austria.
[15] Schonherr, J., "Smooth biarc curves". Computer-Aided Design, Vol.
25, 1993, pp. 365-370.
[16] Timmer H. G., "A Solution to the Surface Intersection".

57