Top Banner
UNIVERSITY OF WEST BOHEMIA Faculty of Applied Science DIPLOMA THESIS The use of Piecewise Circular Curves in Geometric Modeling Ulugbek Khudayarov Pilsen 2007
57
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • UNIVERSITYOF WEST BOHEMIA

    Faculty of Applied Science

    DIPLOMA THESIS

    The use of Piecewise Circular Curves in GeometricModeling

    Ulugbek Khudayarov

    Pilsen 2007

  • ZPADOCESKUNIVERZITA

    Fakulta aplikovanch ved

    DIPLOMOV PRCE

    Pouzit po cstech kruhovch krivek v geometrickmmodelovn

    Ulugbek KhudayarovObor: Matematika

    Plzen 2007

  • ProhlsenProhlasuji, ze jsem diplomovou prci vypracoval samostatne s pouzitm odborn literaturya pramenu uvedench v seznamu, kter je soucst tto prce.

    V Plzni dne . . . . . . . . . . . . . . . . .

    Podpis

  • PodekovnTmto bych chtel podekovat vedoucmu diplomov prce RNDr. M. Lvickovi, Ph.D. zaodborn veden, cetn rady a korektury tto prce.Dekuji tak sv rodine a prtelm za trpelivost a podporu, kterou mi dvali behem mhostudia.

  • CONTENTS 5

    Contents

    1 Introduction 6

    2 Fundamentals of Piecewise Circular Curves 82.1 Biarc formulation . . . . . . . . . . . . . . . . . . . . . . . . 82.2 Construction and representation of Piecewise Circular Curves 172.3 Tangent vectors of the polygon . . . . . . . . . . . . . . . . . 212.4 Approximation of curves by smooth PCCs. . . . . . . . . . . 22

    3 NURBS approximation 243.1 B-spline curve . . . . . . . . . . . . . . . . . . . . . . . . . . 243.2 NURBS curve . . . . . . . . . . . . . . . . . . . . . . . . . . 263.3 PCC approximation of NURBS curve . . . . . . . . . . . . . 293.4 The implementation of the algorithm . . . . . . . . . . . . . 33

    4 Applications of PCCs in geometric modeling 354.1 Circular pipe connections . . . . . . . . . . . . . . . . . . . . 354.2 Blending of canal surfaces . . . . . . . . . . . . . . . . . . . . 394.3 Approximation of surface/surface intersections . . . . . . . . 41

    5 Conclusion 47

    5

  • 6

    1 Introduction

    PCC (Piecewise Circular curve) is a kind of geometric curve made of circulararcs and line segments. It is easy to use, computationally efficient in shapemodeling, and well used as the description of tool path of CNC machines.In CNC tool path programming, fewer arc segments can help to improve theproduction efficiency by reducing the number of instructions and tool motions.Therefore, approximating points, polylines, or arbitrary curves with PCCs isof particular importance. Approximations to point data by G1 arc splineshave been investigated in the past [1, 2, 4 and 5]. Approximations to givencurves 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 speciallybounded shapes such as spiral, convex, or monotone curvature segments.This work presents a method of approximating a NURBS curve by PCCs towithin a user specified tolerance. The ideas of this method are summarizedas follows:

    approximate the NURBS curve by a polygon to within a certain toler-ance;

    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 endpoints of the biarc; and

    hook up the biarcs into a G1 curve that lies from the given curve withintolerance.

    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 whichmatches the points and tangents but an additional constraint is required to

    6

  • 7

    make the biarc unique. The conventional approach to this biarc constructionwhich has been widely adopted in arc spline approximation, introduces variousconstraints to uniquely determine the biarc [7]. The difference of the radii ofthe two circular arcs can be minimized, with the result that the angles of thetwo arcs are equal [15]. The difference of the curvatures of the two arcs canbe minimized, with the result that the joining point is on the bisector of theline segment joining the two end points [11]. Also, the ratio of the two radiican be made as close to one as possible, with the result that the tangent atthe joining point is parallel to the line joining the two end points.Instead of imposing such constraints to make the biarc unique, the approachproposed herein exploits the inherent freedom in the choice of the biarc toachieve a better fit minimizing the distance between the polygon and the biarc.This is called optimal single biarc fitting. A similar approach exploiting thefreedom was proposed for arc spline fitting of a B-spline curve, but it requiresmuch computation since it has to solve a non-linear optimization problem ofminimizing 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 funda-mentals of Piecewise Circular Curves, biarc formulation. Section 3 describesthe details on the biarc approximation method. In Section 4, applications ofPCCs in geometric modeling: Circular pipe connections, Blending of canalsurfaces and approximation of intersection edges of surfaces.

    7

  • 8

    2 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 biarcinterpolating given oriented G1 data, represented by end points P1, P2 andunit tangent vectors T1, T2 if the two circular arcs share one common endpoint 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 withorientation 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 withorientation corresponding to a parametrization of c2 from J to P1.

    3. The two arcs have a common unit tangent vector at J , with orientationcorresponding to a parametrization of c1 from P1 to J and of c2 from Jto P2.

    y

    x

    C1C2T1

    T2

    1

    2

    12

    T1 T2C1

    C2

    y

    x

    (a) (b)

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

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

    8

  • 2.1 Biarc formulation 9

    tangent vectors Ti. For instance, 1 is positive angle while 2 is negative inFigure 1(a). If both angles 1 and 2 are zero, the associated solution is astraight line segment. If the angles 1 and 2 have different signs, the biarccurve 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) (T1 = T2 = 1) pairs of datacan be connected by biarc.

    Proof. Let (P1,T1) and (P2,T2) (T1 = T2 = 1) be given data. The linepasses through P1 and parallel to T1 we will denote 1 and the line passesthrough P2 and parallel to T2 we will denote 2.Let P 1 1 and P 1 = P1+T1, where is constant. Then we can find pointP 2 on the line 2, which satisfy these conditions:

    P 2 = P2 T2, P 2 P 1 = |+ |

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

    (P 2 P 1) (P 2 P 1) = (+ )2

    Substituting P 1 and P 2 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, aftersimplification 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 12V V

    (T2 T1 1) +V T2(2.2)

    9

  • 2.1 Biarc formulation 10

    For any exists and thus we can always obtain the point P2 satisfyingconditions P 2 = P2 T2, P 2 P 1 = |+ |.

    P1

    P2

    J

    T2

    T1

    c1

    c2

    P'1

    P'2

    V

    Figure 2: Biarc for given data (P1,T1), (P2,T2).

    Then we can find a point

    J =

    + P 1 +

    + P 2 =

    P1 + P2 + (T1 T2)+

    (2.3)

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

    P1 P 1 = P 1 J = ||, P2 P 2 = P 2 J = ||

    There are one arc c1 (The arc c1 has the end points P1 and J , and T1 is tangentto 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 theend points J and P2 and T2 is tangent to c2 with orientation correspondingto a parametrization of c2 from J to P1.) satisfying second property. Thesetwo arcs have a common tangent at J with orientation corresponding to aparametrization 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 onebiarc. 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 polygonof biarc. Excellent results are obtained by choosing = which producesregular curves and leads to an efficient evaluation of . Because biarc with = is very close to Bezier cubic curve that interpolates the same boundaryconditions as the biarc and passes through the junction of the two arcs [11].with = equation (2.1) can be written as:

    2(T1 T2 1) V (T1 +T2) +1

    2V V = 0 (2.4)

    Equation (2.4) is equivalent to the equation:

    2(T2 4) 2(V T) + V2 = 0 (2.5)

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

    D = (V T)2 + V2(4 T2) (2.6)

    Because T 2, D is the sum of two nonnegative terms and therefore mustbe positive or null. If T 6= 4, we have two real solutions. Of the two rootswe chose

    =

    D V T4 T2

    (2.7)

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

    =V2

    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.

    T2

    T1

    P1

    P2

    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 +(T1 T2) +V

    2= P2

    (T2 T1) +V2

    , (2.9)

    TJ =V (T1 +T2)

    2(2.10)

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

    1. Compute V = P2P1 and check if the vectors V,T1,T2 are collinear. Ifthey are collinear then biarc is a line segment P1P2 and STOP, otherwiseGO TO N 2.

    2. Check if vector sum T1+T2=2, if equal then GO TO N 3, otherwise GOTO N 4.

    3. Check V T = 0 if true J = P1+ 12V and GO TO N 6 otherwise computeD 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 unittangent vectors T1 = (0, 1),T2 = (0,1) at this points. Construct the biarcfor these given data.a) To be constructed biarc for the given data first we will generate the vectorV = (P2 P1) = (4, 0). The vectors T1,T2,V are noncolinear. We choose

    P1 P2

    J

    T2

    T1

    TJ

    c1

    c2

    y

    x

    P'1

    P'2

    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 12V V

    (T2 T1 1) +V T2=

    (0, 1) (4, 0) 12 16(0, 1) (0,1) 1 + (4, 0) (0,1)

    = 4

    Then we will find points P 1 and P 2 as:

    P 1 = P1 + T1 = [0, 1], P2 = P2 T2 = [4, 4]

    13

  • 2.1 Biarc formulation 14

    The joint point J lie on the line P 1, P 2

    J =

    + P 1 +

    + P 2 =

    4

    5[0, 1] +

    1

    5[4, 4] =

    [4

    5,8

    5

    ]and the vector TJ = P 2 P 1 = (4, 3) we can use as tangent vector at J .Then we will construct two arcs c1, c2 which are satisfying first and secondconditions of biarc definition, respectively (see Figure 4).b) If = 4 then = 1 and points P 1 = [0, 4], P 2 = [4, 1]. The joint pointJ = [165 ,

    85 ] and tangent vector TJ = (4,3) at J (see Figure 5.).

    P1 P2

    J

    T2

    T1

    TJc1

    c2

    y

    x

    P'1

    P'2

    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 followingequation

    2 4 = 0

    and we chose = 2.

    14

  • 2.1 Biarc formulation 15

    Then we find joint point

    J = P1 +(T1 T2) +V

    2= [0, 0] +

    2(0, 2) + (4, 0)

    2= [2, 2]

    and unit tangent vector at this point

    TJ =V (T1 +T2)

    2= (1, 0)

    P1 P2

    J

    T2

    T1

    TJ

    c1 c2

    y

    x

    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 thesecond conditions of biarc definition, respectively (see Figure 6.).

    Theorem 2.2. The two data (P1,T1), (P2,T2) can be connected by one arcwhich passes through end points P1, P2 and tangent to T1,T2 at the end pointsrespectively, if the data (P1,T1), (P2,T2) lie in the same plane and they areline symmetric.

    Proof. Let be given two line symmetric data (P1,T1), (P2,T2) lying in thesame plane. If we choose = and we get P 1 = P 2. Then can be constructisosceles triangle P1P 1P2 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 (seeFigure7).

    P1 P2

    T1

    T2

    -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 theo-rem.

    Theorem 2.3. All joint points J of the family of biars are lies on the samecircle k, which is passing through P1,P2 and the having same oriented angleswith the vectors T1 and T2.

    Proof. For any data there is precisely one circle k passing through the pointsP1, P2 and having the same (oriented) angles with the vectors T1, T2. It isobtained as the trajectory of the point P1 under the unique rotation trans-forming the data P1, T1 into the data P2, T2. If the vectors are parallel, thenk 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 arcshave a common tangent at J if and only if J k. In fact, if J k, thenthe angle between the circle k and the arc c1 at the point J is the same asangle between the circle k and the vector T1. Similarly the angle between k

    16

  • 2.2 Construction and representation of Piecewise Circular Curves 17

    x

    y

    T1

    T2

    P1 P2

    k

    JiJi+1

    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 thevector T2. Since the circle k has the same angle with T1 and T2, the two arcsc1, c2 join with G1 continuity at J . The orientations coincide also, since oneof the arcs c1, c2 will be inside and one outside the circle k. Suppose, on theother hand, that a G1 interpolating biarc is constructed. The circle passingthough 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 thecircle k and J k. This proof produced by Zbynek Sr in [14].

    2.2 Construction and representation of Piecewise Circular Curves

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

    To construct a piecewise circular curve, recall that it is possible to construct

    17

  • 2.2 Construction and representation of Piecewise Circular Curves 18

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

    P2

    P1

    P3

    P4 P5

    P6P7

    Figure 9: Nonsmooth piecewise circular curve

    The advantage of piecewise circular curves is that one may with the appropri-ate choice of the points {Pi} obtain a smooth model. It is important that theappropriate 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 vectorsTi at the each of points Pi (i = 1, 2, ..., n).

    It is possible to construct a piecewise circular curve consisting of twocircular arcs (biarc) by giving the two points P1, P2 and the tangent

    18

  • 2.2 Construction and representation of Piecewise Circular Curves 19

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

    Generalizing the observation, one can construct a smooth circular arcconsisting of n 1 arcs by giving n points P1, P2, ..., Pn and a tangentvector T1 at P1. First construct the circular arc starting at P1 and endingat P2 using the tangent vector T1. Compute the tangent vector at P2from this first arc, and use that tangent vector to construct the circulararc from P2 to P3.

    Theorem 2.4. All given data (P1,T1), (P2,T2), ..., (Pn,Tn) can be connectedby smooth PCC.

    Proof. For all pair (Pi,Ti), (Pi+1,Ti+1) we will construct biarcs bi,i+1, withthe 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.

    P1

    Pn

    P2

    PiT1 T2 Ti

    Tn

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

    Algorithm 2. Procedure PCC1 ((Pi,Ti), i = 1, ..., n, n 2)

    19

  • 2.2 Construction and representation of Piecewise Circular Curves 20

    Input: data (Pi,Ti), i = 1, ..., n, n 2Output: 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)) for 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 = (35 ,

    45),T3 =

    (1, 0),T4 = (1, 0),T5 = (1, 0) at these points. Using the Algorithm 2 we

    P1 P2 T2T1

    J1

    y

    x

    P3

    P4

    P5

    T3

    T4

    T5

    J4

    J3J2

    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) whichis composed by four biarcs given by:

    1 =21 4, 2 =

    46 6, 3 = 1, 4 =

    1

    2

    20

  • 2.3 Tangent vectors of the polygon 21

    and

    J1 =

    [21 95

    ,221 85

    ], J2 =

    [11

    46

    5,7 2

    46

    5

    ],

    J3 = [3,1], J4 =[9

    2,1

    2

    ]In Figure 12 shown PCC, where i 6= .i, i = 1, ..., 4

    P1P2

    T2T1

    J1

    y

    x

    P3

    P4

    P5

    T3

    T4

    T5

    J4

    J3

    J2

    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 obtaintangent vectors at these points. In this subsection we will introduce how tocompute tangent vectors for the given set vertices of polygon.In [5], a technique was discussed to interpolate the tangent vectors to ensurethat the circular are passing through the adjacent points. In this work, we usedan interpolation method discussed in [5] to find the corresponding tangentvectors. 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)Pi+1 PiPi Pi1

    + (Pi+1 Pi)Pi Pi1Pi+1 Pi

    (2.11)

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

    y

    x

    C1C2

    O1

    O2

    T1

    T2

    1

    2

    12

    T1 T2C1

    C2O1

    O2

    y

    x

    (a) (b)

    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 befound between the tangent vectors Ti at the knot points and the chord line(see Figure 13).

    2.4 Approximation of curves by smooth PCCs.

    Given a user defined tolerance , a piecewise circular curve is sought so thatthe PCC does not deviate from the given curve more than . That is, for anygiven point P lying on the piecewise circular curve,

    c (tp) P < , (c (tp) P ) c (tp) = 0

    where tp is the parameter corresponding to the projection of P onto the givencurve. To obtain such an approximation, the following two conceptual proce-dures are applied.

    22

  • 2.4 Approximation of curves by smooth PCCs. 23

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

    data are taken from a C1 continuous curve c(t).

    P1 = c(t1),T1 =c(t1)

    c(t1)P2 = c(t2),T2 =

    c(t2)

    c(t2)(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 C1 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 ofarbitrary (piecewise) G1 continuous curves into arc splines. In the sequel wepresent a simple non-adaptive algorithm for the conversion of C1 continuouscurves.Algorithm 4. Procedure PCC2 (c(t), t [0, 1])Input: A C1 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:

    bni = Biarc(c(t),

    [i 1n

    ,i

    n

    ])for i = 1, ..., 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. Ifthe distance is greater than then set n = 2n and GOTO (2). OtherwiseSTOP.

    23

  • 24

    3 NURBS approximation

    3.1 B-spline curve

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

    c(u) =ni=1

    Ni,k(u)Vi 3.1

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

    for k = 1

    Ni,1 =

    {1, if ui u < ui+10, otherwise.

    for k > 1

    Ni,k =u ui

    ui+k1 uiNi,k1(u) +

    ui+k uui+k ui+1

    Ni+1,k1(u) 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 thenumber of control points n is given by m = n + p + 1. The sequence ofknots 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 parametervalues to calculate a segment of a shape.Since the knot spacing could be nonuniform, the B-splines are no longer thesame for each interval [ui, ui+1) and the degree of the B-Spline can vary. Con-sidering the whole range of parameter values represented by the knot vector,the different B-splines build up continuous (overlapping) blending functionsNi, p(u), as defined in (3.2), over this range. These blending functions havethe 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 knotspans, 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

    j=ikNj,k(u) =

    ni=0

    Ni,k(u) = 1, (partition of unity)

    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 ofdegree k.

    2. Equality m = n+ k + 1 must be satisfied.

    3. Clamped B-spline curve c(u) passes through the two end control pointsV1 and Vn.

    4. Strong Convex Hull Property: A B-spline curve is contained in the convexhull 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 Vionly affects the curve c(u) on interval [ui, ui+k+1).

    6. c(u) is continuous curve of order Ck at knots of multiplicity on curvesof degree k

    25

  • 3.2 NURBS curve 26

    3.2 NURBS curve

    NURBS (Non Uniform Rational B-spline [8]) are industry standard tools forthe representation and design of geometric objects . Some reasons for the useof 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 al-gorithms;

    are invariant under affine as well as perspective transformations;

    are generalizations of non-rational B-splines and non-rational and ratio-nal Bezier curves and surfaces.

    Let us consider the way of introducing homogeneous coordinates to a B-splinecurve and derive the NURBS definition.Given n control points V1, ..., Vn, n k and knot vector U = (u1, ..., um) ofm knots, the B-spline curve of degree k defined by these parameters is thefollowing:

    c(u) =ni=1

    Ni,k(u)Vi

    Let control point Vi be rewritten as a column vector with four componentswith the fourth one being 1:

    Vi = [xi, yi, zi, 1]T .

    We can treat this Vi as a homogeneous coordinate. Since multiplying thecoordinates 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 wito obtain a new form in homogeneous coordinates:

    V wi = [wixi, wiyi, wizi, wi]T .

    Note that V wi and Vi represent the same point in homogeneous coordinate.Plugging this new homogeneous form into the equation of the above B-splinecurve, we obtain the following:

    cw(u) =ni=1

    Ni,k(u)Vwi =

    ni=1

    Ni,k(u)

    wixi

    wiyi

    wizi

    wi

    =

    ni=1

    Ni,k(u)(wixi)

    ni=1

    Ni,k(u)(wiyi)

    ni=1

    (u)(wizi)

    ni=1

    Ni,k(u)wi

    .

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

    cw(u) =

    ni=1

    Ni,k(u)(wixi)

    ni=1

    Ni,k(u)win

    i=1

    Ni,k(u)(wiyi)

    ni=1

    Ni,k(u)win

    i=1

    Ni,k(u)(wizi)

    ni=1

    Ni,k(u)wi

    1

    =

    ni=1

    Ni,k(u)wi

    ni=1

    Ni,k(u)wi

    xi

    yi

    zi

    1

    .

    Finally, we have a clean form as follows:

    27

  • 3.2 NURBS curve 28

    c(u) =

    ni=1

    Ni,k(u)wiVi

    ni=1

    Ni,k(u)wi

    Definition 3.2. A NURBS curve c(u), which is a vector-valued piecewiserational polynomial function, is defined as:

    c(u) =

    ni=1

    Ni,k(u)wiVi

    ni=1

    Ni,k(u)wi

    3.3

    where wi are weights, Vi are control points (vector) and Ni,k are normalizedB-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 segmentOpen line segment can be described as NURBS with order k = 2, weightswi = 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 ellipseCircle 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), V3 = (a, 0, 0, 1), V4 = (0,b, 0, 0)

    28

  • 3.3 PCC approximation of NURBS curve 29

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

    3. BiarcFor a biarc curve let u be a parameter value computed as

    u =P1J

    P1J+ JP2

    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 secondarc, respectively.

    3.3 PCC approximation of NURBS curve

    Given a user defined tolerance , a piecewise circular curve is sought so thatthe PCC does not deviate from the NURBS curve more than . That is, forany given point P lying on the piecewise circular curve,

    c (up) P < , (c (up) P ) c (up) = 0 (3.4)

    29

  • 3.3 PCC approximation of NURBS curve 30

    where up is the parameter corresponding to the projection of P onto theNURBS curve. To obtain such an approximation, the following two concep-tual 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. IfM < output P1, Pk, otherwise subdivide B at one-half the parameterrange.

    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 linesegments using (2.11), and get boundary data.

    30

  • 3.3 PCC approximation of NURBS curve 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 whichapproximate the given NURBS curve with gien tolerance.

    Figure 14: The given NURBS curve from example 3.

    This NURBS curve is drawn in Figure 14.Applying the polygonal decomposition Algorithm 5 we approximate the givenNURBS curve with the polygon with given tolerance, which is shown in Fig-ure 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 thesedata which represent PCC. (see Figure 16). In the Figure 17 shown diffe-nence between NURBS curve and biarc.

    31

  • 3.3 PCC approximation of NURBS curve 32

    Figure 15: Polygonal decomposition of NURBS curve.

    Figure 16: Biarc approximation of NURBS curve.

    Figure 17: Difference between NURBS curve and PCC.

    32

  • 3.4 The implementation of the algorithm 33

    3.4 The implementation of the algorithm

    Algorithm 6 was implemented in Java programming language. This programcompute (and draw) approximation of NURBS curve by PCC with the giventolerance. 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 seg-ments with the tolerance. This tolerance is possible to change in runtime byslider-control which is located in the left of the screen. After constructingof the polygon the Java program are computed corresponding unit tangentvectors at every vertex of the polygon. Using Algorithm 2 we construct PCCwhich passes through vertices of the polygon and tangent to correspondingunit 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 changedin runtime by mouse. Similarly, in the second graph the weights of the controlpoints can be also changed.

    33

  • 3.4 The implementation of the algorithm 34

    0.1

    10

    NURBS curve

    Polygonal decomposition of NURBS (segments: 14) Difference between the poygon and NURBS

    Biarc approximation of NURBS (arcs: 28) Difference between the PCC and NURBS

    Tolerance

    Figure 18: Biarc approximation of NURBS curve.

    34

  • 35

    4 Applications of PCCs in geometric modeling

    PCCs have many potential applications in geometric modeling. Some of theseapplications are described in this section.

    4.1 Circular pipe connections

    Definition 4.1. Let be a developable ruled surface and let be a curve inone of s tangent planes, say T . The surface traced out by while T rollson (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 pipesurface [6].Technical designers need connections of central curves of pipes. These con-nections have better aerodynamical properties when connecting central curvehas a constant curvature. PCC has piecewise constant curvature, thereforewe can use PCC in these connections for getting better results. And furtherpipe elements with a circular central curve are much easer produced than pipeconnections based on arbitrary spatial curves. They are clearly representedin Figures 19, 20Application of PCC in pipe connections can be seen in the following example:Example 4. Let be given two cylinders 1 and 2.

    1 : x2 + z2 = 0.3, y [2, 0]

    2 : y2 + z2 = 0.3, x [2, 4]

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

    35

  • 4.1 Circular pipe connections 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 centralcurves respectively and which must be connected. then we will choose twounit tangent T1 = (0, 1, 0),T2 = (1, 0, 0) vectors at P1, P2 which have thesame direction with the central curves. Then we will compute the vectorV = (P2P1) = (2, 0, 0). Using Algorithm 1 we can construct biarc with thejoint point

    J =

    (33

    2,

    3 12

    )and with the tangent vector

    TJ =

    (33

    23 2

    ,13

    23 2

    )

    at J (see Figure 21). Then we can construct pipe around biarc with radiusr = 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 per-spective.

    38

  • 4.2 Blending of canal surfaces 39

    4.2 Blending of canal surfaces

    The envelope of a one-parameter family t of spheres with variable radiusis called canal surface [6]. The curve s of the spheres centers is called spinecurve. Any sphere of the family t touches along a circle c which is calledcharacteristic. The class of canal surfaces contains the class of pipe surfacesas well. The radius function of the spheres t is constant for a pipe surface.Let be given two canal surfaces S and S , we want to find a surface Sb thatcan smoothly join the given surfaces together. This process is called blendingand the third surface is a blending surface of the given surfaces. Of course, theblending surface is not uniquely defined. It is shown in following Figure 24(in yellow) that blends the green and the blue surfaces. The blending surfaceprovides 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, S 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 aminimum distance from edge and point P 1 on edge which has a minimumdistance from point P1. We generate n 1 points Pi, i = 2, ..., n on , andn 1 points P i , where i = 2, ..., n on as:

    P1P2 = P2P3 = ... = Pn1Pn = PnP1 = = const

    P 1P 2 = P 2P 3 = ... = P n1P n = P nP 1 = = const

    We generate unit vectors Ti, Ti on surfaces S, S at points Pi, P i withthe same basic direction with minimum curvature of surfaces at points Pi,P i respectively. Then biarcs bn can be constructed for all pairs of data(Pi,T), (P i ,T

    ). Then we generate points on this biarcs as:

    P1P11 = P11P12 = ... = P1nP 1 = 1 = const, P11, P12, ..., P1n b1,

    P2P21 = P21P22 = ... = P2nP 2 = 2 = const, P21, P22, ..., P2n b2,

    ...

    PnPn1 = Pn1Pn2 = ... = PnnP n = n = const, Pn1, Pn2, ..., Pnn bn,

    then for all sets of points {Pj1}, {Pj2}, ..., {Pjn}, where j = 1, ..., n we willconstruct smooth PCCs denoted by pn. All constructed biarcs bn, Piecewisecircular curves pn and two circles , 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 .

    S : y2 + z2 = 1, x [5,1]

    S :y2

    9+z2

    9=x2

    16, x [1, 4]

    Using biarcs we will find their blending surface. First of all we will chooseone point P1 on surface S and find a point P 1 on surface S which has the

    40

  • 4.3 Approximation of surface/surface intersections 41

    minimum distance from P1.Let be P1 = [1, 1, 0] then we obtain P 1 = [1, 34 , 0]. To construct the biarc weneed unit tangent vectors T1,T1 at points P1, P 1 respectively. We will choosethe unit tangent vectors on the same basic direction of surfaces S, S whichhas the minimum curvature at points P1, P 1 respectively. Then we will get

    T1 = (1, 0, 0), T1 =(4

    5,3

    5, 0

    )Using Algorithm 1 we will construct biarc for data (P1,T1) and (P 1,T

    1)

    (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 correspond-ing 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. Approx-imation intersection edges have been investigated in the past by JaroslawRossignac 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 per-spective.

    42

  • 4.3 Approximation of surface/surface intersections 43

    This section discusses the computation of PCC approximations for intersectionedges between any two natural faces (i.e., faces of natural primitives: blocks,spheres, cylinders, cones, and tori, shown in Figure 29). Their method is avariation 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 byrecursively refining the approximation in selected intervals.We describe the steps in more detail, let us summarize their effect and indicatehow they differ from techniques reported elsewhere.The first step requires the computation of curve/surface intersections. For thefaces of natural primitives, such computations are reduced to the intersectionof lines or circles with natural surfaces. An efficient implementation of suchcomputations 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 bothsurfaces 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 two-dimensional parameter space of one primitive face. (Hereafter, for brevity werefer to primitive faces as patches.) This method locates consecutive pointspractically without searching. Because heuristic methods are inadequate, rarematching ambiguities are addressed by recursively subdividing certain cellsinto four subcells.In the last step, they interpolate pairs of consecutive intersection points andtangents with twisted biarcs, thus generating a PCC that interpolates theactual edge at all intersection points. Computation of twisted biarcs andrepresentation of the PCC were discussed earlier.To obtain a continuous parametrization of the whole curve, they must main-tain consistency between the orientation of two consecutive biarcs. A con-sistent orientation of the biarcs may be propagated along the PCC curve by

    44

  • 4.3 Approximation of surface/surface intersections 45

    P1 P2 P3 P4 P5 P6 P7

    F1

    F2

    Figure 30: Intersection point lying in one face only: The point P2 is out of F2, but isneeded 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 theintersection edge.

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

    45

  • 4.3 Approximation of surface/surface intersections 46

    P1

    P4

    P2

    P3

    P1

    P2

    P4

    P3

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

    matching the ending point of one biarc with the starting point of the nextbiarc along the curve. Self-intersecting edges are approximated by PCCs thatdo 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

    5 Conclusion

    As mentioned in the introduction, the basis of this thesis consists in studyingand applications the piecewise circular curves (PCC) in geometric modeling.It has five sections. The first section is introduction. In the second sectionwe introduce fundamentals of PCCs, their construction and representation.The third section contains definitions of B-spline and NURBS curves and thealgorithm of NURBS approximation by PCCs. In the next section we intro-duce three applications of PCCs in geometric modeling. The first applicationsolves problem of pipe connections by using PCCs. The second applicationpresents the PCC blending operation of canal surfaces. And the last describesapproximation of surfaces intersections by PCCs.The tasks that were determined before the author are mentioned in the begin-ning of the thesis. These tasks have solved mainly. The self theoretic resultscontained 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 bysmooth PCCs. The algorithms to construct biarc, PCC and to approximateNURBS curves with PCC are presented in the Algorithms 1, 2, 5, 6, respec-tively. In the appendix we have introduced a program which implements theAlgorithm 6. This program has been written in JAVA language as JAVAapplet (see www-page http://home.zcu.cz/ ulugbek). The first and the sec-ond applications which are presented in the fourth section of the thesis haveproposed 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 exampleapplication of PCCs in sphere geometries (Laguerre, Mobius, Lie geometry).

    47

  • 48

    Appendixpublic 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

  • 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

  • 50

    sW += wi[j]*N[j][k];

    }

    x = (sX/sW); y = h1-(sY/sW);

    points.add(new DPoint(x,y));

    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

  • 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);

    path.quadTo((float)Ctrl1.x,(float)

    52

  • 53

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

    path.quadTo((float)Ctrl2.x, (float)Ctrl2.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);

    path.quadTo((float)Ctrl1.x+w2, (float)Ctrl1.y+h1+h1,

    (float)P2.x+w2, (float)P2.y+h1+h1);

    path.quadTo((float)Ctrl2.x+w2, (float)Ctrl2.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();

    stack.add(new Integer(0));

    stack.add(new Integer(points.size()-1));

    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 tolerance)

    {

    int k = (idx0+idx1)/2;

    stack.add(new Integer(idx0));

    stack.add(new Integer(k));

    stack.add(new Integer(k));

    stack.add(new Integer(idx1));

    isLine = false;

    break;

    }

    }

    if(isLine)

    {

    list.add(new Integer(idx0));

    list.add(new Integer(idx1));

    }

    }

    int old = -10, idx;

    Collections.sort(list);

    int size = list.size();

    for(int i=0;i

  • 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 Syn-thesis Using Surface Patch Intersection," Proceedings of ACM Sig-Graph 82, Boston, July 26-30, 1982, pp. 255-263.

    [3] Fuhs W. and Stachel H., "Circular Pipe-Connections". Institute furGeometrie,Technische Universitat Wien, Wiedner Hauptstr. 8-10/113,A-1040 Wien, Austria.

    [4] Hoschechek J., "Circular splines". Computer-Aided Design1992;11:611-8.

    [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-1040Wien, Austria.

    [7] Piegl L. , Tiller W., "Biarc approximation of NURBS curves". Com-puter Aided Geometric Design 34 (2002), 807-814.

    [8] Piegl L. , Tiller W., "The NURBS book". 2nd ed. New York: Spinger-Verlag, 1997.

    [9] Potman H., Peternell M., "Applications of Laguerre geometry inCAGD". Computer Aided Geometric Design 15 (1998), 168-186.

    [10] Rossignac J. R. and Requicha A. G., "Piecewise Constant Curva-ture Approximations for Geometric Modelling," Research Report RC-12171, 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 geomet-ric 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 Representa-tion of Shape". Report No. 60, Computer and Automation Institute,Hungarian Academy of Science, Budapest, 1977.

    [14] Sr Z., Feichtinger R. and Juttler B., "Approximating Curves andTheir Offsets using Biarcs and Pythagorean Hodograph Quintics". Al-tenberger 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

    IntroductionFundamentals of Piecewise Circular CurvesBiarc formulationConstruction and representation of Piecewise Circular CurvesTangent vectors of the polygonApproximation of curves by smooth PCCs.

    NURBS approximationB-spline curveNURBS curvePCC approximation of NURBS curveThe implementation of the algorithm

    Applications of PCCs in geometric modelingCircular pipe connectionsBlending of canal surfacesApproximation of surface/surface intersections

    Conclusion