|
Computer Graphics |
Fall 2000
|
Computer Graphics
Homework 04
6 hours
Copyright © 2000 David C. Banks
|
%! newpath 100 200 moveto 200 250 lineto 100 300 lineto 2 setlinewidth stroke showpage |
![]()
Create your own postscript file using lines and circles (arcs).
Create a viewpoint (small disk) and label it "viewpoint".
Create a light source (small disk) and label it "light".
Create a thick line and label it "object". Pick at least
3 points on the line; highlight each one (small disk) and
draw a ray (thin line) from it to the viewpoint and from
it to the light source. I've created an
example, which is shown at left.
Do not re-use my example. Set the viewpoint, light,
and segment endpoints to be your own choice. Print both
the raw postscript text and its ouput, and put them in
your notebook.
Write a program "reflection" that outputs postscript to produce an image like the one you made by hand. The program reads the command line for the 2D location of the light, the viewpoint, the endpoints of a segment, and the number of samples along the segment. Assume that the coordinate system goes from 0 to 1 in the x and y directions.
reflection view 0.2 0.3 light 0.1 0.2 line 0.8 0.5 0.6 0.4 samples 10 > reflection.ps
You might output a segment in postscript like this.
segment(float x1, float y1, float x2, float y2, float grayLevel)
{
printf("%f setgray\n", grayLevel);
printf("%f %f moveto \n%f %f lineto \nstroke\n",
x1, y1, x2, y2);
}