CONSTRAINT SOLVING FOR COMPUTER AIDED ... - CS @ Purdue

15 downloads 0 Views 559KB Size Report
expressing incidence, 2 explicit point-line distances, 3 angles and 4 point-point dis- tances. ..... the quadrilateral has a well-defined position when + 6= 90 . .... Two geometric configurations are congruent if one can be transformed into the.
CONSTRAINT SOLVING FOR COMPUTER AIDED DESIGN A Thesis Submitted to the Faculty of Purdue University by Ioannis Fudos In Partial Ful llment of the Requirements for the Degree of Doctor of Philosophy August 1995

ii

ACKNOWLEDGMENTS I gratefully thank my advisor Prof. Christoph M. Homann for the invaluable help, support and advice, Prof. Jorg Peters for helpful discussions and the other members of my committee Prof. David C. Anderson and Prof. Elias N. Houstis for insightful comments and suggestions. I thank B. Bouma and X. Chen of the Erep group for a fruitful collaboration. The discussions with J. Cai, R. Page, P. Vermeer, V. Capoyleas, B. Bruderlin, R. JuanArinyo, M. Sitharam and C. Durand are gratefully acknowledged. The nal version of this thesis was improved by comments and suggestions from Dr. W. Gorman.

DISCARD THIS PAGE

iii

TABLE OF CONTENTS Page LIST OF FIGURES : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

vi

ABSTRACT : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

ix

1. INTRODUCTION : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

1

: : : : : :

3 3 4 6 8 8

2. OVERVIEW : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

9

2.1 A Graph-constructive Method for Geometric Constraint Solving : : 2.2 Algebraic Equations for Distances and Angles : : : : : : : : : : : : 2.3 Construction Steps : : : : : : : : : : : : : : : : : : : : : : : : : : : 2.3.1 Three points : : : : : : : : : : : : : : : : : : : : : : : : : : : 2.3.2 Two Lines and One Point : : : : : : : : : : : : : : : : : : : 2.3.3 Two Points and One Line : : : : : : : : : : : : : : : : : : : 2.3.4 Three Lines : : : : : : : : : : : : : : : : : : : : : : : : : : : 2.4 Multiple Solutions and Root Identi cation : : : : : : : : : : : : : : 2.5 Well-constrained, Overconstrained and Underconstrained Problems 2.6 Fixed Geometry : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

: : : : : : : : : :

11 13 13 14 15 16 17 18 19 21

3. CORRECTNESS AND ALGORITHMICS : : : : : : : : : : : : : : : : : :

22

1.1 A Taxonomy of Geometric Constraint Solvers 1.1.1 Numerical Constraint Solvers : : : : : 1.1.2 Constructive Constraint Solvers : : : : 1.1.3 Propagation Methods : : : : : : : : : : 1.1.4 Symbolic Constraint Solvers : : : : : : 1.1.5 Hybrid Solvers : : : : : : : : : : : : :

3.1 Termination and Unique Normal Forms : 3.2 Geometric Uniqueness : : : : : : : : : : 3.3 A Quadratic Algorithm : : : : : : : : : : 3.3.1 Overview : : : : : : : : : : : : : 3.3.2 Details : : : : : : : : : : : : : : :

: : : : :

: : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : : :

: : : : :

: : : : :

23 27 30 31 32

iv Page 3.3.3 Time Analysis : : : : : : : : : : : : : : : : : : : : : : : : : : :

33

4. OVERCONSTRAINED AND UNDERCONSTRAINED PROBLEMS : :

35

4.1 Structurally Overconstrained Problems : : : : : : : : : : : : : : : : : 4.2 Structurally Underconstrained Problems: The Decomposition Analysis 4.2.1 Decomposition Analysis : : : : : : : : : : : : : : : : : : : : : 4.2.2 Correctness of the Decomposition Analysis : : : : : : : : : : : 4.2.3 An Ecient Algorithm for Decomposition : : : : : : : : : : :

35 36 38 40 40

5. EXTENSIONS : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

47

5.1 Extending the Repertoire of Reductions : : : : : : : : : : : : : : : : : 5.2 Incorporating Angle Derivations : : : : : : : : : : : : : : : : : : : : :

47 49

6. CONIC ARCS : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

52

6.1 A Uniform Representation for Conics : : : : : : : : : 6.1.1 Nonparallel Tangents : : : : : : : : : : : : : : 6.1.2 Parallel Tangents : : : : : : : : : : : : : : : : 6.1.3 A Uni ed Representation : : : : : : : : : : : : 6.1.4 Converting to a Rational B-spline : : : : : : : 6.2 Constructions : : : : : : : : : : : : : : : : : : : : : : 6.2.1 Tangency to or Distance from a Line : : : : : 6.2.2 Tangency to a Circle or Distance from a Point 6.2.3 Angle with a Line : : : : : : : : : : : : : : : : 6.2.4 Angle with a Circle : : : : : : : : : : : : : : : 6.2.5 Fairness Constraints : : : : : : : : : : : : : : 6.3 Handling Conic Arcs in the Analysis Phase : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

54 54 56 57 59 61 61 63 66 67 69 69

7. MULTIPLE SOLUTIONS AND ROOT SELECTION : : : : : : : : : : :

72

7.1 The Root Identi cation Problem : : : : : : : : : : : : : : : : : : : 7.1.1 Specifying the Correct Solution by Imposing Global Rules 7.1.2 Adding More Constraints : : : : : : : : : : : : : : : : : : 7.1.3 Dialogue with the Solver : : : : : : : : : : : : : : : : : : : 7.2 Finding a Real Solution : : : : : : : : : : : : : : : : : : : : : : : 7.2.1 NP{hardness : : : : : : : : : : : : : : : : : : : : : : : : : 7.2.2 Discussion : : : : : : : : : : : : : : : : : : : : : : : : : : :

: : : : : : :

72 75 76 78 88 90 95

8. CONCLUSIONS AND FUTURE WORK : : : : : : : : : : : : : : : : : :

97

: : : : : : :

v Page BIBLIOGRAPHY : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

99

APPENDIX : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 106 VITA : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 108

vi

LIST OF FIGURES Figure

Page

2.1 A dimensioned sketch de ning a constraint problem with 10 geometric elements constrained by 17 constraints. : : : : : : : : : : : : : : : : : : :

10

2.2 The constraint graph of the previous sketch. : : : : : : : : : : : : : : : :

10

2.3 (left) Constraint problem. (right) Associated constraint graph. : : : : :

11

2.4 Finding the clusters of the graph. : : : : : : : : : : : : : : : : : : : : : :

12

2.5 Cluster merge. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

14

2.6 Placing three points. : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

14

2.7 Placing two lines and one point. : : : : : : : : : : : : : : : : : : : : : :

16

2.8 Placing two points and one line. : : : : : : : : : : : : : : : : : : : : : :

17

2.9 A degenerated con guration is derived for  +  = 90 . : : : : : : : : : :

20

3.1 Only one reduction can be applied to C. : : : : : : : : : : : : : : : : : :

28

3.2 Two or more reductions applied to C. : : : : : : : : : : : : : : : : : : :

29

3.3 Rewriting a 6-Cycle in the cluster graph. : : : : : : : : : : : : : : : : : :

32

3.4 Three cases for a triangle in a depth rst search. : : : : : : : : : : : : :

32

3.5 Finding a 6-cycle by doing a breadth rst search. : : : : : : : : : : : : :

33

4.1 A cluster con guration derived from a structurally overconstrained problem. 36 4.2 A structurally underconstrained graph where adding edges (clusters) to trigger local cluster merging does not always work. : : : : : : : : : : : :

37

4.3 The two basic cases for decomposing the clusters into sets. : : : : : : : :

38

vii Figure

Page

4.4 An underconstrained cluster con guration containing only lines. We add a virtual point p and three constraints in the form of the clusters C3, C4 and C5. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

39

4.5 Getting two geometrically incongruent solutions, (b) and (c), from the same underconstrained draft (a). : : : : : : : : : : : : : : : : : : : : : :

41

4.6 (left) A cluster con guration that is derived from an underconstrained system of geometric constraints. (right) The graphs representing a cluster with two and a cluster with three geometric elements. : : : : : : : : : :

44

4.7 A decomposition in split components of the graph that corresponds to the cluster con guration of the previous gure. : : : : : : : : : : : : : : : :

45

5.1 A well-constrained cluster con guration that cannot be solved by the basic method. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

48

5.2 Detecting the cluster con guration of the previous gure during the reduction analysis, by a BFS rooted at C1. : : : : : : : : : : : : : : : : : :

48

5.3 Two constraint con gurations that can be solved only if we utilize angle derivations. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

49

5.4 Cluster con gurations for the geometric constraint problems of the previous gures after some initial cluster merging has occurred. The information maintained for the angle classes is also shown. : : : : : : : : : : : :

50

6.1 (left) The signs of the barycentric coordinates. (right) A conic arc blending two segments and interpolating the origin. : : : : : : : : : : : : : : :

55

6.2 (left) The sign of the coecients for the case of parallel tangents. (right) A conic arc blending two parallel segments and passing through (1 1). :

55

6.3 Subdividing a conic arc at t = 1=2. : : : : : : : : : : : : : : : : : : : : :

60

6.4 (left) Finding the point of tangency in the case of nonparallel tangents. (right) Finding the point of tangency in the case of parallel tangents. : :

62

6.5 Blending two segments by a conic arc that is tangent to a given line. : :

62

6.6 Four solutions for a conic arc that blends two segments and is tangent to a circle. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

65

viii Figure

Page

6.7 Four solutions for a conic arc that blends two parallel segments and is tangent to a circle. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

65

6.8 (a),(b): Two solutions for a conic arc that blends two segments and forms a 45 angle with a line. (c),(d): Two solutions for a conic arc that blends two parallel segments and forms a 45 angle with a line. : : : : : : : : :

68

6.9 Four solutions for a conic arc that blends two segments and forms a =7 angle with a circle. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

68

6.10 Arc extension implied. : : : : : : : : : : : : : : : : : : : : : : : : : : : :

71

7.1 A well-constrained problem with three lines, three points and nine pairwise constraints. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

73

7.2 A solution that is consistent but not intuitive. : : : : : : : : : : : : : : :

73

7.3 A well-constrained problem with distinct 2n;2 solutions. : : : : : : : : :

74

7.4 Constraining three parallel lines with distances. : : : : : : : : : : : : : :

76

7.5 An instance of the n parallel lines problem. : : : : : : : : : : : : : : : :

77

7.6 Root identi cation in placing three points. : : : : : : : : : : : : : : : : :

79

7.7 The two types of tangency between an arc and a segment. : : : : : : : :

80

7.8 The initial sketch with two 70 angles. : : : : : : : : : : : : : : : : : : :

81

7.9 After making the two angles 30 . : : : : : : : : : : : : : : : : : : : : : :

82

7.10 Selecting solution 4 (instead of 2) from level 7. : : : : : : : : : : : : : :

85

7.11 Selecting solution 1 (instead of 3) from level 4. : : : : : : : : : : : : : :

86

7.12 Complementing the arc Ar10. : : : : : : : : : : : : : : : : : : : : : : : :

87

7.13 Four distinct solutions for placing the four points A, B , C and D with respect to each other. : : : : : : : : : : : : : : : : : : : : : : : : : : : :

89

7.14 Constructing an instance of the real solution problem. : : : : : : : : : :

91

ix

ABSTRACT Fudos, Ioannis. Ph.D., Purdue University, August 1995. Constraint Solving for Computer Aided Design. Major Professor: Christoph M. Homann. An approach to solving systems of geometric constraints appropriate for computer aided design is described, its scope is characterized and its correctness is proved. Various ways to extend the scope of the method are investigated and ecient algorithms are presented. Special consideration is given to the problem of navigating the geometric constraint solver to a real solution that is appropriate to the application and is intuitive to the user.

1

1. INTRODUCTION In the past few years, there has been a strong trend towards developing a Computer Aided Design (CAD) system that has the following properties: 1. The design process is intuitive to the user even if the user is not aware of the underlying representation and technical aspects of the system. 2. The designed object can be modi ed and interrogated. 3. The designed object may be used as a functional part of a larger design. 4. The designed object may be used in subsequent phases of the application (analysis, robot motion planning, assembly), which implies that information related to the user's intentions must be preserved (see SKW90]). The traditional Boundary representation (Brep) and Constructive Solid Geometry (CSG) representation impose major limitations and exhibit unacceptable performance when used as primary representations in systems designed to accomplish the above goals Woo90, Rol89, HJ93, Hof93, Woo88]. In response to these problems, the concept of design by features has emerged. Design by features is a notion rather than a formally de ned process. It means that certain areas have a speci c semantic description that makes them capable of being modi ed or of functioning in a predetermined (but not xed) way when linked in a certain environment Woo90, Rol89, AC90]. This work presents the development of a geometric constraint solver which serves as a building block for a larger project of developing a new generation of feature-based CAD systems based on a neutral, high-level geometry representation that expresses

2 design intent and preserves the ability to redesign BFH+95, HJ93]. More specifically our constraint solving method has the following characteristics that make it appropriate for geometric constraint solving in CAD: It is variational, i.e. the user does not have to specify the order in which the geometric constraints are satis ed. The order in which the constraints are satis ed and the geometric objects are placed is derived automatically. Because it is based on an analysis of the structure of the constraint graph, the properties of our method can be formally studied. For instance, its correctness is proved and its scope is characterized. The method can be realized by an ecient algorithm having quadratic worst case time complexity. It is capable of handling eciently over- and underdetermined systems of geometric constraints. It can solve a large subset of the ruler and compass constructible problems and it can be easily extended to handle constraint problems that are not ruler and compass constructible. Since it is based on merging rigid bodies, the repertoire of geometric objects can be easily extended to include higher degree objects such as conic arcs. For the same reason, the results of this work can be extended to constraint solving in the three dimensional space. The solver can be navigated eciently to a new solution as appropriate for the application. Although there is an exponentially large search space of solutions that satisfy the given system of geometric constraints, a new solution can always be found in linear time. To put our work into perspective, the rest of this chapter presents a taxonomy of approaches to geometric constraint solving. Chapter 2 provides an overview of our

3 approach, and Chapter 3 presents the core method. How to handle overconstrained and underconstrained systems of geometric constraints is discussed in Chapter 4. Chapter 5 presents extensions to the scope of the core method and Chapter 6 describes how to incorporate conic arcs. Chapter 7 discusses the problem of navigating the solver to solutions that have speci c properties. Finally, Chapter 8 oers conclusions and future research directions. 1.1 A Taxonomy of Geometric Constraint Solvers The following is a taxonomy of approaches to geometric constraint solving. 1.1.1 Numerical Constraint Solvers In numerical constraint solvers the constraints are translated into a system of algebraic equations and are solved using iterative methods. To handle the exponential number of solutions and the large number of parameters iterative methods require sharp initial guesses. Also, most iterative methods have diculties handling overconstrained or underconstrained instances. The advantage of these methods is that they have the potential to solve large nonlinear system that may not be solvable using any of the other methods. All existing solvers more or less switch to iterative methods when the given con guration is not solvable by the native method. This fact emphasizes the need for further research in the area of numerical constraint solving. Sketchpad Sut63a], was the rst system to use the method of relaxation as an alternative to propagation. Relaxation is a slow but quite general method. Many systems like ThingLab Bor81] and Magritte Gos83] kept the relaxation as an alternative to other methods. In Bar87] a method called projection method is presented for nding a new solution that minimizes the Euclidean distance between the old and the new solution. The Newton-Raphson method has been used in various systems Nel85, SG86], and it proved to be faster that relaxation but it has the problem that it may not converge

4 or it may converge to an unwanted solution after a chaotic behavior. For that reason Juno Nel85] uses as initial state the sketch interactively drafted by the user. However, Newton-Raphson is so sensitive to the initial guess BFH94], that the sketch drafted must almost satisfy all constraints prior to constraint solving. A sophisticated use of the Newton-Raphson method was developed in LG82], where an improved way for nding the inverse Jacobian matrix is presented. Furthermore, the idea of dividing the matrix of constraints into submatrices as presented in the same work, has the potential of providing the user with useful information regarding the constraint structure of the sketch. Though this information is usually quantitative and nonspeci c, it may help the user in basic modi cations. Finally, when the Jacobian matrix is singular Light and Gossard use a modi ed version of Doolittle's method. To check whether a constraint problem is well-constrained, Chyz Chy85] proposes a preprocessing phase where the graph of constraints is analyzed to check whether a necessary condition is satis ed. The method is however quite expensive in time and it cannot detect all the cases of singularity. An alternative method to Newton-Raphson for geometric constraint solving is homotopy or continuation AG93], that is argued in LM95] to be more satisfactory in typical situations where Newton-Raphson fails. Homotopy, is global, exhaustive and thus slow when compared to the local and fast Newton's method Mor87]. 1.1.2 Constructive Constraint Solvers This class of constraint solvers is based on the fact that most con gurations in an engineering drawing are solvable by ruler, compass and protractor or using other less classical repertoires of construction steps. In this methods the constraints are satis ed in a constructive fashion, which makes the constraint solving process natural for the user and suitable for interactive debugging. There are two main approaches in this direction.

5 Rule-Constructive Solvers Rule-constructive solvers use rewrite rules for the discovery and execution of the construction steps. In this approach, complex constraints can be easily handled, and extensions to the scope of the method are straightforward to incorporate. Although it is a good approach for prototyping and experimentation, the extensive computations involved in the exhaustive searching and matching make it inappropriate for real world applications. A method that guarantees termination, ruler and compass completeness and uniqueness using the Knuth-Bendix critical pair algorithm is presented in Bru86, Soh91]. This method can be proved to con rm theorems that are provable under a given system of axioms Bru93]. The rules for automatically determining the desired unique solution are not discussed in these papers. A system based on this method was implemented in Prolog. Aldefeld in Ald88] uses a forward chaining inference mechanism, where the notion of direction of lines is imposed by introducing additional rules, and thus restricting the solution space. A similar method is presented in SAK90], where handling of overconstrained and underconstrained problems is given special consideration. Sunde in Sun88] uses a rule-constructive method but adopts dierent rules for representing directed and nondirected distances, giving exibility for dealing with the root selection problem. In YK90] the problem of nonunique solutions is handled by imposing a topological order on three geometries. An elaborate description of a complete set of rules for 2D geometric constraint solving can be found in VSR92]. In their work, the scope of the particular set of rules is characterized. JAS95] presents an extension of the set of rules of VSR92], and provides a correctness proof based on the techniques of FH95].

Graph-constructive Solvers The graph-constructive approach has two phases. During the rst phase the graph of constraints is analyzed and a sequence of construction steps is derived. During the second phase these construction steps are followed to place the geometries. These

6 approaches are fast and more methodical. In addition, conclusions characterizing the scope can be easily derived for such methods. A major drawback is that as the repertoire of constraints increases the graph-analysis algorithm needs to be modi ed. Fitzgerald Fit81] follows the method of dimensioned trees introduced by Requicha Req77]. This method allows only horizontal and vertical distances and it is useful for simple engineering drawings. Todd in Tod89] rst generalized the dimension trees of Requicha. Owen in Owe91] presents an extension of this principle that includes circularly dimensioned sketches. DCM Ltd94] is a system that uses some extension of Owen's method. Kramer Kra92] describes a 3D constraint solver that deals with constraints from kinematics that are characterized by basic joint types. Complex geometric elements are placed implicitly by choosing a suitable number of local coordinate frames to be placed with respect to each other by rigid-body motions. HB94] presents a graphbased method to analyze the degrees of freedom of the geometric entities and to construct a dependency graph and an evaluation scheme for symbolic or numerical solutions to the constraint problem. Other approaches, such as CFV88, GZS88], use the constraint graph to record a speci c sequence of constructions as implied by the interaction with the user. Such approaches can be characterized as parametric CS90, RBN88, Ros86], i.e. one in which the user implicitly or explicitly speci es the order in which the geometric constraints will be satis ed. Finally, AAJM93] decomposes the system of geometric constraints in polynomial time in under-, over-, and well-constrained irreducible subsystems by an analysis of the bipartite graph of equations and variables. 1.1.3 Propagation Methods Propagation methods follow the approach met in traditional constraint solving systems. In this approach the constraints are rst translated into a system of equations

7 involving variables and constants. The equations are then represented by an undirected graph which has as nodes the equations, the variables and the constants, and whose edges represent whether a variable or a constant appears in an equation. Subsequently, we try to direct the graph so as to satisfy all the equations starting from the constants. To succeed this, various propagation techniques have been used, but none of them guarantees to derive a solution and at the same time have a reasonable worst case running time. For a review of these methods see Soh91]. Sketchpad Sut63a] uses propagation of degrees of freedom and propagation of known values. Pro/ENGINEER Bro91, Pro] uses propagation of known values. Propagation of known values is the inverse process of propagation of degrees of freedom. Both methods are global, unstable and do not work for cyclically dimensioned sketches. CONSTRAINTS SS80] uses retraction, which is a localized version of propagation of known values, that stores for each variable some information, about the variable's premises and dependents. A similar technique is used in Li88], where an algorithm for local propagation of known values is given, and for the remaining simultaneous constraint solving, a system of linear equations is attempted. In general, retraction is faster but less powerful than propagation of known values. ThingLab uses the Blue and Delta Blue algorithms FBMB90, Bor81], the Delta Blue algorithm being just an incremental version of the Blue algorithm where the constraint graph need not be recomputed from scratch with each removal or addition of a constraint. These algorithms are faster than other algorithms because they are based on a local propagation of degrees of freedom within the constraint graph. The algorithm presented in Wil91] has a better conict detection which is based on information, provided explicitly by the user. Magritte Gos83] employs a propagation method to transform the undirected constraint graph and then a breadth rst search to derive all solutions. Constraint Kernels, a system described in Fuq87] uses a somewhat dierent approach. It transforms the original undirected graph to a directed acyclic dependency graph.

8 As a matter of fact, the constructive constraint solvers can be thought of as a subcase of the propagation method ( xed geometries for constants and variable geometries for variables). However, constructive constraint solvers utilize domain speci c information to derive more powerful and ecient algorithms. 1.1.4 Symbolic Constraint Solvers In symbolic solvers the constraints are transformed to a system of algebraic equations which is solved using methods from algebraic manipulation, such as Grobner basis calculation Buc85] or Wu's method Wu86]. Kondo in Kon92] handles the addition and deletion of constraints by using the Buchberger's Algorithm Buc85] to derive a polynomial that shows the relationship between the deleted/added and the pre-existing constraints. 1.1.5 Hybrid Solvers Many existing systems use a combination of the above methods. As already mentioned many systems use a numerical approach as an alternative to some other method, such systems include DCM Ltd94], Sketchpad Sut63a, Sut63b], ThingLab FBMB90, Bor81], and Magritte Gos83]. On the other hand, some solvers, like the one used in Pro/ENGINEERBro91, Pro], try to isolate a number of reduced sets of core equations that must be solved simultaneously. Then, an iterative method is used for solving each subsystem of simultaneous equations.

9

2. OVERVIEW In CAD systems the user speci es a rough sketch and adds to it geometric and dimensional constraints that are normally not yet satis ed by the sketch. The constraint solver determines from the dimensioned draft the geometric elements that are to be found, and processes the constraints to determine each geometric element such that the constraints are satis ed. A geometric constraint problem is given by a set of points, lines, rays, circles with xed radii, line segments and circular arcs, called the geometric elements, along with required relationships of incidence, distance, angle, parallelism, concentricity, tangency, and perpendicularity between any two geometric elements, called the constraints. As it is explained in Fud93] with an appropriate representation and some preprocessing we may restrict ourselves to points, lines, with pairwise distance and angle constraints. The geometric constraint problem is then formulated as follows: Given a set V of n points and lines and a set E of pairwise constraints among them, nd a solution that satises the given constraints. A pairwise constraint may be : point-point distance, point-line distance and line-line angle. More formally E is a partial mapping E : V  V ! 0 (see Figure 2.6). We place B at the origin and C at (a 0). x

A b

c

y a

B(0, 0) c

C(a, 0) b

A

Figure 2.6 Placing three points.

15 For nding the third point A we intersect two circles as illustrated in Figure 2.6, one circle centered at B with radius c, the other centered at C with radius b. The two circles can be disjoint (no solution), tangent (one solution) or intersecting in two points (two distinct solutions). Algebraically, to nd the point A(x y) we solve the system

x2 + y2 = c2 (x ; a)2 + y2 = b2 or, equivalently,

2 2 2 x = c + 2aa ; b

y2 = c2 ; x2 With a b c nonnegative, we distinguish three cases:

(i) a + b < c or b + c < a or a + c < b. The circles are disjoint there are no real solutions. (ii) a + b = c or b + c = a or a + c = b. The circles are tangent there is one solution, x = c y = 0 (iii) jc ; aj < b < c + a. The circles intersect in two distinct points the two solutions are 2 2 2 p x = c + 2aa ; b  y = c2 ; x2 2 2 2 p x = c + 2aa ; b  y = ; c2 ; x2 where the rst solution corresponds to a counterclockwise arrangement of the three points (A B C ) and the second solution corresponds to a clockwise arrangement of the three points (A B C ). 2.3.2 Two Lines and One Point Let l1 = (n~1 r1) and l2 = (n~2 r2) be two lines that intersect in the prescribed angle . Also let p = (x y) be a point with prescribed signed distances d1 and d2

16 from lines l1 and l2 respectively. We place l1 on the x-axis i.e., l1 = ((0 1) 0) and the point p at (0 d1) as shown in Figure 2.7. Then we have for l2

x

l2

p(0, d1) α

l1

y

Figure 2.7 Placing two lines and one point.

n~2 = (; sin  cos ) r2 = d1 cos  ; d2 This gives a unique solution for l2. 2.3.3 Two Points and One Line Let p1 and p2 be two points, and let l be a line. The distance between p1 and p2 be d > 0, and the distance between l and the points p1, p2 be d1 and d2, respectively. We place l on the x-axis i.e., l = ((0 1) 0), and we place the point p1 on (0 d1), as illustrated in Figure 2.8. To nd p2 = (x y) we must intersect the line " : y = d2 with a circle with center p1 and radius d. Algebraically, we have

x2 + (y ; d1)2 = d2 y = d2

17 x

d p1(0, d1) p2

ε

p2 l

y

Figure 2.8 Placing two points and one line. We distinguish three cases: (i) d < jd2 ; d1j. The line and the circle are disjoint there are no real solutions. (ii) d = jd2 ; d1j. The line and the circle are tangent there is one solution, p2 = (0 d2 ). (iii) d > jd2 ; d1j. The line and the circle intersect there are two distinct solutions

p2 =

q q

( d2 ; (d2 ; d1)2 d2)

p2 = (; d2 ; (d2 ; d1)2 d2) 2.3.4 Three Lines If there are three lines with angle constraints between each pair then one of the constraints must be redundant or contradictory. Technically, we consider this case overconstrained because then the constraint values cannot be independently changed. Note that cluster merging cannot be done when the shared geometric elements are three lines.

18 2.4 Multiple Solutions and Root Identi cation It is well known that a well-constrained geometric problem can have many incongruent solutions. Recall that at each construction step we may have to choose one of several solutions. Dierent choices may lead to incongruent solutions, each mathematically satisfying the given constraints. In order to select a solution at each step, a number of heuristics are applied that make sense if the sketch with which the geometric problem has been speci ed is more or less like the intended solution. This is an application-speci c issue that is further discussed in Section 7.1. We assume that the geometric problem has been speci ed by a user-prepared sketch. The point-line distances, and the angles between oriented lines are assumed to be signed quantities. The correct sign is determined from the original input sketch. As explained before, all placements have a unique solution except in two cases, which are solved as follows: (i) The relative placement of three points in a construction step has the same cyclic ordering in the plane as the ordering of the points in the original drawing. (ii) The relative placement of two points and an oriented line is such that the inner product of the direction vector of the points and the line is sign invariant between the original sketch and in the chosen solution. The geometric construction rst places three geometric elements in this manner, and then applies a rigid-body transformation to align the three clusters accordingly. In particular, placing clusters by the shared geometric elements does not involve a reection. We will prove later that no matter in which order the clusters are combined, the same set of triples of geometric elements is used to select the geometric solution, and that this implies congruence. Note that the heuristics only imply the existence of a solution in a generic sense. Speci c dimensions of distance and angle could be such that the solution selected by

19 the heuristics would require complex coordinates. If this possibility is to be systematically excluded, some strategy would be required that searches the solution space in a canonical order. As the space of possible solutions may be exponential in the number of geometric elements, this is not an attractive prospect. In the case of rulerconstructible con gurations, there is a theorem by Hilbert stating that if one solution has only real coordinates, then all of them must have real coordinates Hil56]. This means that for such con gurations the heuristics will never fail to deliver a solution if one exists. The theorem does not generalize to ruler-and-compass constructible problems, and we know of no results that make progress beyond Hilbert's theorem. The problem of nding a real solution of a system of geometric constraints is further discussed in Section 7.2. 2.5 Well-constrained, Overconstrained and Underconstrained Problems Each line or point on the Euclidean plane has two degrees of freedom. Each distance or angle corresponds to one equation. If we have no xed geometric elements (geometric elements whose absolute coordinates have been speci ed explicitly by the user) then we expect that jE j = 2jV j ; 3

where jV j = n

Recall that jV j is the number of geometric elements and that jE j is the number of constraints. Note that the solution will be a rigid body with three remaining degrees of freedom, because the constraints determine only the relative position of the geometric elements. We use this argument to de ne a technical notion of wellconstrained sketches in which no attempt is made to account for the possibility that for special dimension values an otherwise well-constrained problem may happen to be underconstrained. An example is shown in Figure 2.9. In the gure, the vertex P of the quadrilateral has a well-de ned position when + 6= 90 . But for + = 90 the position of P is not determined. This \semantic" notion of well-constrained problems

20 d1

d1 β

β

d2

d2

α

α

P

P

Figure 2.9 A degenerated con guration is derived for  +  = 90 . is too speci c for the constraint graph analysis because there the generic problem of constructing a solution is considered independent of dimension values. Intuitively a dimensioned sketch is considered to be well constrained if it has a nite number of solutions for nondegenerate con gurations. Similarly a dimensioned sketch is considered to be underconstrained if it has an in nite number of solutions for nondegenerate con gurations. Finally a dimensioned sketch is considered to be overconstrained if it has no solutions for nondegenerate con gurations. The intuitive notions above can be made technically precise as follows: Denition 2.1 A graph with n nodes is structurally overconstrained if there is an induced subgraph with m n nodes and more than 2m ; 3 edges. Denition 2.2 A graph is structurally underconstrained if it is not overconstrained, and the number of edges is less than 2n ; 3. Denition 2.3 A graph is structurally well-constrained if it is not overconstrained, and the number of edges is equal to 2n ; 3. Denition 2.4 A geometric constraint problem with a structurally over-, underor well-constrained constraint graph is characterized as structurally over-, under- or well-constrained problem respectively.

For an algorithm to test whether a graph is structurally well-constrained see, e.g. Ima85, Sug85]. Note also that a structurally well-constrained graph can be

21 overconstrained in a geometric sense, for example if there are three lines with pairwise angle constraints. The core reduction analysis handles structurally well-constrained problems. Chapter 3 presents this method in detail, together with a correctness proof and an ecient algorithm to realize it. Chapter 4 discusses how our constraint solving method handles structurally overconstrained and underconstrained problems. 2.6 Fixed Geometry In addition to the constraints decribed before the constraint solver provides for xed constraints, i.e. the user may prescribe the coordinates of geometric elements explicitly. All such xed geometric elements are treated in the analysis phase as one cluster (rigid body), except of the case that there is only one xed geometric element, where no special provision needs to be made in the analysis phase. At the end of the construction phase a rotation and translation of all the relatively placed geometric elements will move the xed cluster (or single geometric element) to its prescribed coordinates.

22

3. CORRECTNESS AND ALGORITHMICS We are given a constraint graph G = (V E ) whose nodes V are geometric elements, and whose edges E are the geometric constraints. As mentioned before, without loss of generality, the geometric elements are reduced to points and lines, and the constraints to those of distance and angle. We consider sets C whose elements are sets S that in turn have as elements nodes of G. Each set S represents a cluster. Intuitively, a cluster S consists of geometric elements whose position relative to each other has already been determined. A cluster thus can be considered a rigid geometric structure that has three degrees of freedom, two translational and one rotational. Initially, we form a set CG from G. For each edge e = (u v) in G, there is a cluster Se = fu vg. The construction steps that solve the constraint problem amount to one reduction step that merges three clusters whose pairwise intersection is a singleton set. The reduction is denoted by !, where we sometimes indicate with subscripts which clusters are to be merged. The process of nding a sequence of reductions that derives a single set of clusters, and thus determines, a sequence of construction steps that positions the geometric elements to satisfy the initial set of constraints, is called reduction analysis. In Sections 3.1 and 3.2, we consider clusters as sets and study their structure under reduction. In Section 3.1 we prove rst a weak notion of correctness: If the constraint graph is not structurally overconstrained, then our algorithm reduces the initial set CG to a singleton, no matter in which order the reduction steps are applied. That is, the set CG and the reduction ! are a terminating, conuent rewriting system.

23 Here, conuent means that if a set A can be reduced to two dierent sets B1 and B2, then there are two reduction sequences, one reducing B1, the other B2 to the same set C . Notice, however, that a well-constrained geometric problem has in general several incongruent solutions (see Chapter 7). We prove therefore a stronger uniqueness theorem in Section 3.2: If the constraint graph is well-constrained and our algorithm reduces the initial set CG to a single cluster using, in the construction phase, the placement rules given in Section 2.4, then the solutions derived by dierent reduction sequences place a xed set of triples of geometric elements in the same relative position. This result implies that dierent reduction sequences must produce geometric solutions that are congruent. Finally, in Section 3.3 we provide an algorithm that runs in time quadratic to the number of geometric elements and realizes correctly the reduction analysis, presented in this chapter.

3.1 Termination and Unique Normal Forms Given the constraint graph G = (V E ), we consider the set of clusters

CG = ffu vg : (u v) 2 E g Cluster sets are rewritten using a reduction !. The reduction ! is formally de ned as follows:

24 Denition 3.1 Let C be a set of clusters C in which there are three clusters S1, S2 , S3 such that S1 \ S2 = fg1g

S2 \ S3 = fg2g S3 \ S1 = fg3g where g1, g2, g3 are distinct, then where

C ! C0

C0 = (C fS1 S2 S3g) ; fS1 S2 S3g

We will show that the reduction system (CG  !) has a unique normal form that is obtained after nitely many reductions. When all g1, g2, g3 are lines then we have an overconstrained con guration, since each of the pairwise angles that have been determined independently in each cluster can be expressed as a combination of the other two. The results of this and the next section hold even if we assume that a reduction is applicable when not all three geometric elements are lines. However, if we choose to handle consistently overconstrained cases (see also Section 4.1) we should not exclude such reductions. Denition 3.2 The set C0 of clusters is derived from C, if C0 can be obtained by applying a sequence of reductions to C. We denote this by

C! C0 Denition 3.3 A set of clusters C to which ! is not applicable is called irreducible. If C can be derived from C0 and is irreducible, then C is called a normal form of C0.

25 We will show that the initial cluster set CG obtained from a constraint graph that is not structurally overconstrained has a unique normal form, and that this normal form is derived by a nite sequence of reduction steps. Lemma 3.1 If CG is obtained from a constraint graph with n nodes and e edges, then every reduction sequence has length less than (e + 1)=2. Proof CG has initially e clusters. Each reduction step reduces the number of clusters by 2. 2 Lemma 3.2 Let G be a constraint graph. If CG ! C, then the subgraph that corresponds to a cluster in C is structurally well-constrained. Proof The proof is by induction on the length of the reduction sequence deriving C. The induction basis is C = CG and is trivial. For the induction step, consider the last reduction step which merges three clusters S1, S2 and S3 into a new cluster S . Let GS be the subgraph of G corresponding to S , Gk the subgraph of G corresponding to Sk , k = 1 2 3. Note that these graphs are not necessarily induced subgraphs of G, and that the edge sets of the Gk are disjoint. Let ni be the number of nodes, ei the number of edges in the subgraph of G induced by Si. From the induction hypothesis, ei = 2ni ; 3. Since jS1 \ S2j = jS2 \ S3j = jS3 \ S1 j = 1, S has n = n1 + n2 + n3 ; 3 vertices. Then e1 + e2 + e3 = 2n ; 3. 2 Lemma 3.3 Let CG ! C. If the clusters S1 S2 2 C intersect in more than one node then G is structurally overconstrained. Proof Assume jS1 \ S2j = m > 1 and that G1 and G2 are the corresponding subgraphs. By Lemma 3.2, e1 = 2n1 ; 3 and e2 = 2n2 ; 3. Consider the subgraph G0 induced by S1 S2. Then G0 has n0 = n1 + n2 ; m vertices and e0  e1 + e2 edges. But e0  e1 + e2 = 2(n1 + n2) ; 6 > 2n0 ; 3. Therefore, G is structurally overconstrained. 2

26 Theorem 3.1 If the original constraint graph is not structurally overconstrained, then the reduction system (C !) is conuent, where CG ! C. Proof Let C be a set of clusters, CG ! C. Assume there are two dierent reductions possible, C !1 C1 and C !2 C2. It suces to show that then C1 !2 C3 and C2 !1 C3. The reduction !1 involves the clusters S11, S12, S13, and the reduction !2 involves the clusters S21, S22, S23. Several cases must be distinguished based on how many distinct clusters there are among the clusters Sik . Case { 3 clusters: Since there are only three distinct clusters, and since the reductions are dierent, there must be two clusters that have more than one element in common. Thus the constraint graph is overconstrained. Case { 4 clusters: Since each reduction requires three distinct clusters, the cluster not used in the reduction !1 must connect two of the clusters S11 S12 S13. But then C1 contains two distinct clusters whose intersection is larger than one element. Hence the original graph is overconstrained. By symmetry, using !2 similarly certi es an overconstrained. Case { 5 clusters: Let S11 = S21, and assume that S11 \ S12 = fg1g and S11 \ S13 = fg2 g. Clearly S22 and S23 intersect S11 in singletons. If S22 and S23 are both disjoint from S12 S13 ; fg1 g2g, then it is clear that C1 !2 C3 and C2 !1 C3. But if (S22 S23) \ (S12 S13 ; fg1 g2g) 6= , then C1 and C2 must contain two clusters that share more than one common element, contradicting that the original is not overconstrained. Case { 6 clusters: Since the clusters are all distinct, the reductions !1 and !2 commute. 2 Corollary 3.1 (Normal Form Theorem). If the constraint graph G is not overconstrained, then the reduction system CG has a unique normal form that is obtained by nitely many reduction steps. Proof Immediate from Lemma 3.1 and Theorem 3.1. 2

27 3.2 Geometric Uniqueness Two geometric con gurations are congruent if one can be transformed into the other by a translation and a rotation. We have shown that the reduction sequence, and hence the cluster formation, cannot interfere with termination or uniqueness of the normal form. But each reduction implies a geometric construction that places three clusters, by placing the three associated geometric con gurations with respect to each other. Since these constructions have more than one solution, it is not at all evident whether dierent reduction sequences will produce congruent solutions. However, we will show that this is the case for all graphs that are not structurally overconstrained. In Section 2.3 we explained that heuristic rules are used to select one among several possible solutions in each construction step. The three elements whose relative orientation is preserved correspond to the graph nodes that are the pairwise intersections of a triple of clusters merged in a reduction step. It turns out that two dierent reduction sequences make use of the same set of triples. By Lemma 3.3, it is clear that in a set of clusters C the same triple of nodes cannot be used for two dierent reductions. Denition 3.4 Let g1 , g2 , and g3 be the three geometric elements corresponding to the shared nodes when merging the clusters S1, S2, and S3. Denoting the reduction with , we call the triadic set

g( ) = fg1 g2 g3g the geometry triple of . Denition 3.5 Let C be a set of clusters and be a sequence of reductions applied to C. Then the set TC( ) = fg( ) : g

is the set of geometry triples, of C under .

28 Theorem 3.2 Let G be a constraint graph that is not structurally overconstrained, and assume that CG ! C. Let 1 and 2 be two reduction sequences that reduce C to normal form Cf . Then TC( 1) = TC( 2). Proof By Corollary 3.1, C has a unique normal form Cf . Moreover, it is clear from Theorem 3.1 that the reduction sequences 1 and 2 must have the same length. Consequently, the sets TC( 1) and TC( 2) have equal cardinality. We proceed by induction on the length of 1. Basis: 1 is a single reduction. By Theorem 3.1, 1 = 2 , so TC ( 1 ) = TC ( 2). Induction Step: Assume that the theorem is true for reduction sequences of length n, and let j 1j = j 2j = n + 1. Let CG ! C, C ! 1 Cf , and C ! 2 Cf . Case 1: If 1 = 1 and 2 = 2, where is a single reduction, then the theorem follows from the induction hypothesis applied to C0 where C ! C0 and the sequences 1 and 2. See also Figure 3.1.

C

G

*

C

σ

τ1

C

*

C

f

τ2

*

Figure 3.1 Only one reduction can be applied to C. Case 2: Let 1 = 1 and 2 = 2 , where and are single reductions. Let C ! C and C ! C. By Theorem 3.1, and commute, so there is a cluster set C0 such that

C ! C ! C0 C ! C ! C0 Let 3 be any sequence that reduces C0 to normal form. See also Figure 3.2. Applying the induction hypothesis to C and the sequences 1 and 3, we have TC ( 1) = TC ( 3) = TC ( 3) fg( )g 0

29 Cσ

σ C

*

τ1

*

ρ C

C

σ

ρ Cρ

τ3

Cf

τ2 *

Figure 3.2 Two or more reductions applied to C. And applying the induction hypothesis to C and the sequences 2 and 3, we have

TC ( 2) = TC ( 3) = TC ( 3) fg( )g 0

But then

TC( 1) = TC ( 1) fg( )g = TC ( 3) fg( )g fg( )g = TC ( 2) fg( )g = TC( 2) 0

2

Lemma 3.4 Let G be structurally well-constrained. Assume that there are two reduction sequences 1 2 and 1 2 of CG to normal form. Then the solutions constructed by the two sequences are congruent. Proof Assume that

CG ! C ! C1 CG ! C ! C2 1 1

We know that C1 and C2 are the same set of geometric elements. We prove that the corresponding geometric clusters in C1 and C2, constructed by and by , are congruent. From the proof of Theorem 3.1, we only consider the cases where and

involve ve or six clusters. It is clear that in the case of six clusters corresponding geometric clusters of C1 and C2 are congruent.

30 Assume, next, that merges S11, S12, and S13, and that merges S11, S22, and S23. We may consider S11 xed, so that and determine only the positions of g1 = S12 \ S13 and g2 = S22 \ S23, followed by translations and rotations of the geometric clusters of S12, S13, S22, and S23. Clearly, g1 and g2 are dierent and are therefore placed independently. By Theorem 3.2, the placement of gi is unique. Moreover, the placement of the geometric clusters of S12 and S13 is independent from the placement of the geometric clusters of S22 and S23, since S11 is xed and G is not structurally overconstrained. Hence the geometric clusters of C1 must be congruent to the corresponding geometric clusters of C2. 2 Theorem 3.3 Let G be well-constrained then the solutions constructed by two different reduction sequences leading to normal form are congruent. Proof Let the two sequences be 1 and 2 . By Theorem 3.1 we know that the two sequences are permutations of each other. The theorem now follows from Lemma 3.4 by an induction on the number of transpositions of commuting reductions needed to change 2 into 1. 2

3.3 A Quadratic Algorithm In this section we present an ecient algorithm that realizes the reduction analysis presented earlier in this chapter. Let G = (V E ) be the constraint graph. Let n = jV j and e = jE j. The algorithm has a O(n2) worst case time complexity for constraint graphs that are not structurally overconstrained. We can also show that we can test, in the same time bound, whether the graph is structurally overconstrained (see Section 4.1). For the purposes of the algorithm we will also consider an undirected cluster graph H whose vertices are the edges and vertices of G. H has an edge (e v) i there is an edge e 2 E and v is incident to e in G. Note that H is bipartite. The initial cluster graph H records of clusters of size 2 in G. H is bipartite, with one set of vertices corresponding to clusters, initially the edges of G, the other

31 corresponding to the geometric elements of the constraint problem, the vertices of G. There is an edge in H if a vertex of G belongs to a cluster. In this section we will assume that G is not structurally overconstrained thus every subgraph Gs = (Vs Es ) of G satis es jEsj 2jGs j ; 3. 3.3.1 Overview The algorithm for solving the constraint graph is as follows: 1. Construct initial clusters of size 2, each consisting of two adjacent vertices of G. 2. Construct the cluster graph H . 3. Find all triangles in G. 4. Successively rewrite H by replacing a 6-cycle in H by a four-node structure as explained below. Record a cluster merging operation for each such rewriting step. 5. If H can be rewritten into a nal graph that is a star with center a cluster and periphery the vertices of G, then G is solvable otherwise it is not solvable. A 6-cycle in H corresponds to three clusters that pairwise share an element (a vertex of G). The rewriting step corresponds to a cluster merge. Let (u U v V w W ) be such a 6-cycle, where u v w 2 G. We replace the three vertices U , V and W with a new vertex X . Then X will be incident to all vertices that U , V and W are adjacent to. That is, the nodes U V W are combined into a single node. See also Figure 3.3. A 4-cycle in H corresponds to two clusters that share two elements. If a 4-cycle exists, the graph G is structurally overconstrained (Lemma 3.3). Thus, the shortest possible cycle in H has length 6.

32 ...

U

u

...

...

...

V

v

...

...

...

W

w

...

...

X

u

...

v

...

w

...

Figure 3.3 Rewriting a 6-Cycle in the cluster graph. 3.3.2 Details The main work of the algorithm is to nd and reduce 6-cycles. Finding triangles in Step 3 identi es all 6-cycles in H , and the algorithm will nd other 6-cycles that are formed by rewriting in Step 4. Those two steps must be implemented carefully, and we explain how they are done. Step 3: We assume that G is represented both by adjacency lists and by the adjacency matrix. We nd all triangles in G as follows, using the method of IR78]. Build a depth- rst search tree. Three types of triangles are possible, involving two, one, or no tree edge (Figure 3.4). Triangles that involve one or two tree edges v

v

v

father(u)

father(u)

father(u)

u

u

u

a) A triangle containing two tree edges

b) A triangle containing one tree edge

c) A triangle without tree edges

Figure 3.4 Three cases for a triangle in a depth rst search. are found as follows: Let (u v) be a back edge. If (father(u) v) is an edge in G, we

33 X u

v

...

...

...

U ...

V w

Figure 3.5 Finding a 6-cycle by doing a breadth rst search. have a triangle with one or two tree edges, because in that case either (v father(u)) is a tree edge or (father(u) v) is a back edge. Next, we remove all tree edges, and repeat the above search for all connected components of the remaining graph. This is repeated until there are no more edges. Clearly, all triangles that do not have tree edges in the rst depth- rst search eventually become triangles involving tree edges in later depth- rst searches. Step 4: A triangle in the constraint graph G corresponds to a 6-cycle in the cluster graph H and vice versa. Having found all triangles in G, we now know all six cycles of H . When rewriting a 6-cycle, new 6-cycles could be created. They are found by a limited-depth breadth- rst search that originates at the new vertex X  see also Figure 3.5. In Mon83] limited depth- rst search has been used to nd cycles of minimum length. To nd all such 6-cycles, begin a breadth- rst search at X . Each vertex at level 3 that is reached twice in the breadth- rst search closes a 6-cycle. Note that the search is done only to level 3. 3.3.3 Time Analysis Steps 1 and 2 require O(e) steps. Since G is not structurally overconstrained, this is linear in the number of vertices n.

34 Step 3 repeatedly performs a depth- rst search. It requires the adjacency matrix of G which costs O(n2) if constructed with standard data structures. The rst depthrst search now requires O(e) steps, because the test whether (father(u) v) is a graph edge can be done in constant time using the adjacency matrix. Let G1 be a connected component of G with m vertices. After a depth- rst search of G1, m ; 1 edges are removed from the adjacency lists. This is more than half the edges in G1 because G is structurally not overconstrained. Consequently, the next depth- rst search examines less than half the number of edges. The total time for Step 3 is therefore O(e) which is O(n), excluding the time for the adjacency matrix construction. In Step 4, each reduction of a 6-cycle takes time O(e): We go through all the adjacency lists and replace each of the three vertices U , V and W with vertex X . Every new 6-cycle must involve the new node X . We do a breadth- rst search beginning at X to depth 3, looking for new 6-cycles. This again takes again time O(e). Initially, H contains at most 2n ; 3 vertices representing clusters. Each 6-cycle replacement reduces this number by 2, thus in Step 4 we may have at most n reductions. And since each breadth rst search corresponds to one reduction, Step 4 takes time O(ne) = O(n2 ).

35

4. OVERCONSTRAINED AND UNDERCONSTRAINED PROBLEMS Section 4.1 discusses how the reduction analysis can be extended to detect overconstrained systems of geometric constraints and handle eciently consistently overconstrained cases. Section 4.2 presents a decomposition analysis for underconstrained systems of geometric constraints and an ecient algorithm that realizes it. 4.1 Structurally Overconstrained Problems With some extra checking the algorithm of Section 3.3 can detect an overconstrained subgraph in the same time bound. For Step 1 before doing a depth rst search in a connected component graph G1 = (V1 E1) we check whether jE1j 2jV1j ; 3, if yes we go on, otherwise we terminate the algorithm and return the graph G1. Since this step is performed on the initial graph as well we have ensured that the original graph has less than 2n ; 3 edges. Step 2 takes again time O(n), and Step 3 takes time O(n2 ). For Step 4, we keep reducing until we meet a 4-cycle, then we terminate the algorithm and return the 4-cycle, the time complexity is again O(n2). The returned graph is used for interactive editing. To handle consistently overconstrained problems we introduce a new reduction operation that merges two clusters sharing two or more geometric elements (cf. Lemma 3.3). This corresponds to checking in the construction phase whether the relative positioning of the shared geometric elements in the two clusters is consistent. If it is consistent, then the two rigid bodies are merged into one. A cluster con guration derived from a structurally overconstrained problem is depicted in Figure 4.1. In this cluster con guration, C1, C2 and C3 are merged into a cluster C 0, and C4, C5 and C6 into a cluster C 00. C 0 and C 00 have two common elements: p4 and p2 . In the analysis phase we merge the two clusters and in the construction phase we rst check whether

36 the distance between p4 and p2 in C 0 matches the distance between p4 and p2 in C 00. If so, we rotate and translate, e.g. C 0 to match C 00. p1 C1

C3 p4 p3

l2

C4

l1

p5

C2 C6 p2

l3 C5

Figure 4.1 A cluster con guration derived from a structurally overconstrained problem. We modify the algorithm of Section 3.3 to solve consistently overconstrained graphs. The only modi cation that we need to do is to add to Step 4, that if we meet a 4-cycle in a breadth rst search we reduce it as if it was a 6-cycle and we go on. To derive the time bounds note that the number of reductions is always linear in the number of nodes in H . Also recall that each iteration of Step 4 takes only p O(e). Steps 1 and 2 take time O(e). Step 3 becomes O(e e) (see IR78]), and Step 4 becomes O(e2). This gives an overall O(e2) worst case time complexity for the general case. If the original graph has e = O(n) then Steps 1 and 2 take O(n) time, Step 3 p takes O(n n) and Step 4 takes time O(n2). 4.2 Structurally Underconstrained Problems: The Decomposition Analysis In this section we present the decomposition analysis in which underconstrained cluster con gurations are handled. Adding constraints to trigger local cluster merging may yield locally overconstrained or nonsolvable con gurations as illustrated by the following example.

37 Example 4.1 Figure 4.2 shows the constraint graph of an underconstrained geometric problem that needs the addition of three constraints to become well-constrained and solvable. An addition of constraints that makes the graph solvable and wellconstrained is the following: (v1 v3), (v7 v9) and (v15 v13). However, if we start by adding (v16 v10) to trigger a local cluster merging, then any addition of two more constraints will make the problem nonsolvable. Thus the local reduction analysis is insucient for underconstrained problems.

v3 v2 v18

v5 v4 v1 4

v17

v6 v7

v16

v15

v8 v13

v10 v9

v14 v12

v11

Figure 4.2 A structurally underconstrained graph where adding edges (clusters) to trigger local cluster merging does not always work. The decomposition analysis described below can be used for analyzing well-constrained graphs as well. However, it cannot handle overconstrained graphs and cannot eciently handle extensions such as angle derivations (see Section 5.2). The decomposition analysis can be considered the reverse process of the reduction analysis. The decomposition analysis can be characterized as top down, while the reduction analysis can be characterized as bottom up. Owen in Owe91] sketches a similar decomposition method to solve well-constrained systems of geometric constraints. Owen's

38 method analyzes the original constraint graph and as mentioned in Owe91] does not guarantee solving an underconstrained problem for which one could add geometric constraints that make the problem well-constrained and solvable. Owen's algorithm runs in time O(n2 ) and uses the linear algorithm for nding triconnected components presented in HT73]. The decomposition analysis presented in this section analyzes the cluster con guration derived by the reduction analysis and is proved to handle all unconstrained problems that can become well-constrained and solvable by adding constraints. Our decomposition algorithm has quadratic worst case time complexity and uses the classical linear depth rst search algorithms for nding split components and articulation nodes HT73, Tar72]. 4.2.1 Decomposition Analysis In this part we analyze the cluster con guration derived at the end of the reduction analysis. We partition the clusters into two or three sets that pairwise share exactly one geometric element. We continue this process recursively until we have decomposed all clusters into sets containing only one edge. We assume that the cluster graph derived at the end of the reduction analysis is connected (if not, then we introduce systematically clusters to join the connected components). The dierent elementary cases that may arise under this assumption are basically two and are depicted in Figure 4.3. In this gure, S1, S2, and S3 denote cluster sets and C denotes a cluster. Note that for case (a) we do not need to introduce any additional clusters S1

S2

S2

C

S3 S1

S2

(a)

S1

(b)

Figure 4.3 The two basic cases for decomposing the clusters into sets.

39 that represent constraints, for case (b) we need to introduce one additional cluster C . The corresponding cluster merging operations will be carried out in reverse order. We must be careful to avoid selecting a partition where all three shared geometric elements are lines for case (a). For case (b), when the shared element is a line we choose to add a (line, point) or a (point, point) cluster. If we have exactly two clusters, each with exactly two lines (the reduction analysis guarantees that there are no clusters that contain only lines and have more that two elements), we add a point and three constraints as shown in Figure 4.4.

p

C3 l3 C2

C4 C5 l2 l1

C1

Figure 4.4 An underconstrained cluster con guration containing only lines. We add a virtual point p and three constraints in the form of the clusters C3, C4 and C5. On the underconstrained graph of Figure 4.2 the reduction analysis has no eect, since there are no triangles. The decomposition analysis however can successfully solve the underconstrained problem and determine three additional constraints that will make it solvable. The corresponding clusters (one for each edge) can be split in three sets, with shared geometric elements v1, v7 and v13. However, this method cannot handle problems that are consistently overconstrained such as the one depicted in Figure 4.1, for which there is no decomposition of the clusters in two or three sets that pairwise share exactly one geometric element. The reduction analysis can eciently handle such geometric constraint problems.

40 4.2.2 Correctness of the Decomposition Analysis After a nite number of decompositions (which is bounded by the number of clusters) there will be no more clusters collections that can be decomposed any further. This shows termination. The following lemma guarantees that if there is a sequence of constraint additions that make the cluster con guration solvable, then the decomposition analysis will reveal one such sequence. We prove the following: Lemma 4.1 If there is a sequence of decompositions leading to a collection of single clusters then every decomposition sequence will result into a collection of single clusters. Proof Assume that there is a sequence of decompositions D that results in a collection of single clusters. Let us also assume for the purposes of contradiction that there is a subset S of the initial set of clusters that is not decomposable, and is derived by another sequence of decompositions. Since D gives a nal collection of single clusters, at some point the clusters of S will be partitioned into two or three sets. Consider the particular decomposition of D that causes this to happen for the rst time to a superset of S. This clearly means that there is a decomposition of S, which contradicts our assumption. 2 Of course the resulting solutions may not be congruent in a geometric sense, since dierent choices of decompositions may result in dierent choices of constraint additions, giving geometrically incongruent solutions. This is depicted in Figure 4.5, where the same underconstrained problem, given in the form of a dimensioned sketch by the user (Figure 4.5(a)) may result in two incongruent solutions if we designate the additional dimension values as shown.

4.2.3 An Ecient Algorithm for Decomposition We present an algorithm that correctly implements the decomposition method described above and runs in time quadratic in the number of clusters and geometric

41 Pt1 13.000

22.000

Pt5

Pt6

9.000

9.000

Pt2

(a)

Pt1

Pt1

13.000 13.000

22.000

13.738 22.000 Pt2 9.0000

9.0000

Pt5

17.000

Pt5 Pt6

9.0000

Pt6 9.0000

Pt2

(b)

(c)

Figure 4.5 Getting two geometrically incongruent solutions, (b) and (c), from the same underconstrained draft (a). elements. We will use the graph GR derived by the reduction part of the analysis. Recall that in this graph, both clusters and geometric elements are represented by nodes and an edge between two nodes means that the geometric element belongs to the corresponding cluster. We transform our graph GR = (VR ER) to a graph GD = (VD  ED ), where VD has all the nodes of V plus two more nodes for each node that corresponds to a cluster. Let VRc and VRg be the set of nodes that correspond to clusters and geometric elements respectively (VR = VRc VRg ):

VD = ED =

v2VRg

fv g

(uv)2ER u2GgR v2GcR

v2VRc

fv 1 v 2 v 3g

f(u v 1) (u v 2) (u v 3)g

42 We assume that the original graph G is connected, thus the resulting graph GD is also connected. If not then we apply the algorithm to all connected components of GD and then we add pairwise constraints (clusters), so as to sequentially locate the clusters with respect to each other. This will require adding 2c ; 3, constraints where c is the number of connected components. The algorithm that we are going to present in this section uses a DFS algorithm for nding the split components of a biconnected graphHT73]. We introduce now some terminology adopted from HT73]. Let G be a connected undirected graph. Then a is an articulation node of G i there is a pair of vertices fu vg, u v 6= a, such that a is on every path connecting u and v. If the graph has no articulation nodes, then it is called biconnected. Let fa bg be a pair of vertices in a biconnected graph G. The edges of G are divided into separation classes E1  E2  : : :Ek , such that two edges which lie on a common path not containing any vertex of fa bg except as an endpoint are in the same class. If there two or more separation classes, the pair fa bg is called an articulation pair of G except if there are exactly two separation classes and one of them consists of a single edge or there are exactly three separation classes each consisting of a single edge. If G has no articulation pairs then G is said to be triconnected. Let us assume that there is an articulation pair fa bg with separation classes E1 E2 : : :Ek . Let E 0 = Smi=1 Ei and E 00 = Ski=m+1 , such that jE 0j jE 00j  2, and let G0 = (V (E 0) E 0 f(a b)g) and G00 = (V (E 00) E 00 f(a b)g), the graphs G0 and G00 are called split graphs of G and the operation of splitting G into G0 and G00 is called splitting. The inserted edge (a b) is labeled to denote the split and is called a virtual bond. Merging G0 and G00 to form G is called merging. If we keep splitting the split graphs of G and so on, until we end up with graphs that cannot be decomposed any further, then the collection of those graphs (which are triconnected) are called split components of G. The decomposition of a biconnected graph G in split components is not unique. By merging the split components pairwise we get the original graph. We distinguish three types of split components: triple bonds, triangles and other triconnected graphs. If we perform all merging operations between bonds

43 and all merging operations between triangles, then the resulting graphs (bonds and polygons) together with the rest of the triconnected split component graphs form the triconnected components of G. It is a standard result that the decomposition of a graph G in triconnected components is unique Mac37]. The algorithm works as follows: 1. If the graph is not biconnected then split the graph in biconnected components. If the graph has k biconnected components, then we will need to insert k additional (pairwise) constraints. This corresponds to k decompositions of type (b). Then apply Step 2 to each of the biconnected components. If the graph is biconnected then proceed to Step 2. 2. Find all split components for the graph. If there is no articulation pair stop. If among the split components there is a triangle having as edges only virtual bonds and whose vertices are not all lines, then the overall graph is decomposable and the separation triple consists of the vertices of the triangle. This corresponds to one decomposition of type (a). The three component graphs can be easily found by following the virtual bonds. We then apply the algorithm recursively to all three components. If we end up with graphs that contain nodes that correspond to only one cluster, then the constraint problem is solvable. The rst step of the algorithm takes time O(jED j + jVD j) Tar72]. Finding the split components each time the second step is executed takes time O(jED j + jVD j) HT73]. The number of times that we need to decompose the components is bounded by jVD j, since each time we decompose the graph, the number of cluster nodes at each component is reduced by one. Thus the algorithm takes at most O((jE j + jV j)2) time. If we assume that the number of edges jE j= O(n) then the decomposition analysis of the algorithm takes time O(n2).

44 1 C2 p1 p1

l2

C2

C3 C1

2 C2

l2

C32

p4 p3

l3

C4

p2

C7 C5

p4 C6

p7

l1

p7

1 C7 2 C7

p6 p5

C8

p6

3 C7

Figure 4.6 (left) A cluster con guration that is derived from an underconstrained system of geometric constraints. (right) The graphs representing a cluster with two and a cluster with three geometric elements. Every cluster corresponds to a triconnected graph that cannot be split any further. Figure 4.6 depicts an underconstrained cluster con guration that is missing one constraint. The corresponding graphs for a cluster with two and three elements are depicted on the right. A decomposition sequence of the set of clusters, is the following: fC1  C2 C3  C4 C5  C6 C7 C8 g ! ffC1g fC2g fC3  C4 C5  C6 C7  C8gg ! ffC1 g fC2g fC3g fC4g fC5  C6 C7  C8gg ! ffC1g fC2 g fC3g fC4g fC5 g fC6g fC7 C8 gg ! ffC1g fC2g fC3 g fC4g fC5g fC6 g fC7g fC8gg

So the con guration is solvable, and the last decomposition is a type (b) decomposition and means that we have to add a cluster (constraint) between p5 and p7 or alternatively, between p5 and p4.

45 C2

l2

F

l2

p1

F

p1

p1 D

E C1

E

l2 C3 p4

D

l3 l3

l3 p2

B

C4

p3

p2

C7 B

C5 p7 l1 C6

p4

A

A

p7 l1 p6 p5 C C p5 C8

p6

Figure 4.7 A decomposition in split components of the graph that corresponds to the cluster con guration of the previous gure. Figure 4.7 shows a decomposition into split components of the graph GD for the cluster con guration of Figure 4.6. The edges inside the clusters are omitted and they are as in Figure 4.6 (left). The existence of the triangle, ffp1  l2 l3 g f(p1 l2 ) (l2 l3) (l3 p1 )gg

means that there is a decomposition of the cluster in three sets that pairwise share a single geometric element, and that one of them represents a point. We prove now that the above algorithm correctly realizes the decomposition analysis described in Section 4.2.1. It suces to prove that: Lemma 4.2 A cluster con guration with a biconnected graph GD as de ned above, is decomposable into three sets of clusters that pairwise share exactly one geometric element, one of which is a point, if and only if every decomposition of the graph into split components contains at least one triangle whose edges are all virtual bonds, and whose vertices are not all lines.

46 Proof Assume that among the split components of GD there is a triangle (a b c) whose edges are virtual bonds, and whose vertices are not all lines. Then, since we have replicated each cluster node and all the adjacent edges, we are certain that no articulation node or articulation pair will contain any cluster nodes. Thus, all three articulation pairs (a b), (b c) and (c a) correspond to geometric elements, and GD can be decomposed into three sets of clusters, sharing pairwise a single geometric element. These sets can be found if we follow the labels of the virtual bonds (see Figure 4.7). Now assume that the cluster con guration can be decomposed into three sets of clusters pairwise sharing exactly one geometric element. Let (a b c) be the shared geometric elements, and assume without loss of generality that vertex a corresponds to a point. We can nd at least one decomposition of GD into split components containing the triangle: (fa b cg f(a b) (b c) (ca)g). We know however (see e.g. Mac37]), that the decomposition of any graph in triconnected components is unique. We also know from HT73] that merging split components that are triangles as much as possible, will give us a number of polygons which are triconnected components of the original graph. Since polygons occur as triconnected components only as a result of two or more triangles being merged (otherwise they would split), we conclude that every decomposition of GD in split components will contain a triangle graph whose one vertex is a and whose edges are virtual bonds (there are no edges between geometric elements and all articulation pairs consist of geometric elements). 2

47

5. EXTENSIONS We present two extensions of the scope of the analysis phase. Both extensions are incorporated in the reduction analysis, do not aect the overall time complexity and can be used also in conjunction with the methods of Section 4.1 for solving consistently overconstrained problems. 5.1 Extending the Repertoire of Reductions The reduction analysis can be extended to include more complicated reductions, as the one depicted in Figure 5.1 for which the constructions are presented in BFH+95]. We replace the DFS of Step 3 of the reduction analysis algorithm (Section 3.3), for nding the triangles in graph G with the less ecient BFS from every cluster node of the cluster-geometry graph H , to nd a 4-cycle or a 6-cycle or if there is not any, an 8-cycle with exactly 3 incoming edges at the cluster-node of level 4. Similarly we modify Step 4 of the reduction analysis algorithm. An 8-cycle with exactly 3 incoming edges (see Figure 5.2), corresponds to the cluster con guration of Figure 5.1. In Figure 5.2 we have started a BFS from C1 and at level 4 we detect that the node that corresponds to cluster C2 has exactly 3 incoming edges. Remember that all geometry nodes g1 : : : g6, and cluster nodes C3, C4 and C5 have only one incoming edge since there are no 6-cycles and no 4-cycles. However more that 3 incoming edges in a cluster node of level 4, mean that we have an overconstrained con guration. At this point we can either return the overconstrained subgraph or treat it as a consistently overconstrained con guration by taking into account only three incoming edges, merge the 5 clusters into one and then check for consistency with the remaining ones. Although Step 3 is now computationally more expensive, the overall worst-case time complexity remains O((jE j + jV j)2).

48

C3

g4

g1

g5 C2

C4 g2 C1 C5

g3

g6

Figure 5.1 A well-constrained cluster con guration that cannot be solved by the basic method.

C1 g2

g1 ...

... C4

C3 g4 ...

...

g3

g5

C2

g6

... C5 ...

...

Figure 5.2 Detecting the cluster con guration of the previous gure during the reduction analysis, by a BFS rooted at C1.

49 5.2 Incorporating Angle Derivations By utilizing information about the semantics of the geometries, we may perform certain graph transformations that have the potential of converting a constraint graph that is not solvable by our basic method to an equivalent solvable constraint graph. p3

l3

p3

l3

p7

p4

p6 l1

l2

l1

l2 p5

p2

p1

p2

p1

Figure 5.3 Two constraint con gurations that can be solved only if we utilize angle derivations. A powerful graph transformation rule can be based on the following observation: if we have three lines l1, l2, and l3 and the angles (l1 l2) and  (l2 l3), then the angle between  (l1 l3) must be  +  . This implies that we can substitute any tree that corresponds to n line nodes with n ; 1 angle constraints by any appropriate spanning tree of the complete graph that corresponds to the n lines. In Figure 5.3 (left) we see a constraint graph that is not solvable by our basic reduction analysis, but it becomes solvable if we replace edge (l1 l2) with edge (l1 l3) applying the graph transformation rule described above. This rule can be generalized and applied also in cases where while initially there are no explicit angles between lines, implicit angle constraints may later occur as a consequence of cluster merging. In Figure 5.3 (right) we see such a constraint graph. To eciently handle this graph transformation, we partition all nodes that correspond to line geometries into a number of angle classes. Two line vertices belong to the same angle class if and only if the angle between them is known. The binary relation known angle between two lines is reexive, transitive and symmetric. We can nd the angle classes formed by the initial angle constraints in time O(jE j + jV j), by

50 maintaining with each line geometry a bidirectional pointer to its angle class, which is initially set to contain only the line itself. Then we traverse the original constraint graph (e.g. by a DFS), and each time that we nd an edge between two lines that represents an angle constraint we merge the two corresponding angle classes, by merging the two lists that represent them. Two line vertices that belong to the same cluster, are always in the same angle class. Thus it is easy to maintain a bidirectional pointer in each cluster node to the angle class of its line vertices. l1 l2 l3 l1 l2 l3 p3

l3

C5

C1 C2

C4

l1

l2

C1

C8 p4

p2

C3

p1

C2

l1

C4

C5

l2

C9

C6 C7 p1

p2 C4

p6

C5

p5

C1

l3

p7 p3

C2 C3

p1

l2

l3

l1

p3

p2

Figure 5.4 Cluster con gurations for the geometric constraint problems of the previous gures after some initial cluster merging has occurred. The information maintained for the angle classes is also shown. We then modify Step 3 of the reduction analysis to additionally check whether some angle class triggers a cluster merging, this is done by checking in graph H all cluster nodes associated with the angle class to detect two that have a common point vertex. This can be done in time O((jE j + jV j)2). When a cluster merging occurs the associated angle classes are also merged, and the links to and from the clusters and

51 the corresponding line vertices are updated in time O(jE j + jV j). Finally when we perform a BFS from a cluster vertex formed by merging three clusters, we also check whether the associated angle class triggers any further cluster merging, this takes time O(jE j + jV j). Thus, the overall worst case time complexity remains O((jE j + jV j)2). In Figure 5.3 (left), there is initially only one angle class fl1 l2 l3g, whereas in Figure 5.3 (right) there are initially three angle classes fl1g, fl2g, and fl3g. In Figure 5.4 (left) we have the cluster con guration of the constraint problem of Figure 5.3 (left), after the rst two cluster mergings have occurred. Now we check to see whether the angle class triggers some additional cluster merging, and we nd that C2 and C5 have indeed a common point vertex p3, meaning that C2 and C5 can be merged. In Figure 5.4 (right) we have the cluster con guration of the constraint problem of Figure 5.3 (right), after four cluster merging operations have occurred. The two angle classes and their links to the clusters are also shown. When clusters C5, C6 and C8 are merged the corresponding angle classes are merged as well, and the problem becomes similar to the one in Figure 5.3 (left).

52

6. CONIC ARCS Blending two line segments in a sketch is an important operation in CAD/CAM systems and their user interfaces. The majority of CAD/CAM systems provide circular arcs for this purpose. When connecting two given line segments at their end points, four degrees of freedom are needed. Circular arcs, however, have only three degrees of freedom, and therefore can be used only when the two line segments are in special position | when the end points to be connected by the arc are equidistant from the intersection of the extended line segments. General conic arcs, on the other hand, oer ve degrees of freedom. Consequently, they can be used to blend any two line segments with one additional degree of freedom available as a shape parameter. In CAD/CAM systems, the segments to be blended are often parallel or nearly so. Therefore, it is highly desirable to use representations and constructions that are capable of handling both parallel and intersecting segments uniformly. Consequently, such representations are expected to increase the robustness of the system. Motivated by these considerations, in this chapter, we describe how to construct conic blending arcs from constraints, using a uni ed rational parametric representation that combines the separate cases of blending parallel and nonparallel edges. The possible constraints are that the arc must have a given distance from a line, a point, or a circle, or else intersect a circle or a line at a prescribed angle. Our representation is easily converted into a rational B-spline with positive weights, and is therefore compatible with internal representations used by most solid modeling systems. Finally we discuss how to provide for conic arcs in the analysis phase. In prior work, an explicit parametric form for a conic arc that blends two segments and passes through a third point has been studied by Liming Lim79] and Faux and Pratt FP79], but the cases of parallel and nonparallel segments must be handled

53 separately. A rational quadratic Bezier formula for the nonparallel case is presented in Far93]. In Pie87b], Piegl proposes \in nite" control points which can be used to handle parallel end tangents Pie87a]. In Far93], Farin derives a solution for nding a conic arc that blends two given segments and is tangent to a third line. He assumes nonparallel segments. A complete representation for any circular arc using rational B-splines is presented in Til83] and PT87]. In the same work they prove that one convex control polygon can de ne only one such conic arc. Finally, in BFH94], regular rational Bezier curves are used for representing conic arcs and other free form edges. In this work, the degree of the appropriate parametrization is speci ed on a case by case basis. Dimensional geometric constraint solvers usually restrict the shape vocabulary to line segments and circular arcs. There seems to be little published work that addresses the incorporation of more general geometric shape primitives. Malraison Mal94] develops a technique for constraining a control net of a rational quadratic Bezier curve to be always an elliptical arc. No constraints may be imposed on the elliptical arc itself except at the end points. In BFH94], a number of constraints are allowed between an edge, which is described by a classical rational Bezier parametrization of arbitrary degree, and other geometries. The constraints are then translated into equations by making use of the implicit equation for the Bezier curve, and the nal system of equations is solved using an iterative method. The authors mention that the solution derived by this method is sensitive to the initial positioning of geometric objects, making the problem of root selection hard to solve (see also, Fud93] for a discussion of the problem of root selection in geometric constraint solving). GN94] considers the problem of conics that have C 2 contact with a plane curve, that is, tangency and curvature of the two curves agree at the contact point. A representation for conics of contact is derived using rational quadratic Bezier curves. Finally in HP94], Homann and Peters discuss how to construct a class of cubic Bezier curves from geometric constraints.

54 In Section 6.1, we specify our representation for a conic arc that is tangent to two given segments and passes through a given point. In Section 6.1.4, we describe how our basic representation can be converted to a two-piece rational quadratic B-spline with positive weights. In Section 6.2, we give algebraic methods for constructing a blending arc which is constrained to a given line, point or circle by a distance, tangency or angle constraint. Finally, in Section 6.3, we discuss how to integrate the constructions in the construction phase of the constraint solver, and how to modify the analysis phase, to provide for conic arcs. 6.1 A Uniform Representation for Conics We develop a uniform rational Bezier representation for a conic arc that blends two segments at the end points and interpolates a third point. We rst review the nonparallel Far93] and the parallel Pie87b] cases separately. Then, we construct a uni ed representation that that is capable of handling both cases. It is well-known that a rational quadratic Bezier curve is a conic arc. However, when the denominator of the coordinate functions vanishes in the interval 0 1], the arc will contain points at in nity. Below, we will exclude those arcs because they are unsuitable for applications in CAD. 6.1.1 Nonparallel Tangents A rational quadratic Bezier curve with nonparallel end tangents has the form: 2 2 c(t) = w0(1w ;(1t;) Ct)2++22ww1t(1t(1;;t)tE) ++ww2tt2 D  t 0 1] 0 1 2 Where C, and D are the end points of the arc and E is the intersection of the end tangents. Let P = (Px Py ) be the point we wish to interpolate, and let ( 0 1 2) be the barycentric coordinates of P with respect to the triangle 4 C E D. The lines of the triangle partition the plane into several regions. Figure 6.1 (left) shows the signs of the barycentric coordinates when P lies in each region. We write P = c(tP ) =

0C + 1E + 2D. By comparing coecients (see Far93]), we derive the implicit

55

C 2

(-,+,-)

1.5

E

D 1

(+,+,-)

(-,+,+)

P

0.5

(+,+,+)

C

D -1

-0.5

(-,-,+) (+,-,-)

(+,-,+)

P

0 0

0.5

1

1.5

2

-0.5

-1

E

Figure 6.1 (left) The signs of the barycentric coordinates. (right) A conic arc blending two segments and interpolating the origin.

P 1

(+, +, +) 0.5

v

(+, +, -)

C

(-, +, +)

-2

D

-1.5

C

-1

-0.5

0

0

0.5

1D

(+, -, -) (+, -, +)

(-, -, +)

-0.5

-1

Figure 6.2 (left) The sign of the coecients for the case of parallel tangents. (right) A conic arc blending two parallel segments and passing through (1 1).

56

q

formula 12w0w2 = 4w12 0 2. When 0 and 2 are positive and 1=(2 0 2) > ;1, an acceptable solution is obtained. In all other cases, the conic arc will pass through in nity or degenerate into a pair of line segments. The unique solution is given by w1 = 2p

1

0 2 (6.1) (1 ; t)2 C + 2w1 t(1 ; t)E + t2D c(t) = (1 ; t)2 + 2w t(1 ; t) + t2  t 2 0 1] 1

6.1.2 Parallel Tangents Let C = (Cx Cy ), D = (Dx Dy ) be two endpoints and let ~v = (vx vy ) be a tangent vector of the two parallel segments. Then the rational Bezier form of the blending conic can be written 2 2 w v + w 0(1 ; t) C + 2w1 t(1 ; t)~ 2t D  t 0 1] (6.2) c(t) = w0(1 ; t)2 + w2t2 In Pie87a], ~v has been called a control point at in nity. Let d(S~r R) be the unnormalized distance of the point S from the line through R with direction ~r that is, d(S~r R) = (Sy ; Ry )rx ; (Sx ; Rx)ry . By Area(C P D) we denote the signed area of the triangle 4 C P D. When the two intersecting tangent lines become parallel, their intersection E moves to in nity i.e., E = limr!1 r~v. By taking the barycentric coordinates in the limit, we get P = c(tP ) = T0C + T1~v + T2D where

v D) T2 = d(P~v C) T1 = 2 Area(C P D) T0 = dd((PC~ ~v D) d(D~v C) d(C~v D) By comparing the coecients we obtain the implicit equation:

(6.3)

T12w0w2 = 4w12T0T2 The signs of the coordinates (T0 T1 T2) of P are shown in Figure 6.2 (left). An acceptable solution will require that T0 > 0 and T2 > 0. Here, P is in the strip de ned by the two parallel lines. The unique solution is the elliptic arc:

57

w1 =

qT

1

2 T0T2 (6.4) 2 2 c(t) = (1 ; t) Ct+2 +w1(1t(1;;t)t2)~v + t D  t 0 1] Note that the solution is not aected by changing the sign of ~v or the order of the points C and D. An example is shown in Figure 6.2 (right) for C = (;1 0), D = (1 0), v~ = (1 1), and P = (1 1). 6.1.3 A Uni ed Representation Let ~v, ~u be the two tangent vectors of the conic arc at the end points. Let C and D be the two endpoints of the conic arc, and let P be the third point we wish to interpolate. Let U = (vxM2 ; uxM1 vy M2 ; uy M1), where M1 = Cxvy ; Cy vx and M2 = Dxuy ; Dy ux. Furthermore, let v~  ~u = vxuy ; vy ux be a scalar. We will prove that the solution c(t), if it exists, is given by: (1 ; t)W + t D  c(t) = (1 (1; t;) tC)2++22twt (1 ; t) + t2 2

where

2

t 2 0 1]

(6.5)

Area(C P D) U d(D~v C) d(P~v C) d(C ~u D) d(P ~u D) (6.6) ~ ~ Area ( C  P  D )( v  u ) w = q d(D~v C) d(P~v C) d(C ~u D) d(P ~u D) and that the formula is valid whether the vectors ~u and ~v are linearly dependent or not. We assume that P is not on any of the three lines, through C with direction ~u, through D with direction ~v, and through C and D. Moreover, the three lines are assumed distinct, so that the denominators of W and w do not vanish.

W = q

58 Scale and Sign Invariance

We observe the following: 1. d( ~v ) = d(~v ). 2. Let U = fU (u~ ~v), where fU is de ned by the expression for U above. Then fU (~u~v) = fU (~u~v). and fU (~u ~v) = fU (~u~v). 3. (~v  ~u) = (~v  ~u) and (~v  ~u) = (~v  ~u). Consequently, if we replace ~u with ~u and ~v with ~v in (6.5), the same arc is obtained. When the sign of the square root in the denominator is chosen equal to the sign of d(D~v C) d(C u~  D), the representation becomes independent of sign and magnitude of the end tangent vectors. Correctness for Nonparallel Tangents

Using the well-known interpretation of barycentric coordinates as area ratios in the subdivision of 4 C D E by P, we can rewrite w1 from (6.1) as Area(C P D) w1 = q 2 Area(P E D)Area(C E P) But  D)d(D~v C) Area(P E D) = 21 kEDk d(P (E D) E) = d(P u~2( ~v  u~ ) (6.7) ~ 1 d ( P ~ v  C ) d ( C  u  D ) Area(C E P) = 2 kECk d(P (E C) C) = 2(~v  ~u) so that w1 in (6.1) is equal to w in (6.6). Now the intersection E must satisfy the system: (Ey ; Dy )ux ; (Ex ; Dx )uy = 0 (6.8) (Ey ; Cy )vx ; (Ex ; Cx)vy = 0 . Therefore, (6.5) is equivalent to (6.1) for the case of By algebra, E = (~v U  ~u) nonparallel tangents.

59 Correctness for Parallel Tangents

We set ~u = v~ because of scale and sign invariance. Then w = 0 and U = (M2 ; M1)~v = d(C~v D)~v. From (6.3), and (6.6) we obtain Area(C P D) W= q d(C~v D)~v = qT1 ~v d(D~v C)d(P~v C)d(C~v D)d(D~v C) 2 T0 T 2 from which we derive that W = w1~v. Hence the formula is valid for parallel tangents. Acceptable Solutions

Observing the formal correspondences of (6.1) and (6.2) with (6.5), an acceptable solution exists if, and only if,

d(D~v C)d(P~v C) > 0

d(C ~u D)d(P ~u D) > 0

w > ;1

For instance, we obtain the arc of Figure 6.1 (right) if we set C = (1 2), D = (2 1), v~ = (;2 ;3), ~u = (;3 ;2) and P = (0 0), in (6.5). Similarly we obtain the arc of Figure 6.2 (right) if we set C = (;1 0), D = (1 0), ~v = (1 1), u~ = (1 1) and P = (1 1). Determining the Type of the Conic Arc

By studying the singularities of the denominator of (6.5) (see e.g., Lee87]), we derive the following conclusions for the type of the conic arc c(t), t 2 0 1]: (i) w > 1, is a hyperbolic arc. (ii) w = 1, is a parabolic arc. (iii) ;1 < w < 1, is an elliptic arc. 6.1.4 Converting to a Rational B-spline No class of rational Bezier curves of any xed degree is capable of representing all acceptable solutions de ned by (6.5) with positive weights alone. Since most commercial solid modeling software restricts to positive weights, in the implementation,

60 we translate our representation, used internally, to a two piece B-spline representation when interfacing to the solid modeler. By doing so, we also bene t from a large repertoire of algorithms for handing rational B-splines with positive weights e.g., Til83]. We subdivide our conic arc de ned by (6.5) at t = 1=2 such that the two resulting conic arcs are the two pieces of a C 1-continuous rational B-spline. C 2-continuity of the quadratic B-spline is then implied. Since the tangent at t = 1=2 is parallel to CD, it must intersect both end tangents. Let A and B be the intersection points (see Figure 6.3). It is well-known that a rational parametric curve can be considered l A

l

1

P

2

B

v C

u D

Figure 6.3 Subdividing a conic arc at t = 1=2. to be the projection of a parametric space curve to a plane e.g., Far93]. Speci cally, we take the Bezier space curve de ned by C 1], W w] and D 1], where w and W are as in (6.5). Its projection to the plane w = 1 is the original rational curve. Using this formulation, a routine computation shows that the following rational B-spline represents the original conic arc exactly D + W , D] Control Points: C, C1 ++ W , w 1+w 1 Knot Vector: 0, 0, 2 , 1, 1] Weights: 1, 1 +2 w , 1 +2 w , 1]

61 6.2 Constructions We present geometric and algebraic methods for constructing a blending arc that satis es an additional geometric constraint with another geometric object. All computations are valid independently of the relative position of the geometric objects involved. 6.2.1 Tangency to or Distance from a Line In this Section we discuss a geometric construction for constructing a conic arc that blends two segments and is tangent to a line. The case of requiring that the arc have a given distance from a line directly reduces to this case. The construction is in terms of the uniform representation explained before. Let ! be the line which is to be tangent to the conic arc. We will determine the point P where the conic touches the line !, thereby reducing the problem to the interpolation problem solved in the previous Section. First, we will describe a geometric construction that derives P and then we shall prove its soundness. The construction for intersecting tangents is from Far93], and is shown in Figure 6.4 (left). For parallel tangents, the construction is illustrated in Figure 6.4 (right). Let l1 be the line that passes through C and is parallel to ~v, and l2 be the line that passes through D and is parallel to ~u. We assume that ! intersects both l1 and l2 at two points A, B other than C, D, and E is the intersection, if any, of l1 and l2. We then nd the intersection point Q of AD and BC. Then the intersection P of line ! with the line l through Q with direction ~r = U ; (~v  u~ )Q will be shown to be the point of tangency. Here U is as before in Section (6.1.3). (i) Nonparallel tangents: The correctness of the construction uses Pascal's theorem ~ = 1 ~r, the geometric construction is consistent Far93, Lim79]. Since QE (~v  ~u) ~ with the de nition of r.

62

E

Λ

Λ

l2 l1

B

B P

P

A

A u Q v

v

Q

l2

l1

r

r

C

D

C

D l

l

Figure 6.4 (left) Finding the point of tangency in the case of nonparallel tangents. (right) Finding the point of tangency in the case of parallel tangents.

5

5

Λ

Λ 4

4

C

C 3

3

2

2

P 1

1

P -4

-3

-2

-1

0 0

1

2

3

-4

0 0

-2

-1

D

4

-1

-2

D -3

2

-2

-3

Figure 6.5 Blending two segments by a conic arc that is tangent to a given line.

63 (ii) Parallel tangents: The correctness of the geometric construction is clear from the projective interpretation of Pascal's theorem (~v  ~u) = 0, so the geometric construction is consistent with the de nition of ~r. The construction of Q assumes that ! intersects both l1 and l2. However, it is possible that ! is parallel to l1 or l2, yet we are still able to nd a blending arc that is tangent to !. We include this case by determining Q from a computation similar to the one used to compute P: We intersect the line through C with direction ~r1 = U1 ; (n~  ~v) C, and the line though D with direction ~r2 = U2 ; (n~  ~u) D. Here n~ is the normal vector of ! and U1 and U2 are de ned as follows, U1 = (ny L1 + vxd ;nxL1 + vy d), U2 = (ny L2 + uxd ;nxL2 + uy d), where L1 = vy Cx ; vxCy , L2 = uy Dx ; uxDy . For this problem, there is only one solution. Figure 6.5 shows two examples, one with intersecting, the other with parallel tangents. 6.2.2 Tangency to a Circle or Distance from a Point We seek blending arcs that are tangent to a given circle. The case is equivalent to requiring that the arc have nonzero distance from a given point. To solve this problem, we will determine the point P at which the arc must touch the circle. Without loss of generality, we assume that the circle R is centered at the origin and has radius d > 0. Let P be the point of tangency with the conic arc c(t), and let ! be the common tangent through P. Let n~ = (nx ny ) be the unit normal of !. If we determine ~n, then we have reduced the problem to interpolating the point P = (d nx  d ny ). Our strategy is to use an approach similar to that of Section 6.2.1. Let A = (Ax Ay ) be the intersection point of ! and l1, B = (Bx By ) be the intersection of ! and l2, and Q = (Qx Qy ) be the intersection point of AD and BC. If ! is parallel to l1, then A is at in nity. This means that Q can be found by intersecting BC and the line that passes through D and is parallel to !. Similarly, if ! is parallel to l2, we intersect AD and the line that passes through D and is parallel to !. All cases can be expressed uniformly by the following system of equations:

64

~ = 0 ~r1  CQ (6.9) ~ ~r2  DQ = 0 where ~r1 = U1 ; (~n  ~v) C and ~r2 = U2 ; (n~  u~ ) D. Finally U1 and U2 are de ned as in Section 6.2.1. Since ! is tangent to the curve c at P, P is on the line l that passes through Q in the direction ~r = (rx ry ) = U ; (~v  ~u)Q (the correctness of this claim can be proved by an analysis similar to that of section 6.2.1). Therefore ;ry (d nx ; Qx ) + rx (d ny ; Qy )

= 0

(6.10)

By solving (6.9) we determine Qx Qy in terms of nx ny . Substitution of Qx Qy in (6.10) yields (U  ~n ; (~v  ~u)d)(a0 + a1nx + a2ny + a3n2x + a4n2y + a5nxny ) = 0

(6.11)

where the ai are constant expressions. The rst term of (6.11) corresponds to the case where the line ! passes through the intersection point E of l1 and l2 (this point is at in nity for parallel tangents). This case does not yield a solution, so it suces to solve

a0 + a1nx + a2ny + a3n2x + a4n2y + a5nxny = 0 nx + ny = 1 2

2

(6.12)

A routine Grobner basis computation produces an equivalent system in which ny is determined from a univariate polynomial and nx from a linear one:

c4n4y + c3n3y + c2n2y + c1ny + c0 = 0 e0nx + e1 = 0

(6.13)

Next, we determine P = (d nx d ny ) and use (6.5) to derive the arc c(t). As indicated by the system (6.13), up to four distinct solutions are possible. Figure 6.6 shows an example with C = (1=5 2), D = (5=2 1=2), ~v = (6=5 3), ~u = (7=2 3=2),

65

v

2.5

2

v

2.5

C

C

2

1.5

1.5

1

1

D

R

0.5

u

0.5

R

D

u

0

0

-0.5

-0.5 -0.5

0

0.5

1

1.5

2

2.5

3

-0.5

0

0.5

1

(a)

v

2.5

2

2.5

3

v

2.5

C

2

1.5

(b)

C

2

1.5

1.5

1

1

0.5

D

R

0.5

u

0

D

u

0

R -0.5 -0.5

0

0.5

1

1.5

2

2.5

3

-0.5 -0.5

0

0.5

1

(c)

1.5

2

2.5

3

(d)

Figure 6.6 Four solutions for a conic arc that blends two segments and is tangent to a circle. v

2.5

v

2.5

C

2

2

C 1.5

1.5

1

R

1

R u

0.5

0

u

0.5

0

C

-0.5

D

-0.5

-1

-1 -1

-0.5

0

0.5

1

1.5

2

2.5

-1

-0.5

0

0.5

(a) v

2.5

1.5

2

2.5

v C

2 2

1

(b)

C

1.5 1

R 1

R

u u

0.5

0

D

D

0

-1 -0.5

-1 -1

-0.5

0

0.5

1

(c)

1.5

2

2.5

-1

0

1

2

(d)

Figure 6.7 Four solutions for a conic arc that blends two parallel segments and is tangent to a circle.

66 and d = 0:45. Solutions (a), (b) and (c) are hyperbolic arcs, while solution (d) is an elliptic arc. The tangents are not parallel. Figure 6.7 shows an example with C = (0 1:8), D = (3=2 0), ~v = ~u = (;1 ;1), ~v = (;1 ;1), and d = 1. In this case the segments we blend are parallel, so all solutions are elliptical arcs. 6.2.3 Angle with a Line Let !0 be a line and  be the speci ed signed angle which we impose between !0 and the conic arc c. Let P be the intersection of the conic and the line, and let ! be the tangent to the conic arc at P = (Px Py ). From the unit normal ~n0 = (n0x n0y ) of !0 and  we determine the normal ~n of !:

~n = (n0x cos  ; n0y sin  n0y cos  + n0x sin ) See FH95, Fud93] for the de nition of a signed angle between oriented lines. The sign of ! depends only on !0 and , and is not related to the sign of the derivative of c. To simplify the calculations, we do a rigid motion so that C = (0 0) and ~n = (0 1). That is, the tangent through P is parallel to the x-axis. Let r be the signed distance of the origin from !0, and let d be the signed distance of the origin from !. We will compute d from a necessary condition, and then apply the inverse motion to nd the actual position of P. We express Q as a function of d, as in Section 6.2.2. Then we compute the coordinates of P as a function of d, by intersecting ! with the line l that is through Q in the direction ~r = (rx ry ) = U ; (~v  ~u)Q ;ry (Px ; Qx) + rx (Py ; Qy )

= 0

Py = d Since P is on !0 we obtain:

Pxn0x + Py n0y = r

(6.14)

(6.15)

Substituting Px and Py from (6.14) into (6.15), we obtain for d a quadratic equation. The equation can have up to two real solutions, so we can have two distinct conic

67 arcs that form the speci ed angle with the given line. In Figure 6.8 (a),(b) we see two solutions for a conic arc that blends two intersecting segments and forms a 45 angle with a line !0, and in Figure 6.8 (c),(d) we see the two solutions for a conic arc that blends two parallel segments and forms a 45 angle with a line !0. 6.2.4 Angle with a Circle In this section, we extend the method of Section 6.2.2 to computing a conic arc that blends two segments and forms a speci ed angle with a given circle R which we consider (without loss of generality) to be centered at the origin and have radius d. Let P be an intersection point of the circle and the conic arc, such that the tangent !0 to the circle at P and the tangent ! to the conic at the same point form a signed angle . Also let ~n = (nx ny ) be the unit normal vector of !, and ~n0 = (n0x n0y ) be the unit normal vector of !0. In this setting P = (d n0x  d n0y ). As in Section 6.2.2 we derive an expression for Q involving nx, ny . Then we substitute nx and ny from:

~n = (n0x cos  ; n0y sin  n0y cos  + n0x sin ) Since P = (d n0x d n0y ), (6.10) becomes: ;ry (d n0x ; Qx ) + rx (d n0y ; Qy )

= 0

(6.16)

Substitution of Qx and Qy in (6.16) and elimination of the factors that do not yield a solution gives:

b0 + b1n0x + b2n0y + b3n0x2 + b4n0y 2 + b5n0x n0y = 0 nx + ny = 1 02

02

(6.17)

where bi are constants. We then proceed by solving (6.17) as in Section 6.2.2. In Figure 6.9 we see the four solutions for a conic arc that blends two segments and intersects a circle centered at the origin with radius d = 0:45 under an angle  = =7. Solution (a) is a hyperbolic arcs, while solutions (b)-(d) are elliptical arcs.

68 3

3

Λ0 Λ

2

Λ0

2

D

D 1

1

u

u C

0

-1

Λ

C

0

-1

v -2

-2

v

-3

-3 -1

0

1

2

4

3

5

-1

0

1

2

4

3

5

(b)

(a) 3

Λ0 3

Λ

2

D

2

v

1

Λ0

v

D

1

C

0

C

0

Λ -1

-1

-1

0

1

2

3

-1

0

1

2

3

(d)

(c)

Figure 6.8 (a),(b): Two solutions for a conic arc that blends two segments and forms a 45 angle with a line. (c),(d): Two solutions for a conic arc that blends two parallel segments and forms a 45 angle with a line.

v

2

2.5

C

v

2

C

1

1.5

R

u D

1

R

0

u

0.5

D Λ

Λ

0

-1

Λ

-0.5

-1

Λ

-2 -2

-1

0

1

2

-2

3

-1

0

1

2

3

(b)

(a)

v

2

v 2

C C

1.5

1

u

R

D

1

R

u

0.5

0

D Λ

0

-1

Λ

Λ

-0.5

Λ -2

-1 -1

0

1

(c)

2

3

-2

-1

0

1

2

3

(d)

Figure 6.9 Four solutions for a conic arc that blends two segments and forms a =7 angle with a circle.

69 6.2.5 Fairness Constraints When there is no additional constraint imposed on the blending arc, the extra degree of freedom can be used to satisfy a 'fairness' criterion. Some recent results on this problem are presented in Goo94] and in FF91] for the case of a conic arc in Bezier form. In particular, Goo94] and FF91] give a method that determines a w value that minimizes curvature extrema and maintains monotone curvature change along the arc. When the sum of the angles formed by each tangent and the segment CD is larger than 2 , than there is no conic arc with monotone curvature. For smaller angles, Goodman Goo94] derives a value of w that guarantees monotonicity and minimizes curvature extrema. Since the arc's end tangents are not parallel, we can select, for . example, P = c( 21 ) as the third point, where c is given by (6.5) using W = w ~v U  ~u Thus, the fairness constraint of Goo94] can be reduced to a constraint computation. 6.3 Handling Conic Arcs in the Analysis Phase In general, a conic arc can be determined from ve constraints, but we require that four of them make the construction a Hermite problem. That is, there must be two end points and two end tangents to the conic arc. Phase 2 of the solver has been extended to provide for the constructions described in Section 6.2. After the arc has been determined, geometric constraints involving the conic may be used to construct other points and lines. For example, we can constrain a line to go through a xed point and be tangent to the conic. Note however, that in our current implementation, constraints between two conic arcs (e.g. tangency between two conic arcs) are not permitted. An approach similar to that presented in section 6.2 can be used to handle such constraints. We have not analyzed the degree of the equations that would result. When the geometric element constructed at some step of Phase 2 is a conic arc, we may have to choose among up to four distinct solutions (see e.g., Figure 6.6). In

70 the case of a conic arc this task is best performed by combining information such as the type of the arc (hyperbola, parabola or ellipse), the topological order, and the type of blending, in the sketch initially drafted by the user, to get a unique solution. However, if another solution is needed, the interactive tool described in Section 7.1 can be used to select it. The combination of these requirements entails special rules for analyzing the constraint problem in Phase 1 of our constraint solving algorithm, and we now explain them. The nature of the core algorithm, which is based on the principle of merging three rigid bodies that pairwise share a geometric primitive, make it easy to incorporate a conic arc. There is a new type of geometric primitive for the conic arc and a new rule for merging it with the geometric elements constructed so far. That is, the arc is merged as a rigid body into a rigid con guration of geometric elements. The constraint graph initially has vertices corresponding to all geometric elements, including the conic arc itself. Phase 1 proceeds as in Chapter 3 except that conic arc nodes and the constraints on them are ignored. Whenever a cluster is formed that contains geometric elements with ve constraints to a conic arc c(t), the construction of c(t) is attempted. For Phase 1 of our solver this means simply adding the node corresponding to c(t) to the cluster, and considering in the subsequent processing all constraint edges incident to c(t). Adding the node for c(t) is restricted to correspond to a Hermite problem. We require that the user designates in the sketch input which points are to be end points and end tangents. Four of the ve constraints must then be the incidence and tangency conditions thereby implied. It is possible to avoid having to designate the end conditions explicitly, but this is not necessarily desirable. For an example, consider Figure 6.10 where the user designates tangency conditions at A, B , D and to the line HF . The solver would construct rst the line CB and the incident points E and F . The lines FH and EG can be constructed next, although the positions of H and G cannot yet be determined. Then, point D can be constructed, whereupon the conic arc between D and B can be

71 C

d1

α1

H d4

α2 G

E

d2

D F d3

B A

Figure 6.10 Arc extension implied. found using the computations explained before. Now the line CA can be constructed, as tangent to the conic from C , thereby determining G and H , by intersection, and A by tangency. This requires extending the conic arc to A as shown. However, if the arc obtained before is hyperbolic, it is entirely possible that the tangent to A lies on a dierent branch of the hyperbola. Since the conic arc c(t) from D to B had to be extended, testing for this undesirable situation is more complicated than verifying that the parameter value corresponding to A is in the interval 0 1].

72

7. MULTIPLE SOLUTIONS AND ROOT SELECTION This chapter discusses the problem of nding a solution of a system of geometric constraints { in an exponentially large search space { so that the solution is appropriate to the application and intuitive to the user. Section 7.1 presents the theoretical and human factors involved in the problem of root identi cation and describes the approach followed in our constraint solver. Section 7.2 discusses the problem of avoiding solutions that require complex coordinates. 7.1 The Root Identi cation Problem In general, a well-constrained geometric constraint problem has an exponential number of solutions. Which of these solutions is the intended one would depend on the application that created the constraint problem in the rst place. We discuss how one might select the \right" solution. We call this the root identication problem, because on a technical level it corresponds to selecting one among a number of dierent roots of a system of nonlinear algebraic equations. The following example illustrates the problem of root identi cation in computer aided design. Example 7.1 Assume that the constraint solver is presented with the well-constrained problem de ned by the sketch of Figure 7.1. The geometric constraint problem consists of three points and three lines, on which the following constraints have been imposed: Pt4 on Ln1, Pt4 on Ln2 , Pt6 on Ln2, Pt6 on Ln3, Pt5 on Ln3, Pt5 on Ln1, the distance between Pt4 and Pt5 is 80, the distance between Pt4 and Pt6 is 60, the angle between Ln1 and Ln2 is 40  the solution shown in Figure 7.2 is consistent with the above constraint scheme but it is hardly what the user intended.

73

Pt4 Ln1

Ln2 40.000

80.000

60.000

Pt5

Pt6 Ln3

Figure 7.1 A well-constrained problem with three lines, three points and nine pairwise constraints. Ln2 Pt5 Ln1 Ln3

80.000

Pt4

40.000

60.000

Pt6

Figure 7.2 A solution that is consistent but not intuitive.

74 The number of solutions of a well-constrained problem can be (and in general is) exponential on the number of geometric elements. This is illustrated by the following example. Example 7.2 Consider drawing n points, along with 2n ; 3 distance constraints between them, and assume that the distance constraints are such that we can place the points serially, each time determining the next point by two distances from two known points (see also Figure 7.3). In general, each new point can be placed in two dierent locations: Let Pt1 and Pt2 be known points from which the new point Pti is to be put at distance d1i and d2i , respectively. Draw two circles, one about Pt1 with radius d1i , the other about Pt2, with radius d2i . The intersection of the two circles are the possible locations of q. For n points, therefore, we could have up to 2n;2 distinct solutions. For the constraint problem of Figure 7.3 there are exactly 2n;2 = 32 distinct solutions. In instances where the dimension values are symmetric we may get less than 2n;2 = 32 solutions. Pt7 Pt6

70.000

60.000

Pt4

40.000

Pt2

70.000 60.000

30.000 40.000

50.000

Pt3 30.000

50.000

Pt1 50.000 Pt5

Figure 7.3 A well-constrained problem with distinct 2n;2 solutions.

75 In this section we discuss four approaches to root identi cation: impose global rules, adding more constraints to narrow down the number of possible solutions, moving geometric elements, and placement heuristics in conjunction with a dialogue with the constraint solver that identi es interactively the intended solution. 7.1.1 Specifying the Correct Solution by Imposing Global Rules The central idea in these methods is to prefer solutions with certain properties, usually related to the application. For example we may favor solutions that contain only closed, convex or non-self-intersecting objects. There are two major problems in using such methods : The general rule that we impose may not comply with the intentions of the user who may want to design a dimensioned sketch incrementally. This implies that in some phases of the construction the objects may be open or self-intersecting. Even for restricted cases these problems are computationally hard, in the sense that any algorithm to solve them would have worst-case time complexity at least exponential in the input size. For example, assume that the set of points is the set of vertices of a polygonal cross section. In that case, application-speci c information might require that the resulting sketch is a simple polygon that is, it should form a polygon that is non self-intersecting. In addition we may give a cyclic ordering specifying how to connect the points to obtain the polygon. This additional requirement makes the problem NP-hard. More speci cally the following holds. Theorem 7.1 Cap93] Given n points in the plane that are well constrained by 2n ; 3 rational point-point distances, and a cyclical ordering specifying how to connect the points to obtain a polygon. Then identifying a solution for which the resulting polygon is simple (non self-intersecting), is NP-complete.

76 7.1.2 Adding More Constraints This is a natural method that engineers commonly use in their drawings. The following example illustrates a typical case in which this method can be applied to specify a unique solution. Example 7.3 In Figure 7.4 we have three (nonoriented) parallel lines, if we specify only two distances (d1 and d2), we get two solutions (up to rigid motion), which are shown in Figure 7.4. Note that since the lines are not oriented we have two choices for the interpretation of each distance constraint (except the rst one), so we have in general 2n;2 solutions for n lines and n ; 1 distances. If we impose a third distance d3 , we specify a unique solution. l1

l2

l3

12

l1

l3

l2

12

6

l1

l2

l3

12

6

6 18

With two distances we get two possible solutions.

With three distances we get a unique solution.

Figure 7.4 Constraining three parallel lines with distances. Although this method seems appealing, it is computationally hard, even if we restrict the problem as in the generalization of Example 7.3: Given n parallel lines and n parallel distances among them, is there any solution that satises them?

77 Lemma 7.1 The above problem is NP{hard. Proof We will prove that the problem is NP-hard by reducing in polynomial time to it the following NP-complete problem, also known as the integer partition problem Kar72]: Given a set of n positive integers A, is there a partitioning of A into two disjoint sets A1 and A2, such that the sum of the integers in A1 equals the sum of the integers in A2? Let us assume that we have the following instance of the partition problem : A = fs1 s2 ::: sng, for that instance consider the instance of our problem that appears in Figure 7.5, s1 sn-1

s2

s3

...

sn-2

sn

l1

l2

l3

l n-1

ln

Figure 7.5 An instance of the n parallel lines problem. If the partition problem has a solution, then there is a partitioning of the integers in two sets, A1 and A2 such that the sum of the integers in the two sets is the same. Then we can place the lines l1 through ln, so that all the n distances are satis ed. We place l1 on the y-axis, then if s1 is in A1, we place l2, at distance s1 at the right of l1, else if s1 is in A2, we place l2, at distance s1 at the left of l1. Since the sum of the integers in the two sets is the same the last distance sn, will get us back to line l1 (zero on x-axis).

78 If our problem has a solution there is the obvious splitting: if we choose a left placement to satisfy a distance the corresponding integer is in A1, if we choose the right placement to satisfy a distance the corresponding integer is in A2. Then the sum of the integers in the two sets is the same. If the distance values are rationals or integers then the problem is in NP, since we can check in time polynomial time whether a guess is consistent. In this case the problem is NP{complete. For real distances it may not even be in NP (see e.g., CM, Koi94]).2 7.1.3 Dialogue with the Solver The considerations above seem to suggest that no automatic approach to root identi cation will succeed in delivering an ecient constraint solver that gets the userintended solution every time. In consequence, we feel that a promising alternative is to devise a few simple heuristics that succeed in many cases and are easy to understand. Beyond that, we rely on interaction with the user in those cases in which the heuristics fail to deliver an acceptable solution. All solvers known to us derive from the initial geometric sketch information that is used to select a speci c solution. This is reasonable, since one can expect that a sketch is at least topologically accurate, so that observing on which side of an oriented line in the sketch a speci c point is often a reliable indication of where it should be in the nal solution. However, when generic designs are archived and later edited, one should no longer expect such simple correspondences between the sketch and the ultimate solution, because as dimension values change, so may the side of a line on which a point is situated. In our system, we use very few but highly eective rules. Where the rules fail, we rely on user interaction to amend them as the situation might require. The rst three rules correspond to the initial cluster forming and the next three rules correspond to cluster merging. However, if we choose to form larger initial clusters sequentially, every sequential construction step, corresponds to a combination

79 of one or more of the rst three rules and one of the last three rules. In this case for every construction step there may be up to eight distinct solutions. Two Points: There is only one solution. Line and Point: There are two solutions: the point p may lie on the left or on the right of the line l. At that point we commit to a sign for the value of the distance constraint between p and l. Two Lines: There are two solutions to place two lines with respect to each other at a prescribed unsigned angle. At that point we commit to a sign for the value of the angle constraint between p and l. Three Points: Consider placing three points, p1, p2 and p3 , relative to each other (see also Figure 7.6). The points have been drawn in the initial sketch in some position, and therefore have an order that is determined as follows. Determine where p3 lies with respect to the line (p1 p2) oriented from p1 to p2. If p3 is on the line, then determine whether it lies between p1 and p2, preceding p1 or following p2. The solver will preserve this orientation. p2 3

p2

3

p3

4 5 p1

Initial configuration

4

5

p1 Correct solution

p3

p3

3

5

p2 4

p1

Alternative Solution

Figure 7.6 Root identi cation in placing three points. Two Lines and One Point: There is only one solution, since the pairwise angle and distance constraints are predetermined and signed. One Line and Two Points: Two solutions. We preserve the orientation of the vector p1 p2 with respect to the line orientation by preserving the sign of the inner product with the line tangent vector.

80

Figure 7.7 The two types of tangency between an arc and a segment. Tangent Arc: An arc tangent to two line segments will be centered such that the arc subtended preserves the type of tangency. The two types of tangency are illustrated in Figure 7.7. Moreover, the center will be placed such that the smaller of the two arcs possible is chosen, ties broken by placing the center on the same side of the two segments as in the input sketch. As speci c degeneracy heuristics, an arc of length 0 is suppressed. All rules except the tangency rule are mutually exclusive. They are therefore applicable without interference. The tangency rule could contradict the other rules, because dimensioned arcs and circles are determined by placing the center. In such cases, the tangency rule takes precedence. In our experiments with these rules, we found that most situations are solved as the user would expect. The rules are easy to implement, and are easy to understand for the user. As indicated no matter what the set of rules is, the user may get a solution that he did not expected. We have developed an interactive paradigm that allows the user to select the appropriate solution with minimum eort. The user can step through the construction sequence and be informed of which geometric elements have been placed at each construction step. This is done using the level selection arrow buttons (see Figure 7.8), each level corresponds to one construction step, at each level the geometric elements involved in the construction are highlighted in purple, so that the user can visualize the construction sequence. In Figure 7.8 we can see a well-constrained sketch that is constructed by the solver within eleven steps. This information becomes available to the user after regenerating any well-constrained sketch. A sketch that is not solved (regenerated) will blank the level display.

81

Figure 7.8 The initial sketch with two 70 angles.

82

Figure 7.9 After making the two angles 30 .

83 In addition, we provide the user with the capability to select an alternative solution for the particular construction step (level). After selecting a solution for a speci c level, with the solution selection arrow buttons the user regenerates and gets back the new solution. This process is well-suited to the intuition of the human, since each step corresponds to an elementary ruler and compass construction. As explained earlier the number of choices at each level, ranges from 1 to 8. This makes it easy for the user to browse all possible solutions at a particular level and choose the one that is preferred. When a construction corresponds to a step of sequentially forming a cluster, the part of the cluster constructed so far is highlighted in a dierent color. When a construction corresponds to a cluster merging, then the three clusters are also highlighted in dierent colors. In Figure 7.8 level eleven has only one solution, so there are no alternatives for the user to select, in Figure 7.9 level seven (out of eleven) has four alternative solutions among which the second has been selected. The solution display is available only when the sketch is solved (regenerated). This was enforced to accomplish consistency and compatibility with future versions of the constraint solving algorithm. The user is allowed to change the solution choice only at one level before each regenerate. All previous changes are disregarded except from the most recent one. After regenerating the user is free to change any other level. If the user would be allowed to change the choice in more than one levels, the solution derived could be totally unpredictable and unintuitive. For keeping track of this process we have provided the user with two horizontal buttons, with which he can review the sequence of sketches that his choices have caused. Finally we have introduced a button called complement (see Figure 7.8). Using this button, the user can change an arc to its complementary. Especially for the arc complement, instead of treating it as one more choice, we concluded that since it involves only the arc and no other geometric elements, the user could handle it easier

84 as a special case. Otherwise, we would have to double the number choices for some of the steps. Let us illustrate how this method works by considering the example depicted in Figures 7.8, 7.9, 7.10, 7.11 and 7.12. The user initially sketches and regenerates, the well-constrained sketch depicted in Figure 7.8, in this sketch the role of the arc is clearly to round the adjacent segments Sg9 and Sg7. When the user changes the two angles from 70 to 30 , the solver returns the solution shown in Figure 7.9, instead of the desired one in Figure 7.12. By using the interactive framework the user changes the solution choice at two related steps: in level 7 Ar10, Sg7 and Pt6 are highlighted and the user selects solution 4 instead of the default 2 (Figures 7.9 and 7.10), in level 4 Ar10, Sg9 and Pt8 are highlighted and the user selects solution 1 instead of the default 3 (Figure 7.11). Now he got the correct solution with the complementary arc, so by using the complement button he gets the desired solution (Figure 7.12) in three steps. Summarizing, the interactive root selection framework provided by the 2D sketcher of EREP, oers the following: The user is visually informed of the construction sequence. Based on the construction sequence the user can navigate the system to the correct solution. The user can review the navigation sequence, compare and change any step of it, if this is required using a history mechanism. The interactive framework prohibits the user of aecting unsolved sketches to accomplish consistency and compatibility. The user may complement an arc using a special button.

85

Figure 7.10 Selecting solution 4 (instead of 2) from level 7.

86

Figure 7.11 Selecting solution 1 (instead of 3) from level 4.

87

Figure 7.12 Complementing the arc Ar10.

88 7.2 Finding a Real Solution In this section we discuss the problem of nding a real solution of a system of geometric constraints. Although, we can check whether a given geometric constraint problem is solvable in a generic sense by a xed repertoire of construction steps in time quadratic to the number of geometric elements (Chapters 3, 4 and 5), nding a real solution for a solvable constraint problem will be shown to be NP{hard (at least as hard as an NP{complete problem) in a strong combinatorial sense. The following example illustrates the problem of nding a real solution of a system of geometric constraints. Example 7.4 Given the ve points A, B , C , D, E and the following set of geometric constraints:

A distance 3 from B C distance 4 from A D distance 3 from A E distance 2 from C

C distance 3 from B D distance 4 from B E distance 2 from D

nd a placement of the points that satis es the above geometric constraints. The placement of the points is with respect to each other, so the derived solution is invariant up to translation and rotation. One construction sequence that satis es the imposed constraints is the following: (i) position A and B with respect to each other (ii) construct C from A and B as the intersection of two circles (iii) construct D from A and B as the intersection of two circles (iv) construct E from C and D as the intersection of two circles Step (i) has only one solution, and for each of the steps (ii), (iii) and (iv) there are 2 solutions. Thus, we have eight distinct solution in the complex space. For placing A,

89

4.0

A 3.0

5.0

C

C

5.0

B 4.0

D

D

C

A 5.0

3.0

B

5.0 B

3.0

(b)

4.0

D

5.0 A

4.0

(a)

5.0

4.0

4.0

C

A 5.0

3.0

5.0

B 4.0

4.0

(c)

D

(d)

Figure 7.13 Four distinct solutions for placing the four points A, B , C and D with respect to each other.

90

B , C , and D there are four real solution depicted in Figure 7.13. Solutions (c) and (d) will not yield a real solution for E , since the circles of step (iv) do not intersect. Each of (a) and (b) contribute two real solutions for E , resulting in a total of four real solutions for this geometric constraint problem. In Section 7.2.1 we prove that the problem of nding a real solution for a geometric constraint problem that is solvable by a constructive constraint solver is NP{hard in a strong sense. Section 7.2.2 discusses the impact of this result and proposes an interactive method, appropriate for CAD applications, for interactively navigating our constructive constraint solver to a real solution. 7.2.1 NP{hardness We reduce the following version of the 3SAT to the real solution problem. One-in-three monotone 3SAT (1IN3-M3SAT) GJ79, Sch78]: Given a set U of variables, a collection C of clauses over U , such that each clause c 2 C has jcj = 3 and no negated literal, is there a truth assignment for U , such that each clause in C has exactly one true literal?

We will prove that for each instance of 1IN3-M3SAT, we can construct in polynomial time a solvable geometric constraint problem that has a real solution i the corresponding instance of 1IN3-M3SAT is satis able. Let fx1 x2 : : :xk g be the set of literals used in the clauses of C . Let ! be the line x = 1 and L be the line x = 2. For each literal xi, i = 1 : : : k, we construct a point pi on x{axis at distance 1 from !. The construction is depicted in Figure 7.14. Obviously for each point pi we can choose independently, one of two solutions, namely (0 0) or (2 0), which correspond to the variable xi being assigned a false or a true value respectively. We introduce the following constraints for each variable xi, i = 1 : : : k:

pi on x{axis

pi distance 1 from !

91

y Λ

L

(0, 2)

r

(0, 0)

(1, 0)

(2, 0)

x

(0, -2)

Figure 7.14 Constructing an instance of the real solution problem.

92 Let r be a circle of radius 2, centered on O(0 0) (see Figure 7.14). We then create the appropriate structure for representing each clause c = (xa xb xc) as follows. Let pa, pb , and pc be the corresponding points as de ned above, and let la, lb, and lc be the lines that are parallel to the y-axis and pass through pa, pb , and pc respectively. We de ne p0a, p0b , and p0c to have distance 2 from O(0 0) (i.e. lie on r), and to be on la, lb, and lc respectively. From each of the three pairs of points chosen from fp0a p0b  p0c g (order is not important), we construct a new point which lies at distance 1 from the rst point and at distance 2 from the second point. We denote these points by pab , pbc and pca respectively. The corresponding geometric elements and the imposed constraints for a clause c = (xa xb xc) are summarized below:

pi on x{axis pa distance 0 from la pb distance 0 from lb pc distance 0 from lc p0a distance 2 from O(0 0) p0b distance 2 from O(0 0) p0c distance 2 from O(0 0) pab distance 1 from p0a pbc distance 1 from p0b pca distance 1 from p0c

pi distance 1 from ! la angle 0 with the y-axis lb angle 0 with the y-axis lc angle 0 with the y-axis p0a distance 0 from la p0b distance 0 from lb p0c distance 0 from lc pab distance 2 from p0b pbc distance 2 from p0c pca distance 2 from p0a

Lemma 7.2 There is a truth assignment for U with exactly one true literal in each clause i the system of geometric constraints described above has a real solution. Proof Necessity: Assume that there is a truth assignment for U with exactly one true literal in each clause. Note that we do not have negated literals. We select the value (2, 0) for a point pm that corresponds to a true literal xm, and the value (0, 0) for a point

93

pn that corresponds to the false literal xn. Since there is a truth assignment with exactly one true literal in each clause c = (xa xb xc), without loss of generality we may assume that xb is true and that both xa and xc are false. Thus the point pb that corresponds to the true literal xb can be chosen to be on (2 0) and the other two points pa and pc that correspond to the false literals xa and xc can be chosen to be on (0 0). Then lb coincides with L and la and lc coincide with the y ; axis. Consequently, p0b has a unique solution: (2, 0), and for each of the points p0a and p0c there are two solutions, namely: (0 2) or (0 ;2). If we choose the value (0 2) for p0a and the value (0 ;2) for p0c we can easily verify that for each of pab, pbc , and pca there is a real solution. Thus the overall geometric constraint problem has a real solution. Suciency: Assume that there is no truth assignment for U with exactly one true literal in each clause. This means that for every truth assignment there is at least one clause that does not have exactly one true variable. Thus, no matter what solutions we choose for the points pi , the corresponding truth assignment for the xi's will yield one clause c = (xa xb xc) which does not have exactly one true literal. We distinguish two cases: (i) All three corresponding literals are false: Then la , lb, and lc are all identical to the y-axis. This means that at least two of p0a, p0b or p0c have been chosen to be identical either on (0 2) or on (0 ;2). Let us assume, without loss of generality, that p0a and p0b are chosen to be identical. Then there is no real solution for pab since pab is the intersection of two concentric circles with dierent radii. (ii) Two or more literals are true: This means that at least two of la , lb and lc will have to coincide with L, yielding the same coordinates for at least two of the points p0a , p0b and p0c . Let us assume, without loss of generality, that both p0a and p0b have been chosen to be on (2 0). Then there is no real solution for pab since pab is again the intersection of two concentric circles with dierent radii. 2 Lemma 7.3 The problem of nding a real solution for a system of geometric constraints solvable by a constructive method is NP{hard.

94 Proof Since our transformation of Lemma 7.2 is polynomial we conclude that the problem of whether there is a real solution satisfying the system of geometric constraints is NP{hard. We suspect that for real valued constraints the geometric real solution problem is not in NP. Instead, it is in DNP< (see e.g., BSS89, CM]), where the guess is polynomial to the size of the input but the checking procedure needs in nite precision to give an answer in polynomial time. Theorem 7.2 The problem of nding a real solution for a system of geometric constraints solvable by a constructive method is NP{hard in a strong combinatorial sense. Proof Let Rb be the bounded real solution problem where all distances and angles are restricted to be in f0 1 2g. The polynomial transformation of Lemma 7.2, proves that Rb is NP{hard. For an instance I = (V E ) of Rb, where V is the set of geometric elements and E is the set of the imposed constraints, we have,

LengthI ] = jE j + jV j + MaxI ] = 3

X dlog

d2E

2

value(d)e

Obviously for every instance I of Rb, MaxI ] 3LengthI ]. Thus Rb , which is a subproblem of the real solution problem R, is not a number problem GJ79], and it is still NP{hard. This concludes our proof of the strong NP{hardness of the geometric real solution problem. 2 Corollary 7.1 The problem of nding a real solution for a system of geometric constraints is also NP{hard in the strong sense. Proof Immediate from Theorem 7.2. 2

95 7.2.2 Discussion We have proved that the problem of nding a real solution for a system of geometric constraints that is solvable by a constructive method is NP{hard in a strong combinatorial sense. From the nature of the proof we conclude that several specializations of this problem are also hard in NP. In particular, all subproblems derived by imposing any combination of the following restrictions: The set of geometric elements consists only of lines and points. The set of geometric constraints consists only of distances and angles. The domain of the value of the geometric constraints is f0 1 2g. The geometric problem is well-constrained. Furthermore, if we restrict the geometric elements to be points only and the geometric constraints to be distances only we can easily prove that the problem remains NP-hard. Corollary 7.1 implies that a broad class of more general problems are also NP{ hard in the strong sense. We mention the problem of nding a real solution for a system of equations, with real, integer or rational coecients, the problem remains NP{hard in the strong sense even if all equations are quadratic. We will now look into how we can interactively search for a real solution of a wellconstrained geometric problem which is known to be solvable by the constructive method described in Chapter 3. We will adapt the interactive paradigm of Section 7.1.3: The solver will stop at the rst construction step where a nonreal solution is encountered, i.e. cluster merging is not possible because the relative placement of the three pairwise shared geometric elements has no real solution. At that point, there are three clusters (rigid bodies), that have been created independently.

96 The control then returns to the user, who may use the tool to go backwards and again forward in the construction sequence, browse the construction of each of the three clusters, inspect the corresponding root choices and modify those that will hopefully drive the solver to the expected real solution. When the geometric problem is underconstrained, we have argued that additional constraints should be added to make the problem well-constrained and solvable (Section 4.2). It should be possible to choose these additional constraints such that a real solution is obtained. This possibility should be investigated further.

97

8. CONCLUSIONS AND FUTURE WORK A method for solving a system of geometric constraints using a nite repertoire of construction steps has been described. The correctness of the approach has been formally proved and ecient algorithms to realize it have been presented. The basic method has been extended to handle overconstrained and underconstrained problems, which consistute a necessity in computer aided design. Support for conic arcs for blending has also been provided. Finally, a method has been presented, based on a dialogue with the solver and a set of placement heuristics, for interactively navigating the solver to the intended solution. Although, 3D constraint solving is not common in featured-based design, it may be used to avoid problems such as the \persistent id problem" CCH94]. The basic cluster merging in 3D corresponds to reducing an octahedral structure for which the constructions are presented in HV94]. Despite considerable eort in the mathematical community a necessary and sucient condition for structural well-constrainedness is not yet known Owe95]. The problem of solving systems of geometric constraints in 3D is also central to stereochemistry for nding the relative placement of molecules CH88]. In manufacturing applications, one is interested in functional relationships between dimension variables, since such relationships express design intent very exibly. Some parametric relationships can be implemented easily by structuring the sketch representation appropriately Fud93]. Moreover, simple functional relationships are the content of certain geometric theorems, such as the theorems of proportionality, and many other classical results. Such theorems can be added to the constraint solver in a manner analogous to the extensions we have discussed in Chapter 5. But in general, functional relationships between dimension variables necessitate additional

98 mathematical techniques. Geometric theorem proving has developed many general techniques that are applicable, but restrictions are still needed to achieve higher solver speeds. Finally, a theoretically challenging research problem is the speci cation of the minimal extensions required to achieve solvability of all ruler-and-compass constructible geometric constraint problems.

BIBLIOGRAPHY

99

BIBLIOGRAPHY AAJM93] S. Ait-Aoudia, R. Jegou, and D. Michelucci. Reduction of constraint systems. In Proc. Compugraphics, pages 83{92, Alvor, Portugal, 1993. AC90] D. C. Anderson and T. C. Chang. Geometric reasoning in feature-based design and process planning. Comput. & Graphics, 14(2):225{235, 1990. AG93] E. L. Allgower and K. Georg. Continuation and path following. Acta Numerica, pages 1{64, 1993. Ald88] B. Aldefeld. Variation of geometries based on a geometric-reasoning method. Computer Aided Design, 20(3):117{126, April 1988. Bar87] L. A. Barford. A Graphical, Language-Based Editor for Generic Solid Models Represented by Constraints. PhD thesis, Department of Computer Science, Cornell University, March 1987. Also available as TR 87-813. BFH94] P. L. Beaty, P. A. Fitzhorn, and G. J. Herron. Extensions in variational geometry that generate and modify object edges composed of rational Bezier curves. Computer Aided Design, 26(2):98{107, 1994. BFH+95] W. Bouma, I. Fudos, C. M. Homann, J. Cai, and R. Paige. A Geometric Constraint Solver. Computer Aided Design, 27(6):487{501, June 1995. Bor81] A. H. Borning. The programming language aspects of ThingLab, a constraint oriented simulation laboratory. ACM TOPLAS, 3(4):353{387, 1981. Bro91] D. H. Brown Associates, Inc. Conceptual Design: Tradeos in Performance and Flexibility. Notes on the design of Pro/ENGINEER, 1991. Bru86] B. Bruderlin. Constructing Three-Dimensional Geometric Objects Dened by Constraints. In Workshop on Interactive 3D Graphics, pages 111{129. ACM, October 23-24 1986. Bru93] B. Bruderlin. Using geometric rewrite rules for solving geometric problems symbolically. Theoretical Computer Science, 116:291{303, 1993.

100 BSS89] L. Blum, M. Schub, and S. Smale. On a theory of computation and complexity over the real numbers: NP{completeness, recursive functions and universal machines. Bulletin (New Series) of the American Mathematical Society, 21:1{46, 1989. Buc85] B. Buchberger. Grobner Bases: An Algorithmic Method in Polynomial Ideal Theory. In N. K. Bose, editor, Multidimensional Systems Theory, pages 184{232. D. Reidel Publishing Company, 1985. Cap93] V. S. Capoyleas. Personal Communication. New York University, May 1993. CCH94] V. Capoyleas, X. Chen, and C. M. Homann. Generic naming in generative, constraint-based design. Technical Report CSD-94-011, Department of Computer Sciences, Purdue University, West Lafayette, Indiana, 1994. CFV88] U. Cugini, F. Folini, and I. Vicini. A procedural system for the de nition and storage of technical drawings in parametric form. In D. A. Duce and P. Jancene, editors, Eurographics '88, pages 183{196. Eurographics Association, Elsevier Science Publishers B.V. (North Holland), 1988. CH88] G. M. Crippen and T. F. Havel. Distance geometry and molecular conformation. Taunton, Somerset, England: Research Studies Press Wiley, New York, 1988. Chy85] W. Chyz. Constraint management for CSG. Master's thesis, Massachusetts Institute of Technology, June 1985. CM] F. Cucker and M. Matamala. On digital nondeterminism. preprint. CS90] J. C. H. Chung and M. D. Schussel. Technical evaluation of variational and parametric design. In Computers in Engineering, pages 289{298. Proc. of the 1990 ASME Int. Comp. in Eng. Conf. and Expo., 1990. Far93] G. E. Farin. Curves and surfaces for computer aided geometric design: a practical guide. Academic Press, 1993. FBMB90] B. N. Freeman-Benson, J. Maloney, and A. Borning. An Incremental Constraint Solver. Communicationa of the ACM, 33(1):54{63, 1990. FF91] W. H. Frey and D. A. Field. Designing Bezier conic segments with monotone curvature. Technical Report GMR-7845, General Motors Research Laboratories, 1991. FH95] I. Fudos and C. M. Homann. Correctness Proof of a Geometric Constraint solver. International Journal of Computational Geometry & Applications, to appear 1995.

101 Fit81] W. Fitzerland. Using Axial Dimensions to Determine the Proportions of Line Drawings in Computer Graphics. Computer Aided Design, 13(6), November 1981. FP79] I. D. Faux and M. J. Pratt. Computational Geometry for Design and Manufacture. Ellis Horwood, Chichester, 1979. Fud93] I. Fudos. Editable Representations for 2D Geometric Design. Master's thesis, Department of Computer Sciences, Purdue University, December 1993. Fuq87] T. W. Fuqua. Constraint Kernels: Constraints and Dependencies in a Geometric Modeling System. Master's thesis, The University of Utah, August 1987. GJ79] M. R. Garey and D. S. Johnson. Computers and Intractability. W. H. Freeman and Co., 1979. GN94] G. Geise and Th. Nestler. Bezier representation of conics of contact in the projective plane. Computer Aided Geometric Design, 11:233{245, 1994. Goo94] T. N. T. Goodman. Curvature of Rational Quadratic Splines. In P. J. Laurent, A. Le Mehaute, and L. L. Schumaker, editors, Curves and Surfaces in Geometric Design, pages 201{208. A. K. Peters, Wellesley, Massachusetts, 1994. Gos83] J. Gosling. Algebraic Constraints. Technical Report CMU-CS-83-132, CMU, 1983. GZS88] D. C. Gossard, R. P. Zuante, and H. Sakurai. Representing dimensions, tolerances, and features in MCAE systems. IEEE Comput. Graph. & and Applic., 8(2):51{59, 1988. HB94] C. Hsu and B. Bruderlin. Moving into higher dimensions of geometric constraint solving. Technical Report UUCS-94-027, Dept of Computer Science, University of Utah, 1994. Hil56] D. Hilbert. Grundlagen der Geometrie. B. G. Teubner, Stuttgart, 1956. HJ93] C. M. Homann and R. Juan. EREP : An Editable High-Level Representation for Geometric Design and Analysis. In P. Wilson, M. Wozny, and M. Pratt, editors, Geometric and Product Modeling. North Holland, 1993. Hof93] C. M. Homann. On the semantics of generative geometry representations. In Proc. 19th ASME Design Automation Conference, pages 411{ 420, 1993. Vol. 2.

102 HP94] C. M. Homann and J. Peters. Geometric Constraints for CAGD. In Proc. of the Third International Conference on Mathematical Methods for CAGD, Ulvic, Norway, 1994. HT73] J. E. Hopcroft and R. E. Tarjan. Dividing a graph into triconnected components. SIAM J. Comput., 2(3):135{158, 1973. HV94] C. M. Homann and P. J. Vermeer. Geometric constraint solving in R2 and R3. In D. Z. Du and F. Hwang, editors, Computing in Euclidean Geometry. World Scienti c Publishing, 1994. Ima85] H. Imai. On combinatorial structures of line drawings of polyhedra. Discrete and applied Mathematics, 10:79, 1985. IR78] A. Itai and M. Rodeh. Finding a Minimum Circuit in a Graph. SIAM J. Comput., 7(4):413{423, 1978. JAS95] R. Juan-Arinyo and A. Soto. A rule-constructive geometric constraint solver. Technical Report LSI-95-25-R, Universitat Polit#ecnica de Catalunya, 1995. Kar72] R. M. Karp. Reducibility among combinatorial problems. In R. E. Miller and J. W. Thatcher, editors, Complexity of Computer Computations, pages 85{103. Plenum Press, New York, 1972. Koi94] P. Koiran. Computing over the reals with addition and order. Theoretical Computer Science, 133:35{47, 1994. Kon92] K. Kondo. Algebraic method for manipulation of dimensional relationships in geometric models. Computer Aided Design, 24(3):141{147, March 1992. Kra92] G. A. Kramer. Solving geometric constraints systems: a case study in kinematics. MIT Press, Cambridge, Massachusetts, 1992. Lee87] E. T. Y. Lee. The rational bezier representation for conics. In G. E. Farin, editor, Geometric Modeling: Algorithms and New Trends, pages 3{19. SIAM, 1987. LG82] R. Light and D. Gossard. Modi cation of geometric models through variational geometry. Computer Aided Design, 14(4):209{214, July 1982. Li88] J. Li. Using algebraic constraints in interactive text and graphics editing. In D. A. Duce and P. Jancene, editors, Eurographics '88, pages 197{ 205. Eurographics Association, Elsevier Science Publishers B.V. (North Holland), 1988.

103 Lim79] R. A. Liming. Mathematics for computer graphics. Aero Publishers, Fallbrook, California, 1979. LM95] H. Lamure and D. Michelucci. Solving geometric constraints by homotopy. In Proc. Third Symposium on solid Modeling and Applications, pages 263{ 269, Salt Lake City, 1995. ACM. Ltd94] D-Cubed Ltd. The Dimensional Constraint Manager. 68 Castle Street, Cambridge, England, June 1994. Version 2.7. Mac37] S. Mac Lane. A structural characterization of planar combinatorial graphs. Duke Math. J., 3:460{472, 1937. Mal94] P. J. Malraison. Constraining a Quadratic Rational Bezier to be an Elliptical Arc. Presented in Third SIAM Conf. on Geom. Design., 1994. Mon83] B. Monien. The Complexity of Determining a Shortest Cycle of Even Length. Computing, 31:355{369, 1983. Mor87] A. Morgan. Solving polynomial systems using continuation for engineering and scientic problems. Prentice-Hall, Inc., 1987. Nel85] G. Nelson. Juno, a costraint-based graphics system. In SIGGRAPH, pages 235{243, San Francisco, July 22-26 1985. ACM. Owe91] J. C. Owen. Algebraic Solution for Geometry from Dimensional Constraints. In ACM Symp. Found. of Solid Modeling, pages 397{407, Austin, Texas, 1991. ACM. Owe95] J. C. Owen. Constraints on Simple Geometry in Two and Three Dimensions. International Journal of Computational Geometry and Applications, to appear 1995. Pie87a] L. Piegl. Interactive Data Interpolation by Rational Bezier Curves. IEEE Computer Graphics and Applications, pages 45{58, April 1987. Pie87b] L. Piegl. On the use of in nite control points in CAGD. Computer Aided Geometric Design, 4:155{166, 1987. Pro] Pro/ENGINEER. Modeling Users Guide: 2D Sketcher. Parametric Technology Corporation, Boston, Massachusetts. Release 8.0. PT87] L. Piegl and W. Tiller. Curve and Surface Constructions Using Rational B-splines. Computer Aided Design, 19(9):485{498, 1987. RBN88] J. R. Rossignac, P. Borrel, and L. R. Nackman. Interactive Design with Sequences of Parameterized Transformations. Technical Report RC 13740 (#61565), IBM Research Division, T. J. Watson Research Center, Yorktown Heights, New York, 1988.

104 Req77] A. Requicha. Dimensionining and tolerancing. Technical Report PADLTM-19, Production Automation Project, University of Rochester, May 1977. Rol89] D. Roller. Design by Features: An Approach to High Level Shape Manipulations. Computers in Industry, 12:185{191, 1989. Ros86] J. R. Rossignac. Constraints in constructive solid geometry. In Workshop on Interactive 3D Graphics, pages 93{110, Chapel Hill, North Carolina, October 23-24 1986. ACM. SAK90] H. Suzuki, H. Ando, and F. Kimura. Variation of geometries based on a geometric-reasoning method. Comput. & Graphics, 14(2):211{224, 1990. Sch78] T. J. Schaefer. The complexity of satis ability problems. In Proc. 10th Ann. ACM Symp. on Theory of Computing, pages 216{226, New York, 1978. ACM. SG86] D. Serrano and D. Gossard. Combining mathematical models and geometric models in CAE systems. In Proc. ASME Computers in Eng. Conf., pages 277{284, Chicago, July 1986. ASME. SKW90] M. S. Shephard, E. V. Korngold, and R. Wentorf. Design systems supposrting engineering idealizations. In M. J. Wozny, J. U. Turner, and K. Preiss, editors, Geometric Modeling for Product Engineering, pages 279{300. Elsevier Science Publishers B.V. (North Holland), 1990. Soh91] W. Sohrt. Interaction with Constraints in three-dimensional Modeling. Master's thesis, Dept of Computer Science, The University of Utah, March 1991. SS80] G. L. Steele and G. L. Sussman. CONSTRAINTS { A Language for Expressing Almost-Hierarchical Descriptions. Articial Intelligence, pages 1{39, January 1980. Sug85] K. Sugihara. Detection of Structural Inconsistencies in Systems of Equations with Degrees of Freedom and its Applications. Discrete Applied Mathematics, 10:297{312, 1985. Sun88] G. Sunde. Speci cation of shape by dimensions and other geometric constraints. In M. J. Wozny, H. W. McLaughlin, and J. L. Encarnacao, editors, Geometric modeling for CAD applications, pages 199{213. North Holland, IFIP, 1988. Sut63a] I. Sutherland. Sketchpad, a man-machine graphical communication system. In Proc. of the Spring Joint Comp. Conference, pages 329{345. IFIPS, 1963.

105 Sut63b] I. Sutherland. Sketchpad, a man-machine graphical communication system. PhD thesis, Massachusetts Institute of Technology, January 1963. Tar72] R. E. Tarjan. Depth- rst search and linear graph algorithms. SIAM J. Comput., 1:146{159, 1972. Til83] W. Tiller. Rational B-splines for Curve and Surface Representation. IEEE Computer Graphics & Applications, 3:61{69, 1983. Tod89] P. Todd. A k-tree generalization that characterizes consistency of dimensioned engineering drawings. SIAM J. Disc. Math., 2(2):255{261, 1989. VSR92] A. Verroust, F. Schonek, and D. Roller. Rule-oriented method for parameterized computer-aided design. Computer Aided Design, 24(3):531{540, October 1992. Wil91] M. R. Wilk. Equate: An Object-Oriented Constraint Solver. In OOPSLA, pages 286{298. ACM, 1991. Woo88] J. R. Woodwark. Some speculations on feature recognition. Computer Aided Design, 20(4), May 1988. Woo90] R. F. Woodbury. Variations in Solids: A Declarative Treatment. Comput. & Graphics, 14(2):173{188, 1990. Wu86] W. T. Wu. Basic Principles of Mechanical Theorem Proving in Elementary Geometries. Journal of Automated Reasoning, 2:221{252, 1986. YK90] Y. Yamaguchi and F. Kimura. A constraint modeling system for variational geometry. In M. J. Wozny, J. U. Turner, and K. Preiss, editors, Geometric Modeling for Product Engineering, pages 221{233. Elsevier Science Publishers B.V. (North Holland), 1990.

APPENDIX

106

APPENDIX The computation of Section 6.2.2 has the following details. The coecients ak of Equation (6.11) are

a0 = d(vy uy Dx2 ; vy DxDy ux + vxDy2ux ; Cy2vxux + vxCxCy uy +vy CxuxCy ; vy Cx2uy ; vxDxDy uy ) a1 = 2vy CxDxDy ux + vxCxDy uxCy ; vy CxuxCy Dx + 2vy Cx2uy Dx ;2vy d2 uy Dx ; vx Dx Dy ux Cy ; 2vy Cx uy Dx2 + vy d2 Dy ux ; vy Cx2uxDy ;2vx Cx Dx Cy uy + 2vy Cx d2 uy ; vx d2 Cy uy ; Cxvx Dy2 ux ; vy ux Cy d2 +Cy2vxDxux + vxd2Dy uy + Dx2 vxCy uy + vxCxDxDy uy a2 =

;2Dy2 vxux Cy

+ 2vxd2uxCy + vy Cxuy Cy Dx ; 2vy CxuxCy Dy ;2vx d2 Dy ux + vxd2 Dx uy + vy CxDy2 ux + vy d2 ux Dx ; vy Cx uy Dy Dx ;Cy2vx Dx uy + 2Cy2 vx Dy ux + 2vxDx Dy Cy uy ; vy Cy Dx2 uy ; vxCx d2 uy +vy uxCy DxDy ; vxCxDy Cy uy + vy Cx2uy Dy ; vy Cxuxd2

a3 = d(vxCxCy uy + vy uy Dx2 + vy uxCy Dx ; vy Cx2uy ; CxvxDy uy ; vy DxDy ux) a4 =

;d(;vxDy2 ux ; Cxvx Dy uy ; vy Cx uxCy

+ vxDx Dy uy + vy uxCy Dx + Cy2vxux)

a5 = d(;vy Cxuy Dy + vxDx Dy ux ; vxDx2 uy ; vxCxuxCy + Cy2vxuy ; vy Dy2 ux ;vxDx uxCy ; vy Cx ux Dx + vy Cx2ux + vxCx Dy ux + vy Cy uy Dx + vxCx Dx uy ;vxDy Cy uy + vy ux Cy Dy + vy uy Dy Dx ; vy Cx Cy uy )

107 Note that the ai are constants. The coecients ck and ek in the system (6.13) are

c4 = a25 + a23 ; 2a3a4 + a24 c3 = 2a5a1 ; 2a2a3 + 2a2a4 c2 =

;a25 ; 2a23 ; 2a0a3 + 2a3a4 + 2a0 a4 + a22 + a21

c1 =

;2a5 a1 + 2a2 a3 + 2a2 a0

c0 = a23 + 2a0a3 + a20 ; a21 e1 = a25a1 ; a5a2a3 ; a1a23 + a3a1a4 ; a0a5a2 ; a0a1a3 + a0a1a4 +(a35 + a5a23 ; a5a3a4 + a5a0a3 ; a5a0a4 ; a5a22 ; a2a1a3 + a2a1a4)ny +(;a25a1 + 2a5a2a3 ; 2a5a2a4 + a1a23 ; 2a3a1a4 + a1a24)n2y +(;a35 ; a5a23 + 2a5a3a4 ; a5a24)n3y

e0 = a25a3 + a25a0 ; a1a5a2 ; a21a3 + a21a4

VITA

108

VITA Ioannis Fudos was born on February 3, 1968 in Ioannina, Greece. He received a Diploma in Computer Engineering and Informatics from the University of Patras, Greece in 1990 and his M.Sc. in Computer Science in 1993 from Purdue University, West Lafayette, Indiana. His research work includes high-level representations for geometric design, geometry compilers, solid modeling, constraint solving and computer aided design.

Suggest Documents