Casey Muller - Problem Set #1
 
Part 1
p1.dbn
paper 70
pen 30
line 60 50 59 53
line 59 53 58 55
line 58 55 55 58
line 55 58 53 59
line 53 59 50 60
line 50 60 46 59
line 46 59 44 58
line 44 58 41 55
line 41 55 40 53
line 40 53 40 50
line 40 50 40 46
line 40 46 60 20
line 60 20 61 18
line 61 18 64 15
line 64 15 66 14
line 66 14 69 14
line 69 14 73 14
line 73 14 75 15
line 75 15 78 18
line 78 18 79 20
line 79 20 80 24
line 80 24 80 70
// Sorry, I couldn't resist using the fact that you never said straight line on
// at least one assignment. I played it straight on the rest.
// to generate the circles I whipped up this perl program:
// run it, then type "x y radius step" to generate the circle, where step
// gets multiplied by pi.
// #!/usr/bin/perl
// $pi = 3.1415926;
// while(<>) {
// chop;
// ($cx,$cy,$radius,$step)=split;
// print "($cx,$cy) $radius $step\n";
// ($rx,$ry) = ($cx+$radius,$cy);
// for($i=$step*$pi;$i <= 2*$pi;$i+=$step*$pi)
//         {
//         ($ox,$oy) = ($rx,$ry);
//         ($rx,$ry) = (int($cx+$radius*cos($i)),int($cy+$radius*sin($i)));
//         print "line $ox $oy $rx $ry\n";
//         }
// print "line $rx $ry ",($cx+$radius)," $cy\n\n\n";
// }

Create a program to draw a carefully chosen one line on a paper of your choice.
 
Part 2
p2.dbn
paper 30
pen 50
set A 15
// I want my three As to be: 15, 20, 25
line (20+A) 30 (10+A*3) 30
line (10+A*3) 40 50 (90-A*2)
line (15+A*2) 35 (80-A*2) 20

Create a program that uses one variable as a means to control a set of 3 lines. Capture 3 instances of the graphic (A,B,C).
 
Part 3
p3.dbn
paper 10
pen 80
repeat A 10 40
{
   pen (A*2+20)
   line (50+A) (20+A) (A+30) (40+A) 
}
// why stay parallel to the walls?


Create a program to draw a single filled rectangle. Again, choose carefully.
 
Part 4
p4.dbn
paper 10
repeat A 10 70
{
   pen (A*A/30-A+40)
   line 25 30 (A+10) 70
}


Create a program to draw a single filled triangle. Use your good judgement.
 
Part 5
p5.dbn
// I interpreted this as being different from 4 in that
// we were supposed to simulate the way we'd draw a triangle
// in real life
paper 5
pen 100
line 20 30 70 80
line 70 80 70 10
line 70 10 20 30
pen 60
repeat A 20 72
{
   pen (90-A*2/3)
   line A (30-(A-20)/(5/2)) A (30+(A-20)*8/7) 
}



Think of all the ways you can draw a filled triangle, and choose one. Utilize the properties of the drawing method you choose, to create a single filled triangle.
 
Part 6
p6.dbn
paper 0
// modifying paper a little:
pen 2
repeat a 0 100
{
line a (100-a) 100 a
}

// paper done, dots now:

pen 100
set [30 20] 100
set [25 25] 100
set [35 20] 100
set [25 30] 100

pen 99
set [75 75] 100

Set 5 dots on a paper of your choice. Evoke an emotion with your choice in placement of dots.
 
Part 7
p7.dbn
paper 0
pen 100


repeat a 15 30
{
set [40 (a*2)] 100
set [60 (a*2)] 100
}

repeat a 30 20
{
set [((a-20)*15/10+25) (a*2)] 100
set [(75-(a-20)*15/10) (a*2)] 100
}

repeat a 22 35
{
set [((a-22)*20/13+20) (a*2+1)] 100
set [(80-(a-22)*20/13) (a*2+1)] 100
}

repeat a 40 45
{
set [a (69+(a-40)/5)] 100
}
repeat a 60 55
{
set [a (69-(a-55)/5)] 100
}


Create a representational picture (i.e. something that looks like something) using just 8 (at maximum) dotted lines.
 
Part 8
p8.dbn
paper 100

// if this is unacceptable (as it may well be),
// go to: http://web.mit.edu/casey/www/mas110/alternate.dbn
// and http://web.mit.edu/casey/www/mas110/alternate.gif
// for something more conventionally part of the assignment.

// IT'S STARFIELD TIME!
// This is designed to be viewed _while running_
// the still isn't nearly as impressive.
// Yes, it has lots of problems, but it does
// look cool while running (it's at least reminiscent
// of the screensaver), and it does fill the field with
// calculated values, as requested. Plus it was fun to 
// figure out and write. There are some inconsistancies 
// I can't understand, but I got it kludged together at
// least. Wish there were a random number generator.

// remember to try to imagine yourself moving. With so few
// stars, the illusion doesn't really work.

pen 0
command new X Y Z
{
   set [((X-50)*100/(Z)+50) ((Y-50)*100/(Z)+50)] 0
}
command old X Y Z
{
   set [((X-50)*100/Z+50) ((Y-50)*100/Z+50)] 73
}
set A 46
set B 59
set C 46

set D 54
set E 43
set F 92

set G 58
set H 61
set I 68

set J 43
set K 49
set L 13

set M 56
set N 50
set O 98

new A B C
new D E F
new G H I
new J K L
new M N O

forever
{
   old A B C
   old D E F
   old G H I
   old J K L
   old M N O

   set C (C-1)
   set F (F-1)
   set I (I-1)
   set L (L-1)
   set O (O-1)

   new A B C
   new D E F
   new G H I
   new J K L
   new M N O

   same? C 1
   {
      old A B C
      set C 100
      set A (A+D/H)
      set B (B-G/M)
   }

   same? F 1
   {
      old D E F
      set F 100
      set D (D-B/G)
      set E (E+H/J)
   }

   same? I 1
   {
      old G H I
      set I 100
      set G (G-K/N)
      set H (H-B/K)
   }

   same? L 1
   {
      old J K L
      set L 100
      set J (J+A/N)
      set K (K+E/M)
   }

   same? O 1
   {
      old M N O
      set O 100
      set M (M-K/D)
      set N (N-B/J)
   }

}


Using a nested loop, fill the entire field with the value of some calculation that can be appreciated. Do not use the Line command.
 
Part 9
p9.dbn
paper 0
pen 100

// The interesting part is C, which makes the Xs
// different sizes in a square (as in, to the second
// power) pattern.

repeat A 0 10
{
   repeat B 0 10
   {
      set [(A*10) (B*10)] 90
      set [(A*10+5) (B*10)] 60
      set [(A*10+4) (B*10+2)] 75
      set [(A*10+1) (B*10-4)] 60
      set [(A*10-1) (B*10+4)] 75
      set [(A*10-4) (B*10+2)] 60
      repeat C 0 10
      {
         set [(A*10*C+C) (B*10*C+C)] 100
         set [(A*10*C+C) (B*10*C-C)] 100
         set [(A*10*C-C) (B*10*C+C)] 100
         set [(A*10*C-C) (B*10*C-C)] 100
      }
   }
}

Using a nested loop, create a stippled pattern of dots that can be enjoyed for its complexity. Do not use the Line command.
 
Part 10
p10.dbn
paper 0
// I realize the shadow isn't that realistic
// it's fun to watch it draw.

// the surface

repeat A 0 55
{
   pen (25+20*A/55)
   line 0 A 100 A
}
// shadow 1
pen 100
repeat A 20 50
{
   line A 30 90 55
}
// shadow 2
repeat A 30 50
{
   line A 40 90 55
}
//box
pen 50
repeat A 20 50
{
   repeat B 30 60
   {
      line A B (A+10) (B+10)
   }
}
// emphasize front line
pen 51
line 20 60 50 60
// dark side of cube
pen 65
repeat A 30 60
{
   line 50 A 60 (A+10)
}



Using the Line command, and a (few) nested loop, create an image that evokes a three-dimensional feeling through shading.