2D Geometric Constraint Solving : an Overview Samy Ait-Aoudia, Mehdi Bahriz, Lyes Salhi ESI - Ecole nationale Supérieure en Informatique, BP 68M - Oued Smar 16270 Algiers, Algeria
[email protected]
Abstract - Geometric constraint solving has applications in many different fields, such as Computer-Aided Design, molecular modelling, tolerance analysis, and geometric theorem proving. Geometric modelling by constraints enables users to describe shapes by relationships called constraints between geometric elements. The aim is to derive automatically these geometric elements and provide thus effort and time saving. Moreover, users can easily modify existing designs. Many resolution methods have been proposed for solving systems of geometric constraints. We classify these methods in three broad categories : algebraic, rule-oriented and graph-constructive solvers. Keywords - Constraints solving, geometric constraints, algebraic, rule-oriented and graph-constructive solvers
d1
B
A α
d3 β D C
d2
Figure 1. A simple constrained design.
I. INTRODUCTION Geometric constraint solving has applications in many different fields, such as Computer-Aided Design, molecular modelling, tolerance analysis, and geometric theorem proving. Geometric modelling by constraints enables users to describe shapes by specifying a rough sketch and adding to it geometric constraints i.e. a set of required relations between geometric elements (see [6], [27], [28]). The constraint solver must derive automatically the correct shape needed. Typically, in 2D, geometric modelling by constraints specifies geometrical objects such as points, lines, circles, conics by a set of constraints : distances between points, points and lines, parallel lines, angles between lines, incidence relations between points and lines, points and circles, tangency relations between lines and circles or between circles, and so on. Intuitively a dimensioned sketch is considered to be well-constrained if it has a finite number of solutions for non-degenerate configurations. Figure 1 shows a 2D well-constrained problem with three distance constraints between pairs of points and two angle constrains. Similarly a dimensioned sketch is considered to be underconstrained if it has an infinite number of solutions for non-degenerate configurations. Finally a dimensioned sketch is considered to be over-constrained if it has no solutions for non-degenerate configurations. Examples of 2D under-constrained and over-constrained sketches are given in figures 2.a and 2.b respectively.
(a)
(b)
Figure 2. (a) an under-constrained sketch, (b) an over-constrained sketch
Many resolution methods have been proposed for solving systems of geometric constraints. They can be classified in many ways. We classify these methods in three broad categories : algebraic, rule-constructive and graph-constructive solvers. This paper is organized as follows. The algebraic approach for constraints solving is explained in section II. We present in section III, the rule-oriented methods to handle constraint problems. The graph-based methodology is given in section IV. Section V gives conclusions. II. ALGEBRAIC APPROACH A. Numerical methods In a numerical constraint solver, the geometric constraints are first translated into a system of algebraic equations (linear or not). This system is then solved by applying a numerical method. For each constraint correspond an algebraic equation. As an example of this correspondence, the equation corresponding to "internal"
and "external" tangency between two circles (see figure 3), one centred at A with radius r1, the second centred at B with radius r2 is the following : (xB - xA)2 + (yB - yA)2 - (r1 ± r2)2= 0.
C2
C2 C1
C1 r2
r1 A
r2
r1
B
B
A
B. Symbolic methods
Figure 3. Tangency between two circles.
Example :
A constrained scheme is shown in figure 4. It consists of three points and three distance constraints. The point P1 lies at the origin and P3 on the positive x-axis. The corresponding set of equations is given below : eq1 : x1 = 0. eq2 : y1 = 0. eq3 : y3 = 0. eq4 : y2 – y1 – d1 = 0. 2
2
However, there is a well-known problem. If NewtonRaphson’s method often works well, sometimes it does not converge or it converges to an unwanted solution. In this last case, the user changes his initial guess until Newton-Raphson’s method works if it does. An alternative method to Newton-Raphson for geometric constraint solving is homotopy or continuation [3]. Lamure et al. [34] have tested several configurations using homotopy with success and where NewtonRaphson's method fails. Nonetheless, homotopy, is slower than Newton's method. Homotopy was also used for solving 3D constraints by Durand et al. [14]. Foufou et al. [16] recently used efficient numerical methods to solve systems of constraints.
2
eq5 : (x3 – x2) + (y3 – y2) – d3 = 0. eq6 : x3 – x1 – d2 = 0.
As in the numerical solvers, the constraints are again formulated as a system of algebraic equations. However, instead of applying numerical techniques to determine a solution, general symbolic computations are undertaken to find the solution to the system of equations. Methods such as Gröbner basis or Wu-Ritt [32] techniques can be applied to find symbolic expressions for the solutions. Many systems have used a symbolic resolution of the system of equations. We can non exhaustively mention works done by Ericson et al. [15], Kondo [31], Buchanan et al. [12], Chou et al. [13] and Gao et al [18]. III.
Sutherland [55], Hillyard and Braid [24], Borning [7] Borning and Duisberg [8] and Gosling [22] have used the relaxation method to solve the constrained problem. Relaxation is a quite slow method and sometimes convergence can't be achieved. Barford [5] used a projective method. Many systems have used the Newton-Raphson’s iteration to solve the set of geometric constraints. This "popular" numerical method was used, among many others, by Lin et al. [41], Light et al. [40], Lee et al. [37], Nelson [45], Prusinkiewicz et al. [49], Rocheleau et al. [50], Gossard et al. [23], Serrano [51], Perez et al [47], Anderl et al. [4]. This method needs an initial guess, typically given by the sketch of the desired geometric scheme.
y
RULE-CONSTRUCTIVE APPROACH
A. Problem formulation Rule-based solvers rely on the predicates formulation. The constraints are expressed as facts and an inference engine is used to derive the solution by exhaustively applying rules. Some examples of expressing constraints as facts are given below : coord(P1, [X, Y]) coordinates of point P1 are X and Y. dist(P1, P2, d) d is the distance between points P1 et P2. slope(P1, P2, a) a is the slope of the line P1P2. angle(P1, P2, P2, b) b is the angle P1P2P3.
P2(x2,y2) d3
slope(P1, P2) = slope(P3, P4) line P1P2 is parallel to line P3P4.
d1 x P1(x1,y1)
P3(x3,y3) d2 Figure 4. A constraint problem.
A typical example of rule used by the inference engine is given hereafter : [coord(P1, [X1, Y1]), coord (P2, [X2, Y2]), dist(P1, P3, R1), dist(P2, P3, R2)] → coord(P3, intersection(circle(c(P1), R1), circle(c(P2), R2)))]
E
It states that if points P1 and P2 are known and the distance values R1 and R2 between points (P1,P3) and (P2,P3) respectively are given then we can compute the coordinates of the point P3 by intersecting two circles, one centered at P1 with radius d13 the other centered at P2 with radius d23. B. Rule-Oriented solvers We will review now some works done in the ruleoriented field. The majority of rule-constructive solvers have been implemented at the end of the eighties and early nineties. Brüderlin ([10], [11]), has developed a system taking into account 2D and 3D constraints. This system was implemented using Prolog. The class of 2D configurations solved was not very large and the 3D case solves very simple schemes. Sunde in [53] uses a rule-constructive method. He introduces the notion of CA (Constraint Angle) and CD (Constraint Distance) sets. The method tries to merge all the initial CA and CD sets in a single CD set. If the merging operation succeeds the figure solution is constructed. Aldefeld in [2] 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 was presented by Suzuki et al. [54], where handling of over-constrained and underconstrained problems is given special consideration. Verroust et al [56] have used the same theoretical foundations as Sunde [53]. They added some rules to extent the class of problems solved. Rule-constructive approach provide a qualitative study of geometric constraints. 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. IV.
GRAPH-BASED APPROACH
A. Graph representation In graph-based methods, an undirected graph G=(V,E) where |V|=n and |E|=m represents the constraint problem. The geometric elements are represented by the graph nodes and the constraints are the graph edges. The class of configurations solved by these methods is typically the ruler and compass constructive problems. In Computer-Aided Design, the graph-based approach has become dominant. Example: A dimensioning scheme defining a constraint problem is shown in figure 5. It involves six points and six lines. The constraints are six point-point distances, three lineline angles, twelve point-line implicit distances that are zero. The corresponding constraint graph is shown in figure 6. The edges are labeled with the values of the distance and angle dimensions. The unlabeled edges correspond to the implicit point-line distances.
d5
d4 γ
F
D d3
d6 β
α A
C d1
d2 B
Figure 5. A constraint problem.
EF γ DE
E F
d5
d4
d6 A
AF α
D d3 C
d1 B
AB
CD
d2
β BC
Figure 6. The constraint graph.
B. Graph structure analysis Graph-constructive solvers are stemming from graph theory. They are based on an analysis of the structure of the constraint graph. The graph constructive approach provides means for developing sound and efficient algorithms. Let us now give some definitions concerning the structural properties of the constraint graph when the degree of freedom of each geometric object is two and each constraint 'fixes' one degree of freedom. Definition 1 A constraint graph G=(V,E) where |V|=n and |E|=m is structurally well-constrained if and only if m=2*n-3 and m’≤ 2*n’-3 for any induced sub-graph G’=(V’,E’) where |V’|=n’ and |E’|=m’ (see [33]). Definition 2 A constraint graph G=(V,E) contains a structurally over-constrained part if there is an induced sub-graph G’=(V’,E’) having more than 2*n’-3 edges. Definition 3 A constraint graph G=(V,E) is structurally underconstrained if it is not over-constrained and the number of edges is less than 2*n-3.
We must mention that the Laman's theorem [33] is proved only for point to point distance constraints and that the extension of his definitions may imply incorrect cases. A typical example of such cases is given by a triangle constrained with three angle constrains. In figure 7.left, a triangle is constrained with three angle constraints (with α+β+γ=180°). The triangle is geometrically under-constrained but the constraint graph related to (figure 7.right) is well constrained.
15 14
12 13
4
11 1
9
16
10
7
3
8 6
2 AB A
A
α
B
β
5
α β
AC
γ
B
γ
BC
Figure 9. Constrained Design decomposition.
C C
Figure 7. An under-constrained problem (left), and its associated constraint graph (right).
The graph constructive approach uses only the structure of the constraint graph and forgets numerical information. A constraint graph can be structurally wellconstrained but numerically under-constrained. The dimensioned scheme shown in figure 8 (left) is numerically under-constrained (the edges are labeled with distance arguments). Its corresponding constraint graph shown in figure 8 (right) is structurally well-constrained. Nonetheless, with the graph constructive approach, such cases will be detected during the construction phase.
A 1 D
1 0 1
B
A
Figure 10 shows an example of a placement step. The point p3 is to be constructed from two known points p1 and p2. dij is the value of the constraint distance between points pi an pj. To obtain point p3, we intersect two circles, one centered at p1 with radius d13 the other centered at p2 with radius d23. If the point to point distance constraint between p1 and p2 is the first constraint "pinned", we assume that p1 is placed at the origin and p2 on the positive x-axis at distance d12 from p 1. These approaches are fast and more methodical. In this methods the constraints are satisfied in a constructive manner, which makes the constraint solving process natural for the user and suitable for interactive debugging. y
B p3
1 C
d13
C
D
p1
d23 p2
d12
x
p3
Figure 8. A numerical under-constrained problem (left), and its associated constraint graph (right).
C. Resolution principle Graph-based algorithms for solving geometric constraint problems have two phases : an analysis phase and a construction phase. These algorithms are also called decomposition recombination methods. During the first phase the graph of constraints is analyzed and decomposed in small sub-problems. Sequences of construction steps are derived. During the second phase the recombination is carried out and the construction steps are processed to place the geometric elements. Figure 9 shows an example of decomposition of a constrained scheme. The placement steps correspond to standardized geometric construction steps (place a point at given distances from two points, place a line at prescribed angle from another line through a point, rotate and translate a sub-structure, …).
Figure 10. Placing a point relative to two known points.
D. Graph based solvers In the early nineties, Owen [46] was the first to give an efficient and sound graph-based algorithm. This algorithm is quadratic and performs well on ruler and compass constructive problems. Following that, based on Owen's work, was developed a commercial system named D-Cubed. Since that and until recently, a lot of researches were conducted in this promising way. Among these works we can mention those done by Hoffmann's "constraint team" ([9], [17], [42], [43], [44], [25], [26], [19]), Lamure et al. [35], Lee et al. [38], Ait-Aoudia et al. [1], Jermann et al. [29], Gao et al [20], Lee et al. [39], Sitharam et al [52], Gao et al. [21], Zhang et al. [57], Joan-Arinyo et al. [30], Podgorelec et al. [48].
V. CONCLUSION
VI.
We have classified the geometric constraint solvers in three broad categories. we summarise hereafter some advantages and drawbacks for each approach. Numerical methods are O(n3) or worse. These methods suffer from the lack of "geometric explanation" during the resolution process. Also, most numerical methods have difficulties for handling over-constrained or under-constrained schemes. 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. Almost all existing solvers switch to algebraic methods when the given configuration is not solvable by the native method. Algebraic methods handle easily the 3D case. Speeding up the resolution must be considered further. Symbolic methods are typically exponential in time and space. They can be used only for small systems. According to Lazard [36], computing the Gröbner bases of an irreducible system of degree two in ten unknowns is a hopeless case. Rule-based solvers rely on the predicates formulation. Although they provide a qualitative study of geometric constraints, the "huge" amount of computations needed (exhaustive searching and matching) make them inappropriate for real world applications. Graph-based methods can be very efficient. In Computer-Aided Design, the graph-based approach has become dominant. However, these methods are only applicable to particular kinds of problems, typically ruler and compass constructive problems. The graph-based approach to handle efficiently the 3D case deserves further studies. The theoretical framework is no longer applicable. The extension of Laman theory (section IV.B) to the 3D case will give: a constraint graph G=(V,E) where |V|=n and |E|=m is structurally well-constrained if and only if m=3*n-6 and m’ ≤ 3*n’-6 for any induced sub-graph G’=(V’,E’) where |V’|=n’ and |E’|=m’. The 3D constrained design shown in figure 11 involves eight points and eighteen point to point distances. This well known example verifies the formula given above but it is not structurally well constrained. The two sub-parts defined by the points {A,B,C,D,E} and {A,G,H,F,E}can rotate around the AE axis. A
B
C
G
H F B
D
E Figure 11. A 3D constrained design.
REFERENCES
[1] S. Ait-Aoudia, H. Brahim, A. Moussaoui , T. Saadi. Solving Geometric Constraints by a Graph-Constructive Approach. IEEE International Conf. on Information Visualization , (London, England), pp. 250-255, July 99. [2] B. Aldefeld. Variation of geometries based on a geometric reasoning method. CAD vol.20, num.3, April 88. pp 117126. [3] E.L. Allgower and K. Georg. Continuation and path following. Acta Numerica, pages 1-64, 1993. [4] R. Anderl and R. Mendgen. Parametric design and its impact on solid modeling applications. Symposium on Solid Modeling and CAD/CAM Applic. May 95. pp. 1-12. [5] L.A. Barford. A graphical language-based editor for generic solid models represented by constraints. PhD Thesis, Cornell University, May 1987. [6] B. Bettig, J. Shah. Derivation of a standard set of geometric constraints for parametric modeling and data exchange. CAD, 33 (2001), 17-33. [7] A. Borning. THINGLAB: a constraint-oriented simulation laboratory. Ph.D Thesis, Stanford University 1979. [8] A. Borning and R. Duisberg. Constraint-based tools for building user interfaces. ACM Transactions on Graphics, vol. 5, num. 4, Oct. 86. pp 345-374. [9] W. Bouma, I. Fudos, C.M. Hoffman, J. Cai, R. Paige. A geometric constraint solver. Computer Aided Design, Vol. 27, No.6, June 1995, 487-501. [10] B. Brüderlin. Constructing three-dimensional geometric objects defined by constraints. Proceedings 1986. Workshop on Interactive 3D Graphics. pp.111-129, Chapel Hill, N.C, Oct 86. [11] B. Brüderlin. Automatizing geometric proofs and constructions. Computational Geometry and its Applications. pp 233-252. Lecture notes in Computer Science, 333, Springer Verlag, Mars 88. [12] S.A. Buchanan, A. Pennington. Constraint definition system : a computer-algebra based approach to solving geometric constraint problems. CAD, vol. 25, num. 12, Dec.93. pp 741-750. [13] S.C. Chou, W.F. Schelter and J.G. Yang. Characteristic sets and Gröbner bases in geometry theorem proving. Workshop on Computer-Aided Geometric Reasoning, INRIA, Sophia Antipolis, June 87. pp 29-56. [14] C. Durand, C.M. Hoffman. Variational Constraints in 3D. Proc. Intl Conf on Shape Modeling and Appl, Aizu, Japan, 1999; 90-97. [15] L.W. Ericson, C.K. Yap. The design of LINETOOL a geometric editor. Fourth Annual Symposium on Computational Geometry, ACM, June 88, pp 83-92. [16] S. Foufou, D. Michelucci, J.P. Jurzak. Numerical Decomposition of Geometric Constraints, Proceedings of the 2005 ACM symposium on Solid and physical modeling, Cambridge, Massachusetts, pp. 143 - 151. [17] Fudos, C.M. Hoffman. A Graph-Constructive approach to Solving Systems of Geometric Constraints. ACM Trans. on Graphics, Vol.16, N°2, April 1997, 179-216. [18] X.S. Gao and S.C. Chou. Solving geometric constraint systems : a symbolic approach and decision of Rcconstructibility. Computer Aided Design, pp. 115-122. vol. 30, n°. 3, 1998. [19] X.S. Gao , C.M. Hoffman and W. Yang. Solving Spatial Basic Geometric Constraint Configurations with Locus Intersection. Solid Modeling '02, 2002. [20] X.S. Gao and G.F. Zhang. Geometric Constraint Solving Based on Connectivity of Graph. MMRC, AMSS, Academia Sinica, Beijing, n°22, Dec2003, pp148-162.
[21] .S. Gao, Q. Lin, G.F. Zhang. A C-tree decomposition algorithm for 2D and 3D geometric constraint solving, Computer-Aided Design, Vol. 38, Issue 1, January 2006, Pages 1-13. [22] J. Gosling. Algebraic constraints. Ph.D Thesis, CarnegieMellon University, May 83. [23] D. Gossard, R. Zuffante and H. Sukurai. Representing dimensions, tolerances and features in MCAE systems. IEEE Computer Graphics and Applications, Mars 88. pp 51-59. [24] R. Hillyard and I. Braid. Characterizing non ideal shapes in terms of dimensions and tolerances. Computer Graphics, vol. 12, num. 3, Aug. 78. pp 234-238. [25] C.M. Hoffman and C.S. Chiang. Variable-Radius Circles of Cluster Merging in geometric constraints Part I: Translational Clusters. Computer Aided Design, vol. 33, 2001. [26] C.M. Hoffman and C.S. Chiang. Variable-Radius Circles in Cluster Merging : Part II: Rotational Clusters. Computer Aided Design, vol. 33, 2001. [27] C.M. Hoffman and R. Joan-Arinyo. A Brief on Constraint Solving, Computer-Aided Design and Applications, 2(5):655-663, 2005.. [28] C.M. Hoffman. Summary of basic 2D constraint solving, Int. Journal Product Lifecycle Management, Vol. 1, No. 2, 2006. [29] C. Jermann, G. Trombettoni, B. Neveu, M. Rueher. A constraint programming approach for solving rigid geometric systems. 6th Conf. on Principles and Practice of constraint programming pp 233-248, Singapore sep. 2000. [30] R. Joan-Arinyo, M. Tarrés-Puertas, and S. Vila-Marta. Geometric Constraint Graphs Decomposition Based on Computing Graph Circuits, Seventh International Workshop on Automated Deduction in Geometry September 22-24, 2008 [31] K. Kondo. Algebraic method for manipulation of dimensional relationships in geometric models. CAD vol.24, num.3, March 92. pp 141-147. [32] B. Kutzler. Introduction to Bucheberger's Gröbner bases method. Workshop on Computer-Aided Geometric Reasoning, INRIA, Sophia Antipolis, June 87, pp 7-25. [33] G. Laman. On graphs and rigidity of plane skeletal structures. Journal of Engineering Mathematics, vol.4, num.4, Oct. 70. pp 331-340. [34] H. Lamure and D. Michelucci. Solving constraints by homotopy. Symposium on Solid Modeling Foundations and CAD/CAM Applications. May 95. pp. 263-269. [35] H. Lamure and D. Michelucci. Qualitative study of geometric constraints. Geometric Constraint Solving and applications, B. Brüderlin and D. Roller editors, SpringerVerlag, 1998. [36] D. Lazard. Systems of algebraic equations : algorithms and complexity. Rapport interne LITP 92.20, Mars 92. [37] K. Lee and G. Andrews. Inference of the positions of components in an assembly : part 2. CAD vol.17, num.1, Jan. 85. pp 20-24. [38] J.Y. Lee, K. Kim. A 2D geometric constraint solver using DOF-based graph reduction. Computer Aided Design. Vol. 30, No. 11, 1998, pp. 883-896. [39] K.Y. Lee, O.H. Kwon, J.Y. Lee and T.W. Kim. A hybrid approach to geometric constraint solving with graph
[40]
[41]
[42]
[43]
[44]
[45] [46]
[47]
[48]
[49]
[50]
[51]
[52]
[53]
[54]
[55] [56]
[57]
analysis and reduction. Advances in Engineering Software, 34 (2003), pp 103-113. R. Light and D. Gossard. Modification of geometric models through variational geometry. CAD vol.14, num.4, July 82. pp 209-214. V. Lin, D. Gossard and R. Light. Variational geometry in CAD. Computer Graphics, vol.15, num.3, Aug.81. pp 171178. A. Lomonosov ,M. Sitharam and C.M. Hoffman. Finding Solvable Subsets of Constraint Graphs. Springer LNCS 1330, G. Smolka, ed., 1997, 463-477. A. Lomonosov ,M. Sitharam and C.M. Hoffman. Geometric Constraint Decomposition. Geometric Constr Solving and Appl., B. Bruderlin and D. Roller, eds, 1998, Springer, 170-195. A. Lomonosov ,M. Sitharam and C.M. Hoffman Decomposition Plans for Geometric Constraint Problems, Part II: New Algorithms. Journal of Symbolic Computations 31, 2001, 409-428. G. Nelson. Juno, a constraint-based graphics system. Computer Graphics, vol. 19, num. 3, 1985. pp 235-243. J.C. Owen. Algebraic solution for geometry from dimensional constraints. Proceeding Symposium on Solid Modeling Foundations and CAD/CAM Applications, Austin Texas. June 91. pp. 397-407. A. Perez and D. Serrano. Constraint base analysis tools for design. Second Symposium on Solid Modeling Foundations and CAD/CAM Applications, Montreal Canada. Mai 93. pp. 281-290. D. Podgorelec, B. Zalik, V. Domiter. Dealing with redundancy and inconsistency in constructive geometric constraint solving, Advances in Engineering Software 39 (2008) 770–786. P. Prusinkiewicz and D. Streibel. Constraint-based modeling of three-dimensional shapes. Graphics Interface '86, Vision Interface '86, 1986. pp 158-163. D.N. Rocheleau and K. Lee. System for interactive assembly modelling. CAD vol. 19, num.2, Mars 87. pp 6572. D. Serrano. Automatic dimensioning in design for manufacturing. Proceeding Symposium on Solid Modeling Foundations and CAD/CAM Applications, Austin Texas. June 91. pp. 379-386. M. Sitharam, J.J. Oung, Y. Zhou and A. Arbree. Geometric constraints within Feature Hierarchies, Computer-Aided Design, Volume 38, Issue 1, January 2006, Pages 22-38. H. Suzuki, H. Ando and F.Kimura. Geometric constraints and reasoning for geometrical CAD systems. Computer and Graphics, vol. 14, num. 2, Oct. 90. pp 211-224. G. Sunde. Specification of shape by dimensions and other geometric constraints. Geometric modeling for CAD applications, pp. 199-213. North-Holland, IFIP, 1988. I.E. Sutherland. SKETCHPAD: a man machine graphical communication system. Ph.D Thesis, MIT, Mass. 1963. A. Verroust, F. Schonek and D. Roller. Rule oriented method for paremetrized computer-aided design. CAD, vol. 24, num. 3, Oct 92. pp 531-540. G.F. Zhang, X.S. Gao. Spatial geometric constraint solving based on k-connected graph decomposition, 2006 ACM symposium on Applied computing, Dijon France, pp. 979983.