%eden
## initially set the pen up
## execute following commands to get to bottom left corner at {50,50}
%logo
pen up
backward 200
left 90
forward 200
right 90
%eden
## set pen down with pen colour black
%logo
pen down
forward 400
right 90
forward 10
right 90
forward 100
%eden
## set pen up
%logo
pen up
backward 100
left 90
forward 100
%eden
## set pen down with pen colour black
%logo
pen down
forward 300
right 90
forward 400
right 90
forward 400
%eden
## leads to error: didn't correctly compute the length from the door lock to the NE corner
/*
I have made a mistake: I try to correct this using undo()
*/
%eden
undo();
## BUT - only one undo is possible! (it affects line l6 as explained below)
/*
To undo more radically, we can fish out the donald definitions of the lines that are being drawn, and redraw them ...
... consulting the donald definitions, we find that they are:
l6 = [{460.000000, 50.000000}, {60.000000, 50.000000}]
l5 = [{460.000000, 450.000000}, {460.000000, 50.000000}]
l4 = [{160.000000, 450.000000}, {460.000000, 450.000000}]
... but they really should have been as above with 460 replaced by 450 in every definition. Hence we make the redefinition:
Note that the effect of the previous undo was to redefine the attributes of
l6 = [{460.000000, 50.000000}, {60.000000, 50.000000}]
so that it became transparent
*/
%donald
l6 = [{450.000000, 50.000000}, {50.000000, 50.000000}]
l5 = [{450.000000, 450.000000}, {450.000000, 50.000000}]
l4 = [{160.000000, 450.000000}, {450.000000, 450.000000}]
%eden
A_l6="color=black";
## the Logo turtle is in the wrong place!
/* fix this by finding out how the Logo turtle is modelled - this is done by:
_turtle_pos is cart(turtle_x, turtle_y);
The eden variables turtle_x and turtle_y are integers: so relocate via:
*/
turtle_x = 450;
## resume the room defining:
%logo
forward 400
pen up
right 90
forward 200
%eden
/*
I make some more mistakes at this point - and try to undo. The effect is to eliminate the last line drawn from the display - the S wall of the room (undo doesn't really apply to actions that don't draw lines!). This still appears in the donald definitions, but it turns out that the line has been set to be transparent. I fix these problems by
- setting the line colour to black
- relocating the turtle by directly redefining the turtle coordinates in eden
- reorienting as necessary (in my case, my error introduced a spurious extra right turn
- fixing the orientation of the turtle
involves redefining angle in eden
(to an integer value)
*/
%logo
right 90
forward 200
pen down
forward 150
left 90
forward 150
left 90
forward 150
left 90
forward 150
left 90
forward 150
left 90
forward 150
left 90
pen up
forward 75
left 90
forward 75
/*
At this point, I think about drawing the cable, and recognise many of the difficulties
- calculating the direction - which is arctan (325-50)/(325-250)
- calculating the distance
and worrying about how to cope with the non-integral distance and its effects
I proceed instead to try to draw the octagonal part of the lamp
*/
%logo
right 180
forward 25
right 90
forward 12
%eden
## not the ideal place intend 12.5?
%logo
pen down
right 45
forward 25
right 45
forward 25
right 45
forward 25
right 45
forward 25
right 45
forward 25
right 45
forward 25
right 45
forward 25
right 45
forward 25
pen up
backward 12
right 90
forward 25
forward 12
/*
It's now clear that this isn't right: the original octagon in the table_lamp is not a regular octagon - the sides alternate in length between 50 and sqrt(1250), which is about 35.36
The kind of calculations that we now need to do to draw the cable: approximating, we would ideally have the current position of the turtle at {325,325} - it's actually {325, 313}
writeln(atan(75.0/263.0)*180/PI);
This gives an angle of about 19.4 degrees
writeln(sqrt(75.0*75.0+263.0*263.0));
This gives a distance of about 273.49
Can use these to estimate how to draw the cable using logo
*/
%logo
pen down
right 15
forward 273
%eden
## current turtle position is about {254, 49} which is close to the midpoint of the S wall of the room
hdturtle();
A_l22="color=red";