1 \chapter{Appendix}\label{appendix}\index{Appendix}%
2 \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
5 \section{Simple Graphics Package}\index{Simple Graphics Package}%
8 Simple Graphics Package was created in 1980 by Kevin Rosenberg and
9 is modelled after the graphics library in Foley and van
13 +------------------------+
14 | World Coordinate level |
15 +-----------+------------+
17 +-------------+-------------+
18 | Clipping against Window() |
19 +-------------+-------------+
21 +------------+-------------+
22 | Convert to Normalized |
23 | device coordinates (NDC) |
24 +------------+-------------+
26 +-------------+-------------+
27 | Clipping against Viewport |
28 +-------------+-------------+
30 +------------+-------------+
31 | Convert to Physical |
32 | device coordinates (PDC) |
33 +--------------------------+
36 \subsection{Functions}%
38 \subsubsection{World Coordinate Level}
40 \twocolitem{initgrf2}{Initialize 2 dimensional graphics}
41 \twocolitem{termgrf2}{Terminate 2 dimensional graphics}
42 \twocolitem{setColor(color)}{Set current drawing color}
43 \twocolitem{setLinestyle (style)}{Set current line style}
44 \twocolitem{setLinewidth (width)}{Set current line width}
45 \twocolitem{setTextColor (foreground, background)}{If back=-1,
46 then transparent} \twocolitem{setMarker (type, color)}{Set marker
50 \subsubsection{State Commands}
52 \twocolitem{Window(xmin, ymin, xmax, ymax)}{Set window for world
53 coordinates} \twocolitem{MoveAbs(x, y)}{Move graphics cursor}
54 \twocolitem{MoveRel(dx, dy)}{} \twocolitem{PointAbs (x, y)}{Plot
55 point at current position} \twocolitem{PointRel (dx, dy)}{}
56 \twocolitem{LineAbs2 (x, y)}{Draw line from current point to
57 point} \twocolitem{LineRel2 (dx, dy)}{} \twocolitem{MarkerAbs2 (x,
58 y)}{Draw marker at current position} \twocolitem{MarkerRel2 (dx,
59 dy)}{} \twocolitem{PolylineAbs (x[], y[], n)}{Draw a set of lines}
60 \twocolitem{PolylineRel (dx[], dy[], n)}{}
61 \twocolitem{wc\_to\_ndc(xwc, ywc, xndc, yndc)}{Convert from world
62 coord to NDC} \twocolitem{ndc\_to\_wc(xndc, yndc, xwc,
63 ywc)}{Convert from NDC to world coord} \twocolitem{DrawText
64 (str)}{Draw text string at current positon}
68 \subsubsection{Normalized Coordinate level}%
70 \twocolitem{Viewport (xmin, ymin, xmax, ymax)}{Viewport for window
71 in NDC} \twocolitem{stylus (x, y, beam)}{Draw a line from current
72 position} \twocolitem{markerNDC(xndc, yndc)}{Draw marker at NDC
77 \subsection{Coordinate Mapping}
79 \subsubsection{Mapping from world coordinates to physical device coordinates}%
81 Window (World Coordinates): $X_{wmin}, X_{wmax}, Y_{wmin}, Y_{wmax}$ \\
82 Viewport (Normalized Device Coordinates): $X_{vmin}, X_{vmax}, Y_{vmin}, Y_{vmax}$\\
83 Physical (Physicial Device Coordinates): $X_{pmax}, Y_{pmax}$\\
85 To convert from WC to NDC:\\
87 X_{ndc} = X_{vmin} + (X_{vmax} - X_{vmin}) (X_{wc} - X_{wmin}) / (X_{wmax} - X_{wmin})
90 Y_{ndc} = Y_{vmin} + (Y_{vmax} - Y_{vmin}) (Y_{wc} - Y_{wmin}) / (Y_{wmax} - Y_{wmin})
93 To convert from NDC to PDC:
95 X_{pdc} = X_{ndc} X_{pmax}
98 Y_{pdc} = X_{ndc} Y_{pmax}