the construction of curved shapes

Upload: sung-woong-ki

Post on 04-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 The Construction of Curved Shapes

    1/18

    1 Introduction

    Shape grammars are a formal production system whereby languages of designs are

    generated according to shape replacement rules (Stiny, 1980). Ever since their concep-tion, efforts have been made to take advantage of the generative properties afforded by

    the shape grammar formalism by developing shape grammar interpreters, a discussion

    of which is presented by Gips (1999). These are computational systems intended to

    automate the application of shape rules, and thereby generate networks of designs

    within a design space. However, the development of such systems is not trivial because

    the problem of general subshape detection is yet to be solved. Indeed, shape grammar

    interpreters typically are concerned with generating shapes within limited algebras of

    design (Stiny, 1991), in which shapes are composed of a limited range of geometric

    elements, such as straight lines. In this paper, algorithms are presented that enable thedevelopment of shape grammar interpreters in which designs are generated within

    algebras of shapes composed of parametric curve segments. These algorithms provide

    a significant advantage over previous approaches to implementing shape grammars on

    curved shapes, such as that presented by McCormack and Cagan (2003), since they do

    not rely on degenerate representations of shapes in order to afford subshape detection.

    Instead the algorithms employ established results from differential geometry in order

    to enable an intrinsic comparison of shapes composed of parametric curve segments.

    This ensures that shapes are compared according to their embedding properties, defined

    under Euclidean transformations.

    The construction of curved shapes

    Iestyn JowersSchool of Mechanical Engineering, University of Leeds, Leeds LS2 9JT, England;e-mail: [email protected]

    Christopher EarlFaculty of Mathematics, Computing and Technology, The Open University, Milton KeynesMK7 6AA, England; e-mail: [email protected]

    Received 6 August 2008; published online 19 October 2009

    Environment and Planning B: Planning and Design 2010, volume 37, pages 42 ^ 58

    Abstract. Application of a shape grammar involves the repetitive task of matching and replacingsubshapes of a design under transformation, and as such is well suited for computer implementation.As a result, ever since the conception of the shape grammar formalism, efforts have been made todevelop computer programs that automate shape grammar applications. Much of this effort hasbeen directed towards the problem of subshape detection, which involves recognising subshapesembedded in a design. Solutions to this problem have been presented for shapes composed ofrectilinear geometric elements, such as straight lines, and algorithms based on these solutions

    have been implemented in a variety of shape grammar interpreters. However, there has beenless research concerning the solution of the subshape detection problem for shapes composedof nonrectilinear geometric elements, such as curve segments. In this paper a method of intrinsicmatching is presented, which enables comparison of the embedding properties of parametric curves.This method has been employed in order to develop shape algorithms which can be implementedin shape grammar interpreters for shapes composed of parametric curve segments, arranged intwo-dimensional or three-dimensional space.

    doi:10.1068/b35093

  • 7/31/2019 The Construction of Curved Shapes

    2/18

    2 Background

    2.1 Shape grammars

    A shape grammar consists of an initial shape and a set of rules of the form a 3 b,where a and b are both shapes, as illustrated in figure 1. In this context, a shape isdefined visually, as a finite arrangement of geometric elements, such as lines or curves,

    each with a definite boundary and limited but nonzero extent. A rule is applicable

    to a shape g if some similarity transformation (typically a Euclidean transformation)

    of the shape a on the left-hand side of the rule is a subshape of g, denoted a 4 g,

    where 4 is the subshape relation.

    Application of the rule removes the transformed instance of the subshape a and

    replaces it with a similarly transformed instance of the shape b on the right-hand side

    of the rule. For example, the shape rule in figure 1 removes a lens and replaces it with

    a translated lens, as indicated by the coordinate axes. Repeated application of shape

    rules to an initial shape leads to the generation of a sequence of designs, as illustrated

    in figure 2.

    Shape grammars differ from many other generative systems of design, such asevolutionary algorithms (Lee et al, 2005), in that the structure of a design is not fixed

    but changes dynamically throughout a generative process. As a result, application of a

    shape rule is not restricted to the geometric elements initially used to define a design;

    instead they are applicable to any subshapes that can be perceived to be embedded

    in the design. Indeed, within the shape grammar formalism the structure of a design

    is defined retrospectively according to shape rule applications (Stiny, 1994). A conse-

    quence of this is that shape grammars often generate designs that incorporate some

    unexpected results that follow from the recognition and manipulation of new interpre-

    tations of shapes. For example, the design sequence in figure 2 begins with an initialshape [figure 2(a)], and ends with a shape that is a rotation of this initial shape

    [figure 2(c)], but this sequence is generated via application of a rule that merely

    translates a subshape of the initial shape (figure 1). This unexpected result occurs

    because after a single application of the shape rule additional instances of the lens

    in the left-hand side of the rule have emerged [figure 2(b)]. Further applications of

    the shape rule can now be used to recognise and manipulate these emergent shapes,

    and restructure the design so that it appears to be rotated.

    Shape grammars have been found to be a powerful generative mechanism and have

    been employed in a range of design disciplines, from architecture (see, for example,Koning and Eizenberg, 1981) to engineering (see, for example, Brown and Cagan, 1997).

    Figure 1. An example shape rule.

    (a) (b) (c)

    Figure 2. Example design sequence: (a) initial shape; (b) result of one rule application; (c) resultof two rule applications.

    The construction of curved shapes 43

  • 7/31/2019 The Construction of Curved Shapes

    3/18

    However, few of these applications are computationally implemented and instead it is

    common for rules to be applied and designs generated as a paper-based exercise. This

    is because the task of developing a shape grammar interpreter is not trivial, requiring asolution to the subshape detection problem.

    2.2 Shape grammar interpreters

    Typically, a shape grammar interpreter requires mechanisms to enable the recognition

    of embedded subshapes within a design under a similarity transformation, along

    with mechanisms that enable the recognised subshapes to be removed and replaced.

    Implementation of these mechanisms is difficult because shapes can generally be

    represented in an uncountable number of ways and the task of determining whether

    or not two representations refer to the same shape can be computationally expensive, if

    not impossible. Instead, implementation can be simplified through the use of a canonicalrepresentation of shapes, typically the maximal representation. Under this representation,

    shapes are composed of the smallest possible set of geometric elements. For example,

    a shape composed of straight lines is reduced to its maximum representation by merging

    any colinear lines that overlap or share any endpoints, so that the shape is composed of the

    smallest possible set of lines; these are the maximal lines of the shape. The first algorithms

    to provide the required mechanisms for shape grammar implementation were presented

    by Krishnamurti (1980; 1981). These algorithms enable implementation of shape grammars

    on shapes composed of straight lines arranged in a plane and have been implemented

    in a variety of shape grammar interpreters, such as those by Krishnamurti and Giraud(1986), Chase (1989), and Tapia (1999). They have also been shown to be extendable

    to include shapes composed of lines, planes, or solids, arranged in two-dimensional

    or three-dimensional Euclidean space (Krishnamurti, 1992).

    In the algorithms, maximal geometric elements are represented by a descriptor and

    a boundary, where the descriptor defines the abstract object of infinite extent in which a

    geometric element is embedded (for example, an infinite line) and the boundary

    defines the location of a geometric element with respect to its descriptor, for exam-

    ple, endpoints of a line. In this way, shapes are represented by lexicographically

    ordered lists where maximal lines are partitioned according to their descriptorsinto colinear sets and these sets are themselves ordered according to boundaries.

    Binary shape operations, such as shape difference, are applicable to two lines only

    if they share the same descriptors; that is, a line can only be added to or subtracted

    from other colinear lines. As a result, shape operations are implemented efficiently

    by comparing the ordered lists that represent the shapes. However, under Euclidean

    transformations, a straight-line segment is self-similar and can be embedded in

    any other straight line in an infinite number of ways. Consequently, matching of

    embedded subshapes is facilitated by the definition of distinct points, such as the

    points of intersection between two lines, and these points are used to determinethe spatial relations and embedding properties of shapes.

    An obvious limitation of this approach is that it can generate only designs com-

    posed of rectilinear geometric elements, such as lines or planes. Extension to include

    nonlinear elements such as curves or surfaces is not straightforward due to the differ-

    ences in embedding properties. However, Chau et al (2004) have adapted the approach

    in order to develop a shape grammar interpreter for shapes composed of straight lines

    and circular arcs arranged in three-dimensional space. This is possible because

    circular arcs share many of the self-similarity properties apparent in straight lines.

    Similarly, McCormack and Cagan (2003) have employed aspects of the algorithmsin order to develop a shape grammar interpreter for shapes composed of curves. In

    particular, shapes composed of freeform curve segments are associated with distinct

    44 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    4/18

  • 7/31/2019 The Construction of Curved Shapes

    5/18

    construct designs, and intrinsic comparison of descriptors provides valuable insight

    with respect to the embedding properties of curve segments.

    Given a space curve C, the natural parameters of C, denoted s, are defined by thearc length. This arc length is not uniquely defined since it is measured from a specific

    point of the curve, in a specific direction. As a result, if s1 and s2 are both natural

    parameters ofC then s2 s1 c, for some constant c. The curvature and torsion ofCare defined as functions of this arc length and are denoted k(s) and t(s), respectively.

    These functions are intrinsic properties of C since they are independent of the natural

    parameter used to represent the curve. That is, the value of the curvature and torsion

    at any point of C is the same regardless of the direction in which the arc length is

    measured and the point it is measured from. The curvature function k(s) is a measure

    of a curve's departure from linearity; that is, it is a measure of how much the curveturns. Consequently, it follows that a straight line has zero curvature, and conversely

    any curve with zero curvature is a straight line. Similarly, the torsion function t(s) is

    a measure of a curve's departure from planarity; that is, it is a measure of how much

    the curve twists. Consequently, it follows that a planar curve has zero torsion, and

    conversely any curve with zero torsion is a planar curve.

    Formally, the fundamental theorem of space curves states that two space curves C1and C2 can be mapped onto each other under a Euclidean motion if and only if,

    for some constant c,

    k1 s k2 s c , (1)

    t1 s t2 s c . (2)

    These equations hold for curves that are parameterised according to natural param-

    eters, defined by arc length. However, Farouki and Sakkalis (1991) have shown that

    real curves, other than straight lines, cannot be parameterised according to rational

    functions of a natural parameter. This means that the descriptors of parametric curve

    segments commonly used by designers in computational systems of design, such as

    B-splines or NURBS, cannot be readily parameterised according to natural param-eters. As such, they cannot be easily compared according to equations (1) and (2).

    Fortunately, the principles of differential geometry hold for any regular curves irres-

    pective of the parameters used to define them (Do Cormo, 1976), and the equations can

    be restated for curves defined according to arbitrary parameters. Accordingly, given

    two space curves C1 and C2 , parameterised according to arbitrary parameters t

    and u, respectively, the two curves can be mapped onto each other under a Euclidean

    motion if and only if, for some continuous reparameterisation function u u(t),

    k1 t k2ut

    , (3)

    t1 t t2ut

    . (4)

    Equations (3) and (4) are suitable for comparing the embedding properties of

    parametric curves under Euclidean motion: that is, translation and rotation. How-

    ever, in shape grammar implementations, it is customary to consider the embedding

    properties of shapes under Euclidean transformations: that is, Euclidean motion

    augmented by reflection and isotropic scale. As a result, it is desirable to expand

    these equations in order to enable comparison of curves under the Euclidean trans-

    formations, and to do so, it is necessary to consider how the curvature and torsionfunctions of a curve are modified under reflection and isotropic scale.

    46 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    6/18

    Given a space curve C, defined parametrically according to the function x(t) [x(t),y(t), z(t)], the curvature ofC is

    k jx H x HHj

    jx Hj3

    ,

    and the torsion function ofC is

    t jx Hx HHx HHHj

    jx H x HHj2

    ,

    where jx Hx HHx HHHj denotes a scalar triple product x H(x HH x HHH), and the derivatives x H,x

    HH, and x HHH are functions of arbitrary parameter t (Do Carmo, 1976). IfC is modified

    according to a scaling factor l then the derivativesx

    H

    ,x

    HH

    , andx

    HHH

    are scaledequivalently:

    xt 3 lxt A x Ht 3 lx Ht , and x HHt 3 lx HHt .

    As a result, it can be shown that the curvature and torsion function of C are scaled

    according to a factor of l1

    . Similarly, it can be shown that, ifC is modified according

    to a reflection and if C is a planar curve, then the curvature function is negated;

    otherwise ifC is nonplanar the torsion function is negated.

    These results, when combined with equations (3) and (4), mean that given two

    space curves C1 and C2 , parameterised according to arbitrary parameters t and u,respectively, the two curves can be mapped onto each other under a Euclidean

    transformation if and only if

    k1 t l1k2

    ut

    , (5)

    t1 t l1t2

    ut

    , (6)

    for some constant l( T 0) and some continuous reparameterisation function u u(t).These equations provide a means of determining whether or not two space curves can

    be mapped onto each other under a Euclidean transformation. If the space curves actas descriptors for curve segments in a shape, then the equations reveal whether or not

    the segments lie on infinite curves that can be mapped onto each other, and whether or

    not the curve segments can be embedded in each other. In the remainder of this paper,

    equations (5) and (6) form the basis of shape algorithms that enable implementation of

    shape grammars on shapes composed of parametric curve segments.

    4 Shape algorithms for curved shapes

    Implementation of a shape grammar involves repeated application of shape rules in the

    form a 3 b. Such a rule is applicable to a shape g if there is a similarity transformationT that will match the shape a on the left-hand side of the rule with a subshape of g.This condition is tested according to the subshape relation, denoted by 4, and if it is

    satisfied then a is said to be a subshape of g, denoted a 4 g. A shape rule is applied to

    g by removing the subshape that matches the transformed shape T(a) and replacing it

    with a similarly transformed shape T( b), where b is the shape on the right-hand side of

    the rule. This shape replacement involves applying a shape subtraction operation,

    followed by a shape addition operation, and results in the shape [g T(a)] T( b).As a result, the algorithms necessary to implement a shape grammar interpreter include

    algorithms for the subshape relation and the shape operations of addition and subtrac-tion. The algorithms introduced here are for implementing shape grammars on shapes

    composed of parametric curve segments that are arranged in two- or three-dimensional

    Euclidean space, with shape operations applied under Euclidean transformation. It is

    The construction of curved shapes 47

  • 7/31/2019 The Construction of Curved Shapes

    7/18

    assumed that the curve segments are sufficiently smooth that their curvature and torsion

    functions are continuous.

    The algorithms will be illustrated by considering application of the shape rulein figure 1 to the curved shape S in figure 3 [which is also the shape in figure 2(b)].

    S is composed of nine curve segments, S1 ^S9 , and shape operations will be applied

    to Sby considering the intrinsic properties of the descriptors of these composite curves

    according to equations (5) and (6).

    4.1 Maximal representation of curved shapes

    As discussed above, when implementing shape operations it is beneficial to consider

    a canonical representation of shapes, typically the maximal representation. This

    approach was successfully employed by Krishnamurti (1980; 1981) in shape algorithms

    for shapes composed of straight lines, and is also used here in shape algorithms forcurved shapes. Given a shape composed of parametric curve segments, such as the

    shape S in figure 3, its maximal representation results from merging any curve

    segments that are on the same infinite curve and have any points in common. For

    example, consider the curve segments S1 and S3 in figure 3. Let S1 and S3 be para-

    meterised according to arbitrary parameters t and u by the vectors x1 (t) and x2 (u) on the

    intervals t0 4 t 4 t1 and u0 4 u 4 u1 , respectively. If S1 and S3 are on the same

    infinite curve and have any points in common, then they can be merged to form a

    single-curve segment. The infinite curves on which S1 and S3 lie are defined by their

    descriptors, which are compared according to equations (5) and (6). This intrinsic com-parison, along with a comparison of the spatial relation between the infinite curves, will

    reveal whether or not S1 and S3 are embedded in the same infinite curve. If there exists a

    scaling factor l( T 0) and a continuous function u u(t) such that the intrinsic proper-ties of the infinite curves defined by the descriptors of S1 and S3 satisfy equations (5)

    and (6) then S1 and S3 are on infinite curves which can be mapped onto each other

    under Euclidean transformations. In addition, if x1 (t) x2 [u(t)] then S1 and S3 are oninfinite curves that have the same spatial position and indeed are the same. In figure 3,

    S1 and S3 are on the same infinite curve, as is S5 , as illustrated in figure 4.

    Comparison of the endpoints of S1 and S3 will determine whether or notthey have any points in common and consequently whether or not they can be

    merged to form a single curve. If S1 and S3 overlap and have one or more points

    S8 S1

    S9

    S7 S2S6 S3

    S5 S4

    Figure 3. A curved shape S.

    S8 S1

    S9S7 S2

    S6 S3

    S5 S4

    Figure 4. Description ofS1 , S3 , and S5 .

    48 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    8/18

    in common, as illustrated in figures 5(a) ^ 5(d), then they can be merged to form

    a single curve. Alternatively, if S3 is completely embedded in S1 , as illustrated in

    figures 5(e) and 5(f), then S3 can simply be removed from the shape without causing

    any visual alterations. Similarly, if S1 is completely embedded in S3 , as illustrated

    in figures 5(g) and 5(h), then S1 can simply be removed from the shape without

    causing any visual alterations. For any other arrangements of endpoints, S1 and S3are completely disjoint and are both maximal with respect to each other.

    In this example, S1 and S3 share an endpoint and as a result can be merged to

    form a single curve, say S13. Similarly, S13 and S5 share an endpoint and can bemerged to form a single maximal curve, say Sa. Comparison of all the curves in Swith

    each other reveals that S2 , S7 , and S9 can be merged to form a single maximal curve,

    say Sb, and that S4 , S6 , and S8 can be merged to form a single maximal curve, say Sc,

    resulting in a maximal representation of Sas illustrated in figure 6.

    This procedure for discovering the maximal representation of a curved shape is

    summarised in algorithm 1. The input for the algorithm is a shape, represented by an

    array of N curves. Every curve segment in the shape is compared with every other

    curve segment according to the intrinsic properties of the infinite curves defined by

    their descriptors. If, for a pair of infinite curves, there exists a constant l ( T 0) and acontinuous function u u(t) that satisfy equations (5) and (6) then they can bemapped onto each other under a Euclidean transformation. In such a case the spatial

    positions of the two infinite curves are compared to determine if they are the same.

    If they are the same then the endpoints of the curve segments associated with the

    descriptors are compared to determine if the curve segments can be merged to form

    a single maximal curve segment. Once all the curve segments in the shape have been

    compared with each other the algorithm outputs a shape represented by an array of N

    maximal curves. Note that the number, N, of curves that are input into the algorithm

    need not necessarily equal the number, N, of curves that are output from the algo-rithm. Curves are merged and deleted as the algorithm progresses and as a result N,

    the number of curves in the shape, is constantly being updated.

    u0 u1 t0 t0

    t0 t0 u0 u1

    t0 t1 t1 t0 u0 u1 u1

    u u t t

    u0

    (a) (b) (c) (d)

    (e) (f ) (g) (h)

    t1u1

    t1u0

    u1t1

    u0t1

    Figure 5. Overlapping curve segments, where (a) t0 4 u0 4 t1 4 u1 ; (b) t0 4 u1 4 t1 4 u0 ;(c) u0 4 t0 4 u1 4 t1 ; (d) u1 4 t0 4 u0 4 t1 ; (e) t0 4 u0 , u1 4 t1 ; (f ) t1 4 u0 , u1 4 t0 ;

    (g) u0 4 t0 , t1 4 u1 ; (h) u1 4 t0 , t1 4 u0 .

    Sa

    Sb

    Sc

    Figure 6. Maximal representation ofS.

    The construction of curved shapes 49

  • 7/31/2019 The Construction of Curved Shapes

    9/18

    4.2 Intrinsic subshape detection

    The first stage in applying a shape rule, a 3 b, to a shape g is determining whether ornot the shape a, on the left-hand side of the rule, is a subshape ofg. This is determined by

    comparing the shapes according to the subshape relation. For example, consider the

    shape rule in figure 7 where a lens is translated along the length of its central axis,

    as indicated by the coordinate axis. If this rule is applicable to the shape S in figure 6

    the shape a, on the left-hand side of the rule, can be embedded in Sunder a Euclidean

    transformation. Here, the shape a, is composed of two curve segments a1 and a2 , and if

    a transformation of a is a subshape ofS, then transformations of the curve segments a1and a2 must be subshapes of the curve segments Si in S. Accordingly, comparing the

    descriptors of a1 and a2 with descriptors of the maximal curves that compose the shapeS, according to equations (5) and (6), will reveal whether or not a can be embedded in S.

    Let Sa and a1 be parameterised according to the arbitrary parameters t and u by

    the vectors x1 (t) and x2 (u) on the intervals t0 4 t 4 t1 and u0 4 u 4 u1 , respectively.

    If the infinite curves defined by the descriptors of Sa and a1 can be mapped onto each

    other under a Euclidean transformation, such that the endpoints of a1 are within the

    Algorithm 1. Make maximal.

    Data: A shape represented by an array ofN curvesResult: A shape represented by an array ofNmaximal curves

    ifNb 1 thenfor i2 0 to N 2 do

    for j2 0 to N 1 dofirstCurve designArrayi;secondCurve designArrayj;if l exists then

    if u (t) exists thenif firstCurvet secondCurveut then

    if firstCurve and secondCurve overlap thenthirdCurve firstCurve secondCurve;Add thirdCurve to designArray;Delete firstCurve from designArray;Delete secondCurve from designArray;Update N;

    else if firstCurve is embedded in secondCurve thenDelete firstCurve from designArray;Update N;

    else if secondCurve is embedded in firstCurve thenDelete secondCurve from designArray;

    Update N;end

    endend

    endend

    endend

    a1 b1

    a2 b2

    Figure 7. A shape rule for a 3 b.

    50 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    10/18

    endpoints of Sa , then a1 can be embedded in Sa . Now, the infinite curves defined by

    the descriptors of Sa and a1 can be mapped onto each other under a Euclidean

    transformation if there exists a scaling factor l( T 0) and a continuous functionu u(t) such that the intrinsic properties of the infinite curves satisfy equations (5)and (6). Also, comparison of the endpoints of the two curves, as illustrated in figure 5,

    will reveal whether or not a1 can be embedded in Sa . In this example, a1 can be

    embedded in Sa under a Euclidean transformation, and as a result a1 is a subshape

    of Sa . Comparison of all the curve segments that compose a with all the curve seg-

    ments that compose Swill determine the transformations that embed each a curve in

    each S curve. If all curves in a can be embedded in curves in S under the same

    transformation then a is a subshape ofS. Indeed, in this example, there are, disregard-

    ing reflective symmetry, three transformations that embed a in S, as illustrated infigure 8.

    This procedure for applying the subshape relation to curved shapes is summarised

    in algorithms 2 and 3. Algorithm 2 compares all the curves in a with all the curves in

    S in order to calculate the transformations that embed the a curves in S. The input

    for the algorithm is a shape grammar that is composed of a shape, called design,

    represented by an array of N curve segments and an array of L shape rules. In each

    shape rule there is a shape a that is represented by an array of M curve segments.

    Sa Sa Sa

    Sb Sb Sb

    Sc Sc Sc

    Figure 8. Subshape detection

    Algorithm 2. Calculate transformations.

    Data: A shape grammar consisting of L shape rules, each rule containing a shape a (alpha)represented by an array ofM curves, and a shape design represented by an array ofN curvesResult: An array of transformations transArray associated with each curve in alpha

    for ruleCount 0 to L 1 dorule ruleArrayruleCount;M number ofalpha curves in rule;for alphaCount 0 to M 1 do

    alphaCurve ruleXalphaArrayalphaCount;

    fordesignCount

    0 toN 1 dodesignCurve designArraydesignCount;

    if l exists thenif u (t) exists then

    if alphaCurve can be embedded in designCurve thenCalculate transformation between alphaCurve and designCurve;transformation.matchWith designCount;Add transformation to alphaCurve.transArray;

    endend

    end

    endend

    end

    The construction of curved shapes 51

  • 7/31/2019 The Construction of Curved Shapes

    11/18

    Algorithm 3. Compare transformations.

    Data: A shape grammar consisting ofL shape rules, each rule containing a shape a (alpha) defined by an arrayofMcurvesResult: A Boolean value indicating whether or not all curve segments in a shape alpha are associated with thesame transformation

    if nextRule TRUE thenruleMatch ruleMatch 1mod L;nextRule FALSE;

    endfor ruleCount ruleMatch to L 1 do

    rule ruleArrayruleCount;ifMb 1 do

    firstCurve alphaArray0;T1 number of transformations associated with firstCurve;for firstTransCount matchPosition to T1 1 do

    firstTrans firstCurveXtransArrayfirstTransCount;for alphacount 1 to M 1 do

    alphaCurve alphaArrayalphaCount;Talpha number of transformations associated with alphaCurve;for alphaTransCount 0 to Talpha 1 do

    alphaTrans alphaCurveXtransArrayalphaTransCount;if firstTrans alphaTrans then

    firstCurveXtransMatchIndex firstTransCount;alphaCurveXtransMatchIndex alphaTransCount;

    foundMatch TRUE;ruleMatch ruleCount;if alphaCount ` M 1 then

    alphaTransCount Talpha;else

    matchPosition matchPosition 1mod T1;if matchPosition 0 then

    nextRule TRUE;endReturn foundMatch;

    endelse if alphaTransCount Talpha 1 then

    alphaCount M;foundMatch FALSE;end

    endend

    endelse ifM 1 then

    alphaCurve alphaArray0;Talpha number of transformations associated with alphaCurve;alphaCurveXtransMatchIndex matchPosition;foundMatch TRUE;ruleMatch ruleCount;matchPosition

    matchPosition

    1

    mod Talpha;if matchPosition 0 then

    nextRule TRUE;endReturnfoundMatch;

    endmatchPosition 0;

    endif ruleMatch b 0 then

    foundMatch TRUE;nextRule TRUE;

    endreturn foundMatch;

    52 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    12/18

    The algorithm systematically compares the curves that compose the a shape in each

    shape rule with the curves that compose the shape design in order to determine whether

    or not transformations exist that embed the a curves in the design curves. If such atransformation exists it is calculated and then associated with a variable matchWith that

    captures the index of the design curve in which the a curve is embedded. In order to

    make shape matching a more efficient process this algorithm is applied only once per

    rule application and the transformations are stored in transformation arrays that are

    associated with the a curves to which they apply.

    Algorithm 3 scrolls through the rules in the grammar and compares the trans-

    formations associated with the a curves in order to determine whether or not the shape

    a as a whole can be embedded in the shape design. The input for the algorithm is an

    array ofL shape rules each containing a shape a represented by an array ofMcurves.For each rule in turn the algorithm compares the transformation associated with the

    first curve in the array of a curves with the transformations associated with the other a

    curves. If all of the curves in an a shape are associated with the same transformation

    then that a is a subshape of the shape design and the algorithm terminates.

    The algorithm can be applied repeatedly in order to explore different match and

    rule possibilities and the variables nextRule, ruleMatch, and matchPosition are global

    variables that are in place in order to record the current state of the comparison. When

    the algorithm is applied next the comparison continues from the current state accord-

    ing to these global variables. If a shape a is found such that all its composite curvesare all associated with the same transformation then the shape is a subshape of design.

    The variable transMatchIndex records the index of the transformation in the arrays

    associated with the a curves. When the algorithm terminates it outputs the Boolean

    value of foundMatch which is TRUE if a match is found and FALSE otherwise.

    4.3 Shape replacement

    If a shape g is found to have a subshape that matches a shape a on the left-hand side of

    shape rule under a Euclidean transformation T, then that rule can be applied to g by

    replacing the shape T(a) with the shape T(b). For example, application of the subshape

    relation has revealed that the shape a, on the left-hand side of the rule in figure 7, is asubshape of the shape S in figure 6, under the Euclidean transformation T. The rule

    can be applied to Sby first applying the shape difference operation in order to remove

    the transformed shape T(a) from S, followed by the shape union operation in order to

    add the similarly transformed shape T(b).

    The shape difference operation is applied by comparing the curve segments that

    compose the shapes. For example, let Sa and a1 be parameterised according to the

    arbitrary parameters t and u by the vectors x1 (t) and x2 (u) on the intervals t0 4 t 4 t1and u0 4 u 4 u1 , respectively. It is already known from the subshape algorithm

    (algorithm 2) that the descriptors ofSa and a1 can be mapped onto each other underEuclidean transformation and that a1 can be embedded in Sa under the transforma-

    tion T. The shape Sa T(a1 ) results from applying the shape difference operation tothe curve segments Sa and T(a1 ). This shape will be composed of one curve segment if

    Sa and T(a1 ) have endpoints in common, otherwise it will be composed of two curve

    segments, as illustrated in figure 9.

    In this example, Sa and T(a1 ) share an endpoint, as illustrated in figure 8, and as

    a result the shape Sa T(a1 ) is composed of a single curve. Similarly, Sb T(a2 ) is ashape composed of a single curve, and the shape S T(a), that results from applying

    the shape difference operation to S and T(a) is illustrated in figure 10.The shape union operation is applied by simply adding the curve segments

    that compose the shape T(b), to the array of curves that represents the shape. In this

    The construction of curved shapes 53

  • 7/31/2019 The Construction of Curved Shapes

    13/18

    example the curves T( b1 ) and T(b2 ) are added to the shape S T(a), resulting in theshape [S T(a)] T(b), as illustrated in figure 11.

    This procedure for shape replacement according to a shape rule a 3 b, issummarised in algorithms 4 and 5. Algorithm 4 transforms the shapes a and b accord-

    ing to the Euclidean transformation T. This transformation was determined according

    to the subshape relation and embeds the shape a in the shape design. The input for

    the algorithm is a shape rule, composed of two shapes a and b that are represented

    x1 (t) x2 (u)

    u0 u1 u1 u0 u1 u0 u0 u1t0 t1 t1 t0 t0 t1 t1 t0

    (a) (b) (c) (d)

    Figure 9. Shape difference between curve segments, where (a) t0 ` t1 and u0 ` u1 ; (b) t0 b t1 andu0 b u1 ; (c) t0 ` t1 and u0 b u1 ; (d) t0 b t1 and u0 ` u1 .

    Sa T(a1 )

    Sb T(a2 )

    Sc

    Figure 10. Subshape removal.

    T( b2 )

    T( b1 )

    Figure 11. Result of rule application.

    Algorithm 4. Shape transformation.

    Data: A shape a (alpha) represented by an array ofMcurves, and a shape b (beta) represented

    by an array ofP curvesResult: A shape Talpha represented by an array ofM curves, a shape Tbeta represented by anarray ofP curves

    for alphaCount 0 to M 1 doalphaCurve alphaArrayalphaCount;transMatch CurveXtransArrayalphaCurveXtransMatchIndex;TalphaCurve transMatchaplhaCurve;Add TalphaCurve to TalphaArray;

    endfor betaCount 0 to P 1 do

    betaCurve betaArraybetaCount;TbetaCurve transMatchbetaCurve;Add TbetaCurve to TbetaArray;

    end

    54 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    14/18

    by an array of M and P curves, respectively. Each curve is considered in turn

    and transformed according to the transformation T. The output of the algorithm is the

    transformed shapes T(a) and T( b).

    Algorithm 5 replaces the subshape T(a), in the shape design, with the shape T( b).The input for the algorithm is a shape T(a) represented by an array of M curves,

    a shape design represented by an array ofNcurves, and a shape T( b) represented by an

    array of P curves. The algorithm deletes the shape T(a) from the shape design by

    considering each design curve in turn. The variable matchWith associated with each

    T(a) curve is the index of a design curve in which it can be embedded. The shape

    difference of a design curve and a T(a) curve results in two curves, as illustrated in

    figure 9. If the two curves have any endpoints in common then one of these curves will

    be of zero length. When all the design curves have been considered then the shape

    design will have been replaced with the shape design T(a). The algorithm then addsall the curves in the array that represents the shape T( b) to the array that represents

    the shape design, and outputs the shape [design T(a)] T( b).

    Algorithm 5. Shape replacement.

    Data: A shape T(a) (Talpha) represented by an array ofM curves, a shape design representedby an array ofN curves, and a shape T(b) (Tbeta) represented by an array ofP curvesResult: A shape, design Talpha Tbeta

    for designcount 0 to N 1 dodesignCurve designArraydesignCount;Add designCurve to minusalphaArray;for alphaCount 0 to M 1 do

    TalphaCurve TalphaArrayalphaCount;transMatch TalphaCurveXtransArraytransMatchIndex;if transMatchXmatchWith designcount then

    count number of curves in minusalphaArray;for i 0 to count 1 dodelete FALSE;designCurve minusalphaArrayi;if t0 ` t1 & u0 ` u1 OR t0 b t1 & u0 b u1 then

    firstCurve curve defined between t0 and u0;secondCurve curve defined between t1 and u1;Add firstCurve and secondCurve to minusalphaarray;delete TRUE;

    else if t0 ` t1 & u0 b u1 OR t0 b t1 & u0 ` u1 thenfirstCurve curve defined between t0 and u1;

    secondCurve curve defined between t1 and u0;Add firstCurve and secondCurve to minusalphaarray;delete TRUE;

    endif delete TRUE then

    Delete designCurve from minusalphaArray;end

    endend

    endenddesignArray minusalphaArray;for betaCount 0 to P 1 do

    TbetaCurve TbetaArraybetaCount;Add TbetaCurve to designArray;

    end

    The construction of curved shapes 55

  • 7/31/2019 The Construction of Curved Shapes

    15/18

    The five shape algorithms presented here provide the mechanisms necessary to

    implement a shape grammar interpreter for shapes composed of parametric curves in

    two- or three-dimensional space. Within such a system shape grammars would producesequences of designs via repeated application of shape rules, according to sequential

    use of the algorithms, as follows:

    Algorithm 1: calculate maximal representation of shape S.

    Algorithms 2 and 3: apply subshape relation to determine applicability of shape rule

    a 3 b.Algorithms 4 and 5: remove the transformation of a from Sand replace with a transfor-

    mation of b.

    If the subshape relation produces a negative result then the shape a cannot be

    embedded in the shape S and the shape rule cannot be applied. However, whilethe subshape relation continues to produce positive results the shape grammar can

    continue to produce new designs.

    5 Discussion

    The shape grammar formalism is based on a visual representation of shape rather than

    a formal representation, and shape grammar interpreters afford shape manipulations

    that reflect this. It is this representational aspect of shape grammars that gives rise to

    the distinction between a geometric element, such as a curve, and the abstract object

    defined by its descriptor. Geometric elements are visual and they have a definiteboundary and limited but nonzero extent. On the other hand, a descriptor defines an

    abstract object given by a formal mathematical representation, with no boundary and

    possibly infinite extent. This distinction can lead to some interesting consequences with

    respect to implementing shape grammars on curved shapes. For example, consider the

    curve segment illustrated in figure 12 which is represented according to two distinct

    descriptors, and as a result is a segment of two distinct infinite curves.

    Visually, there is no problem with this situation, and perceptually the curve

    segment could be represented according to either, or both, descriptors. Indeed, it is

    entirely feasible for this situation to arise when considering the types of piecewiseparametric curves commonly used by designers in computational systems of design,

    such as B-Splines or NURBS. However, this raises complications with respect to

    shape grammar implementation. As discussed above, implementation of the mecha-

    nisms necessary for a shape grammar interpreter is simplified if shapes can be

    reduced to a canonical representation. In the algorithms presented in this paper,

    and in the algorithms presented by Krishnamurti (1980; 1981), a canonical represen-

    tation of a shape is given according to maximal geometric elements, and shape

    operations are applied through consideration of each of these elements along with

    their descriptors. Jowers et al (2004) warn that, if a canonical representation of ashape is required, then the situation illustrated in figure 12 should be avoided,

    since shapes composed of curve segments associated with multiple descriptors would

    Figure 12. A curve segment represented according to two descriptors.

    56 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    16/18

    have multiple maximal representations. As such, piecewise curves, such as B-Splines

    or NURBS, should not be considered as single curves; instead, they could be treated as

    shapes composed of multiple geometric elements, each defined according to a differentdescriptor. The formal representation of shapes supports this approach. Indeed, con-

    sideration of a mathematical representation of curves, as defined by descriptors,

    suggests that the situation illustrated in figure 12 could not arise practically. This is

    because, mathematically, if regular curves are equal for a finite extent of their length

    then they are equal for their whole length.

    The distinction between visual and formal representations of shapes is not so

    apparent for shapes composed of straight lines. This is because if two lines are

    associated with different descriptors then it is usually visually obvious. This difference

    between curved and rectilinear shapes results from differences in embedding propertiesof geometric elements. Further differences can also be noted. For example, difficulties

    arise when comparing the embedding properties of rectilinear geometric elements, such

    as straight lines, because in an intrinsic sense there is no distinction between different

    segmentsin the words of Blake ``a line is a line in its minutest subdivisions'' (1974,

    page 878). As a result, a line can be embedded in another line in an uncountable

    number of ways. That is, the embedding relations between different line segments is

    infinite and intrinsic comparison, such as that outlined in the algorithms presented

    here, is not possible. Similarly, intrinsic matching is not possible for shapes com-

    posed of geometric elements with constant intrinsic properties, such as circular arcs.For such shapes, it is necessary to use alternative methods for determining the

    embedding properties. For example, Krishnamurti's algorithms rely on the definition

    of distinct points in order to determine the spatial relations and embedding proper-

    ties of shapes composed of straight lines. On the other hand, intrinsic matching is

    possible for shapes composed of geometric elements with varying intrinsic properties.

    This is because the varying intrinsic properties result in limited embedding relations

    between geometric elements. These embedding relations are defined by a scalar value l

    and the continuous function u u(t), and allow for intrinsic comparison of curve

    segments according to the equationsk1 t l

    1k2

    ut

    ,

    t1 t l1

    t2ut

    .

    A general method for determining l and u u(t), or indeed of proving theirexistence, has not been investigated here. Indeed, l and u u(t) are both dependenton the particular parametric curves used to compose a shape. An example in which

    the algorithms are used to implement shape grammars on shapes composed of Be zier

    curves will be presented in a paper to follow. Such an implementation will increase

    the scope of shape grammars applications to design disciplines where rectilinear shapesare not sufficient, such as product design.

    ReferencesBlake W, 1974 Blake: Complete Writings Ed. G Keynes (Oxford University Press, Oxford)Brown K N, Cagan J, 1997, ``Optimized process planning by generative simulated annealing''

    Artificial Intelligence for Engineering Design, Analysis and Manufacturing 11 219 ^ 235Chase S C, 1989, ``Shapes and shape grammars: from mathematical model to computer

    implementation'' Environment and Planning B: Planning and Design 16 215 ^ 242Chau H H, Chen X, McKay A, de Pennington A, 2004, ` Evaluation of a 3D shape grammar

    implementation'', in Design Computing and Cognition '04 Ed. J S Gero (Kluwer, Dordrecht)pp 357 ^ 376

    Do Carmo M P, 1976 Differential Geometry of Curves and Surfaces (Prentice-Hall, EnglewoodCliffs, NJ)

    The construction of curved shapes 57

  • 7/31/2019 The Construction of Curved Shapes

    17/18

    Elber G, Kim M S, 1997, ``Geometric shape recognition of freeform curves and surfaces'' GraphicalModels and Image Processing 59 417 ^ 433

    Farouki R, Sakkalis T, 1991, ``Real rational curves are not `unit speed''' Computer Aided Geometric

    Design 8 151 ^ 157Gips J, 1999, ``Computer implementation of shape grammars'', in NSF/MIT Workshop on Shape

    Computation Massachusetts Institute of Technology, Cambridge, MAJowers I, Prats M, Earl C, Garner S, 2004,``On curves and computation with shapes'', in Generative

    CAD Systems Eds O Akin, R Krishnamurti, K P Lam (School of Architecture, Carnegie MellonUniversity, Pittsburgh, PA) pp 439 ^ 457

    Ko K H, MaekawaT, Patrikalakis N M, Masuda H,Wolter F-E, 2004,` Shape intrinsic properties forfree-form object matching'' Journal of Computing and Information Science in Engineering3 325 ^ 333

    Koning H, Eizenberg J, 1981, ``The language of the prairie: Frank Lloyd Wright's Prairie houses''

    Environment and Planning B8 295 ^ 323Krishnamurti R, 1980, ` The arithmetic of shapes'' Environment and Planning B7 463 ^ 484Krishnamurti R, 1981, ``The construction of shapes'' Environment and Planning B8 5 ^ 4 0Krishnamurti R, 1992, ` The maximal representation of a shape'' Environment and Planning B:

    Planning and Design 19 267 ^ 288Krishnamurti R, Giraud C,1986,` Towards a shape editor: the implementation of a shape generation

    system'' Environment and Planning B: Planning and Design 13 391 ^ 404Lee C-Y, Ma L, Antonsson E K, 2005, ``Evolutionary and adaptive synthesis methods'', in Formal

    Engineering Design Synthesis Eds E K Antonsson, J Cagan (Cambridge University Press,Cambridge) pp 270 ^ 320

    McCormack J P, Cagan J, 2003, ``Increasing the scope of implemented shape grammars: a shape

    grammar interpreter for curved shapes'', in ASME 2003 International DETC and Computersand Information in Engineering Conference Chicago, IL, http://www.catalog.asme.org/ConferencePublications/PrintBook/2003 Proceedings-DEDCDesign 3.cfm

    Stiny G, 1980, ``Introduction to shape and shape grammars'' Environment and Planning B7 343 ^ 351Stiny G, 1991, ``The algebras of design'' Research in Engineering Design 2 171 ^ 181Stiny G, 1994, ``Shape rules: closure, continuity, and emergence'' Environment and Planning B:

    Planning and Design 21 s49 ^ s78Tapia M, 1999, `A visual implementation of a shape grammar system'' Environment and Planning B:

    Planning and Design 26 59^74

    2009 Pion Ltd and its Licensors

    58 I Jowers, C Earl

  • 7/31/2019 The Construction of Curved Shapes

    18/18

    Conditions of use. This article may be downloaded from the E&P website for personal research

    by members of subscribing organisations. This PDF may not be placed on any website (or other

    online distribution system) without permission of the publisher.