%donald # The following definitions define a room ... # ... and some objects inside the room. # They are expressed in DoNaLD: a definitive (definition-based) # notation for line drawing developed at the University of ÌÇÐÄTV # The room is rectangular in shape. int width, length # the dimensions of room point NW, NE, SW, SE # the 4 corners of room line N1, N2, S, E, W # the 4 walls of room # North wall composed of 2 walls & a door ### Every room has a door ### openshape door # declare the door within door { point hinge, lock # a door has a hinge, and a lock line door # the door itself is defined by a line int width # the size of the door boolean open # open is a flag, specifying whether ... # ... the door is open door = [hinge, lock] lock = hinge + (if open then {0, -width} else {width, 0}) } within door { hinge = ~/NW + {15, -10} # set the coordinates of the hinge open = true # the door is open width = 200 # the size of the door is assigned } N1 = [NW, {door/hinge.1, NW.2}] N2 = [{door/hinge.1+door/width, NW.2}, NE] S = [SW, SE] W = [NW, SW] E = [NE, SE] SW = {100, 100} SE = SW + {width, 0} # The other 3 corners are relative NE = SW + {width, length} # to the South-West corner. NW = SW + {0, length} # width, length = 800, 800 # 800*800 pts ########################################################################### openshape table # There is a table inside the room. within table { int width, length # the dimensions of table point NW, NE, SW, SE # the 4 corners of table line N, S, E, W # the 4 sides of table N = [NW, NE] S = [SW, SE] W = [NW, SW] E = [NE, SE] SE = SW + {width, 0} # the other 3 corners are NE = SW + {width, length} # relative to the SW corner NW = SW + {0, length} # ##### table/lamp ##### openshape lamp # There is a lamp on the table within lamp { circle base # base of the lamp point centre # centre of the table int size # size of the lamp int half # half of size size = 50 half = size div 2 centre = (~/SW + ~/NE) div 2 # at the centre of table # lines L1-L8 form an octagon. line L1, L2, L3, L4, L5, L6, L7, L8 L1 = [centre + {size, -half}, centre + {size, half}] L2 = [L1.2, centre + {half, size}] L3 = [L2.2, centre + {-half, size}] L4 = [L3.2, centre + {-size, half}] L5 = [L4.2, centre + {-size, -half}] L6 = [L5.2, centre + {-half, -size}] L7 = [L6.2, centre + {half, -size}] L8 = [L7.2, L1.1] base = circle(centre, size * 3 div 2) } } within table { # let the size of table be 300*300 pts. width, length = 300, 300 # place the SW of table at the centre of the room. SW = (~/SW + ~/NE) div 2 } ########################################################################### point plug point plug1, plug2 # there are 2 plugs. plug1 = (S.1+S.2) div 2 # plug1 is at the middle of the South wall plug2 = (E.1+E.2) div 2 # plug2 is at the middle of the East wall line cable # a cable connects the table/lamp and the plug int cablelength cable = [plug, table/lamp/centre] plug = plug1 # the cable is connected to plug1 cablelength = 600 # # Now set the line style of cable be dotted line. # Because many Donald commands hasn't implemented, # I just directly access Eden using the non-standard `?' command. ? A_cable = "linestyle=dashed,dash=13"; ########################################################################### openshape desk # there is a desk in the room within desk { int width, length # the size of the desk point NW, NE, SW, SE # the 4 corners of the desk line N, S, E, W # the 4 edges of the desk N = [NW, NE] S = [SW, SE] W = [NW, SW] E = [NE, SE] width, length = 250, 350 # initially the desk is placed at (100,100) of the room. SW = ~/SW + {15, 15} SE = SW + {width, 0} # the other 3 corners are ... NW = SW + {0, length} # ... relative to SW corner NE = NW + {width, 0} # ##### desk/drawer ##### openshape drawer # the desk has a drawer within drawer { int k # k -- a parameter describes # the condition of drawer # 1 --> closed # larger k --> more open int width, length # the size of drawer point NW, NE, SW, SE # the 4 corners of the drawer line N, S, W, E # the 4 edges of the drawer # the size of the drawer is always a ratio to ... # ... the desk. width = ~/length div 3 length = ~/width - ~/width div k k = 2 # initially, the draw is half open NW = ~/NE # NW is always at desk's NE SW = NW - {0, width} # the other 3 corners are ... SE = SW + {length, 0} # ... relative to NW NE = NW + {length, 0} # N = [NW, NE] S = [SW, SE] W = [NW, SW] E = [NE, SE] } } %boolean doorHitTable, cableIsShort %monitor mon1 = doorHitTable, "table obstructs door", "" %monitor mon2 = cableIsShort, "cable is not long enough", "" %doorHitTable = includes(circle(door/hinge, door/width),table/NW) %cableIsShort = dist(cable.1, cable.2) > cablelength