unit hplt; interface { Homogeneous coordinate plotting. Notation used in the comments below: [w x y] = point with Cartesian coordinates (x/w, y/w). = line with Cartesian equation Xx +Yy + W = 0. } procedure hplt_draw_line(W, X, Y: real; width: real; grey: real); { Plots the line , with the given /width/. } procedure hplt_draw_point(w, x, y: real; size: real; grey: real); { Plots a point [w x y], as a circle with diameter /size/. } procedure hplt_draw_segment( w1, x1, y1: real; w2, x2, y2: real; width: real; grey: real ); { Plots the line segment from [w1 x1 y1] to [w2 x2 y2]. Assumes signed (two-sided) homogeneous coordinates, and plots only the positive (top) part of the segment, clipped to the plotting area. The two points must not be antipodal. } procedure hplt_paint_triangle( w1, x1, y1: real; w2, x2, y2: real; w3, x3, y3: real; grey: real ); { Paints the interior of the given triangle with the given color. Assumes signed (two-sided) homogeneous coordinates, and plots only the positive (top) part of the triangle, clipped to the plotting area. No two vertices may be antipodal, and no vertex may be antipodal to any point between the other two. } implementation uses P9; procedure hplt_draw_point(w, x, y: real; size: real; grey: real); label 999; { End of procedure. } begin write('.'); new_command('draw_point'); set_pen_size('draw_point', size); set_grey('draw_point', grey); { Clip coordinates: } if w = 0.0 then goto 999; if abs(w) > 1.0 then begin if abs(x/w) > x_max + size/2.0 then goto 999; if abs(y/w) > y_max + size/2.0 then goto 999; end else begin if abs(x) > (x_max + size/2.0) * abs(w) then goto 999; if abs(y) > (y_max + size/2.0) * abs(w) then goto 999; end; ps_draw_point(cur_file, x/w, y/w); 999: end; procedure hplt_draw_line(W, X, Y: real; width: real; grey: real); var x1, y1, w1, x2, y2, w2: real; label 999; { End of procedure. } begin write('|'); new_command('draw_line'); set_pen_size('draw_line', width); set_grey('draw_line', grey); { Clip line to window: } 999: end; procedure hplt_draw_segment( w1, x1, y1: real; w2, x2, y2: real; width: real; grey: real ); label 999; { End of procedure. } begin write('-'); new_command('draw_segment'); set_pen_size('draw_segment', width); set_grey('draw_segment', grey); { Clip segment to window: } {???} { Plot it: } ps_draw_segment(cur_file, x1/w1, y1/w1, x2/w2, y2/w2); 999: end; procedure hplt_paint_triangle( w1, x1, y1: real; w2, x2, y2: real; w3, x3, y3: real; grey: real ); label 999; { End of procedure. } begin write('v'); new_command('paint_triangle'); set_grey('paint_triangle', grey); { Clip triangle to window: } {???} { Plot it: } ps_paint_triangle(cur_file, x1/w1, y1/w1, x2/w2, y2/w2, x3/w3, y3/w3); 999: end; end.