Graphics Reference
In-Depth Information
{ Use symmetry to reduce to LeftBottom case }
y1 := -y1; y2 := -y2; { reflect about x-axis }
LeftBottom (xmin,-ymax,xmax, -ymin,x1,y1,x2,y2,visible);
y1 := -y1; y2 := -y2; { reflect back }
end
else
begin
dx := x2 - x1; dy := y2 - y1;
if x2 > xmax then
begin
y2 := y1 + dy*(xmax - x1)/dx; x2 := xmax;
end ;
y1 := y1 + dy*(xmin - x1)/dx; x1 := xmin;
visible := true ;
end
end ;
procedure LeftBottom ( real xmin, ymin, xmax, ymax;
ref real x1, y1, x2, y2; ref boolean visible)
begin
real dx, dy, a, b, c;
dx := x2 - x1;
dy := y2 - y1;
a := (xmin - x1)*dy;
b := (ymin - y1)*dx;
if b > a
then visible := false { (x2,y2) is below ray from (x1,y1) to bottom left corner }
else
begin
visible := true ;
if x2 < xmax
then
begin
x2 := x1 + b/dy; y2 := ymin; end
else
begin
c := (xmax - x1)*dy;
if b > c
then { (x2,y2) is between rays from (x1,y1) to
bottom left and right corner }
begin
x2 := x1 + b/dy; y2 := ymin;
end
else
begin
y2 := y1 + c/dx; x2 := xmax; end
end ;
end ;
y1 := y1 + a/dx; x1 := xmin;
end ;
Algorithm 3.2.4.1. Continued
Search WWH ::




Custom Search