LEGO_Grammar

Document Sample
LEGO_Grammar Powered By Docstoc
					                                   LEGO Grammar.
                                         Version 1.7
Parameterized context sensitive directional graph grammar designed to handle thee-dimensional
structures assembled from LEGO blocks, axles, wheels, motors and batteries. Examples of the
elements which can be handled by the grammar is shown below:
         Grammar vocabulary is {MECHANISM,  Module,  Connect,  Block,  Element, 
Disk,  Pole, PegPair, BorderPair, Snap,  Insert,  TInsert,  GTrans, Beam, Brick, Plate,
Battery, Motor, Wheel, Gear, Axle, PozX, PozY, SizeX, SizeY, Len, Diam, Teeth, Hole (, ), [,
], ;}. Starting word of the grammar is – {MECHANISM}. Terminal words of the grammar are –
{Snap,  Insert,  TInsert,  GTrans,  Beam,  Brick, Plate, Battery, Motor, Wheel,
Gear, Axle, SizeX, SizeY, Len, PozX, PozY, Diam, Teeth, Hole (, ), [, ], ;}. Terminal words ( )[
] , and ; are used only to make sentences easier to read by people, so most often they will be
ignored on the derivation and syntax trees.
         Terminals PozX, PozY, SizeX, SizeY, Len, Diam, Hole and Teeth are parameters. SizeX
used to specify the number of pegs on the LEGO piece in the X direction. SizeY used to specify
the number of pegs on the LEGO piece in the Y direction. Terminals PozX and PozY describe
the location of the peg on the LEGO Block by giving its coordinates relative to the origin of the
Block. PozX can alternate between 1 and SizeX of the Block. PozY can alternate between 1 and
SizeY of the Block. SizeX and SizeY belong to the set {1, 2, 4, 6, 8, 10, 12, 16}. This set can be
modified according to the LEGO brick standards. Len used to specify the number of pegs on the
LEGO Beam or the length of an Axle measured in the peg sizes. It belongs to the set {2, 4, 6, 8,
10, 12, 16}. Hole defines the number of the hole in the Beam in to which Axle is inserted. It can
alternate between 1 and (Len - 1). Diam reflects the diameter of the wheel and belongs to the set
{17, 30, 43}. Teeth represent the number of teeth on the LEGO Gear. This number also
uniquely defines the diameter of the Gear. It belongs to the set {8, 16, 24, 40}
         MECHANISM,  Module,  Element,  Block,  Disk,  Pole, Beam, Brick, Plate,
Battery, Motor, Wheel, Gear and Axle are the nodes of the graph grammar. Module is
representing the number of Elements connected together. Element represents a single LEGO
peace. Grammar includes three categories of LEGO elements, namely Block, Disk and Pole.
Block represents a rectangular LEGO peace with pegs on one side. It is obvious that Brick and
Plate are the LEGO Blocks with N*M size, where N and M can range from 1 to 16. However
Brick is 3 times higher than Plate. Beam is the LEGO Block with 1*N size, where N can range
from 2 to 16. Beam has the same height as a Brick but it also has holes in it. Battery and Motor
also belong to the Block category, but they have some special properties. Battery size is (14 ,4) or
(4,14) and it is 4 Bricks high (12 LEGO heights units) . Motor size is (5,4) or (4,5) and it is 2
Bricks and one Plate high (12 LEGO heights units). Also Wheel and Gear can be attached to the
Motor.
        Relative sizes of the Battery and Motor shown on the second picture.




        Wheel and Gear are two types of Disks. I believe their names are self-explanatory.
Only Axle belongs to the category of Pole, but this category may be extended when more LEGO
pieces are added to the grammar. Examples of all Elements are shown on the first picture.
         Connect, Snap,  Insert,  TInsert and  GTrans are the edges. Snap is directed
edge. It represents the way Blocks are connected together. Arrow is pointing from the Block
which provides pegs to the Block that provides connection surfaces. Snap connection defined
by one or two PegPairs. If connection established over 1 peg than one BorderPair (special type of
PegPair) is used to define the connection. If connection established over 2 or more pegs than two
PegPairs are used to define the connection. PegPair is used to define the Pair of corresponding
pegs in the connection [(PozX1, PozY1); (PozX2, PozY2)].
        Illustration of the peg coordinates is shown in the third picture.




        (PozX1, PozY1) defines the peg on the Block witch provides pegs and (PozX2, PozY2)
defines the peg on the Block which provides connection surface. . So peg on the Block Snap is
pointing to always defined second in the PegPare.
        Example of the Snap connection is shown on the forth picture.




         Insert is undirected edge. It represents the way Axle is connected to the Beam. First
parameter of the  Insert is number of Hole in which Axle is inserted. Second is the distance
from the point of origin of an Axle to the connection in LEGO peg units. Example of the  Insert
connection is shown on the fifth picture.




         TInsert is undirected edge. It represents the way Axle or Motor is connected to the
Gear or Wheel. TInsert stands for tight insert. Parameter of the  TInsert is the distance from the
point of origin of an Axle to the connection in LEGO peg units. Example of the  TInsert
connection is shown on the sixth picture.
          GTrans is undirected edge. It represents the way two Gears are connected together.
GTrans stands for gear transmission. GTrans does not have any parameters, but it constrains
relative positioning of the Axles to which gears are attached. In order to validate GTrans one
should calculate the distance between candidate Axles and than locate the closest value in the
Distance table. Connection is valid if and only if the difference between these values less than 1
mm.
         Table of Distances between axles for different gear connections:
    Gear 1 (#Teeth)               Gear 2 (#Teeth)                   Distance (mm)
40                                40                                40
40                                24                                32
40                                16                                28
40                                8                                 24
24                                24                                24
24                                16                                20
24                                8                                 16
16                                16                                16
16                                8                                 12
8                                 8                                 8




          Example of the  GTrans connection is shown on the seventh picture.




         Distances between axles can be calculated from the chart presented below. All valid Axle
locations shown as a red dot and X*Y distances specified on the axis. Couple valid positionings is
shown for 40 to 40 and 8 to 16 teeth Gear connections.
Axles positioning chart:



                                               39
                                               36
                                               33
       Distance Between Holes in Y Direction
                                               30
                                               27
                                               24
                                               21
                                               18
                                               15
                                               12




                                                                                               8*16 teeth
                                                9
                                                6
                                                3           40*40 teeth
                                                0
                                                    0   8     16     24     32 40         48                56   64
                                                            Distance Between Holes in X Direction
This Grammar has following roles:
 MECHANISM        =>         Module
 Module     =>     Module        or       Element
                    Connect
                    Module

 Module     =>     Module        or       Module
                    Connect
 Module            Module                 Module

 Element    =>     Block         or       Disk or         Pole

 Block      =>     Block       or         Block
 Connect           Snap [BorderPair]      Snap [PegPair, PegPair]
 Block             Block                  Block

 Disk       =>     Gear (Teeth, 1)       or        Gear (1, Teeth)      or
 Connect           GTrans                          GTrans
 Disk              Gear (Teeth, 1)                 Gear (1, Teeth)

 Element    =>     Beam (Len, 1)         or        Beam (1, Len)        or
 Connect           Insert [Hole ,Len]              Insert [Hole, Len]
 Pole              Axle (1, Len)                   Axle (Len, 1)
                    Wheel (Diam, 1)       or        Wheel (1, Diam)      or
                    TInsert [Len]                   TInsert [Len]
                    Axle (1, Len)                   Axle (Len, 1)
                    Gear (Teeth, 1)       or        Gear (1, Teeth)
                    TInsert [Len]                   TInsert [Len]
                    Axle (1, Len)                   Axle (Len, 1)

 Disk       =>     Motor (4, 5)          or        Motor (5, 4)         or
 Connect            TInsert [1]                    TInsert [1]
 Motor             Wheel (Diam, 1)                 Wheel (1, Diam)
                    Motor (4, 5)          or        Motor (5, 4)         or
                     TInsert [1]                    TInsert [1]
                    Gear (Teeth, 1)                 Gear (Teeth, 1)

 Pole       =>     Axle (Len, 1) where Len  {2, 4, 6, 8, 10, 12, 16}    or
                    Axle (1, Len) where Len  {2, 4, 6, 8, 10, 12, 16}


 Disk       =>     Wheel (Diam, 1) where Diam  {17, 30, 43} or
                    Wheel (1, Diam) where Diam  {17, 30, 43} or
                    Gear (1, Teeth) where Teeth  {8, 16, 24, 40} or
                    Gear (Teeth,1) where Teeth  {8, 16, 24, 40}
 Block      =>     Beam (Len, 1) where Len  {2, 4, 6, 8, 10, 12, 16}      or
                    Beam (1, Len) where Len  {2, 4, 6, 8, 10, 12, 16}      or
                    Motor (4,5)             or      Motor (5,4)            or
                    Battery (14,4)          or      Battery (4,14)         or
                    Beam (1, Len) where Len  {2, 4, 6, 8, 10, 12, 16}      or
                    Plate (SizeX, SizeY) where SizeX, SizeY  {1, 2, 4, 6, 8, 10,
                   12, 16}                                                   or
                    Brick (SizeX, SizeY) where SizeX, SizeY  {1, 2, 4, 6, 8, 10, 12,
                   16}

PegPair      =>   (PozX, PozY); (PozX, PozY) where PozX  {1.. SizeX}, PozY 
                  {1.. SizeY} for each Block
BorderPair   =>   (1, PozY); (SizeX, PozY)          or
                  (SizeX, PozY); (1, PozY)          or
                  (PozX, 1); (PozX, SizeY)          or
                  (PozX, SizeY); (PozX, 1) where SizeX, SizeY  {1, 2, 4, 6, 8, 10,
                  12, 16} PozX  {1.. SizeX}, PozY  {1.. SizeY} for each Block
                               Example of the Mechanism with a Assembly Graph.

                                        M ECHANISM                                                                                      LEGEND
                                                                                                                                           Beam


                                                                                                                                           Plate


                                                                                                                                           Brick


                                                                                                                                           Wheel


                                                                                                                                           Gear


                                                                                                                                           Axle


                                                                                                                                          Motor


                                                                                                                                          Battery



                                                         Assembly Graph

             GT rans                       T Insert[1]
                                                                                                                         Insert[7]
Gear(40)                    Gear(8)                          Motor(5,4)                     Beam(1,2)                                      Wheel(44)
                                                                                                                                           T Insert[1]
                                                           Snap[(6,1)(5,1);(2,1)(1,1)]            Snap[(1,1)(1,13);(1,2)(1,14)]




            T Insert[8]                 Snap[(1,1)(1,1);(1,2)(1,2)]                      Snap[(6,1)(5,1);(2,1)(1,1)]

                                                                                                                                           Axle(8,1)
Wheel(30)                  Beam(1,2)                                    Plate(6,8)                                      Battery(4,14)
                                                                                                                                           T Insert[8]
                            Insert[2]                      Snap[(1,1)(6,1);(2,1)(2,6)]            Snap[(1,1)(4,13);(1,2)(4,14)]
            T Insert[1]
                                                                                                                         Insert[2]


                                            Insert[7]


Wheel(30)   T Insert[10]   Axle(10,1)                        Beam(1,2)                      Beam(1,2)                                      Wheel(44)
ASSEM BLY GRAPH DERIVATION   LEGEND
                                 Derives

                                Derives
                                (several steps)
                                 Connect
                                 Snap

                                 Mechanism


                                 Module


                                 Element


                                 Block


                                Disk


                                 Pole


                                 Beam


                                 Plate


                                 Brick


                                 Wheel


                                 Gear


                                 Axle

                                 Motor


                                 Battery
             GT rans                       T Insert[1]
                                                                                                                        Insert[7]
Gear(40)                    Gear(8)                          Motor(5,4)                     Beam(1,2)                                   Wheel(44)
                                                                                                                                        T Insert[1]
                                                           Snap[(6,1)(5,1);(2,1)(1,1)]            Snap[(1,1)(1,13);(1,2)(1,14)]




            T Insert[8]                 Snap[(1,1)(1,1);(1,2)(1,2)]                      Snap[(6,1)(5,1);(2,1)(1,1)]

                                                                                                                                        Axle(8,1)
Wheel(30)                  Beam(1,2)                                    Plate(6,8)                                      Battery(4,14)
                                                                                                                                        T Insert[8]
                            Insert[2]                      Snap[(1,1)(6,1);(2,1)(2,6)]            Snap[(1,1)(4,13);(1,2)(4,14)]
            T Insert[1]
                                                                                                                        Insert[2]

                                            Insert[7]


Wheel(30)   T Insert[10]   Axle(10,1)                        Beam(1,2)                      Beam(1,2)                                   Wheel(44)

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:8/12/2012
language:English
pages:12