\chapter{Appendix}\label{appendix}\index{Appendix}%
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%

\section{Simple Graphics Package}\index{Simple Graphics Package}%

\subsection{Overview}%
Simple Graphics Package was created in 1980 by Kevin Rosenberg and
is modelled after the graphics library in Foley and van
Dam\cite{FOLEY82}.

\begin{verbatim}
                       +------------------------+
                       | World Coordinate level |
                       +-----------+------------+
                                   |
                     +-------------+-------------+
                     | Clipping against Window() |
                     +-------------+-------------+
                                   |
                      +------------+-------------+
                      | Convert to Normalized    |
                      | device coordinates (NDC) |
                      +------------+-------------+
                                   |
                     +-------------+-------------+
                     | Clipping against Viewport |
                     +-------------+-------------+
                                   |
                      +------------+-------------+
                      | Convert to Physical      |
                      | device coordinates (PDC) |
                      +--------------------------+
\end{verbatim}

\subsection{Functions}%

\subsubsection{World Coordinate Level}
\begin{twocollist}
\twocolitem{initgrf2}{Initialize 2 dimensional graphics}
\twocolitem{termgrf2}{Terminate 2 dimensional graphics}
\twocolitem{setColor(color)}{Set current drawing color}
\twocolitem{setLinestyle (style)}{Set current line style}
\twocolitem{setLinewidth (width)}{Set current line width}
\twocolitem{setTextColor (foreground, background)}{If back=-1,
then transparent} \twocolitem{setMarker (type, color)}{Set marker
attibutes}
\end{twocollist}

\subsubsection{State Commands}
\begin{twocollist}
\twocolitem{Window(xmin, ymin, xmax, ymax)}{Set window for world
coordinates} \twocolitem{MoveAbs(x, y)}{Move graphics cursor}
\twocolitem{MoveRel(dx, dy)}{} \twocolitem{PointAbs (x, y)}{Plot
point at current position} \twocolitem{PointRel (dx, dy)}{}
\twocolitem{LineAbs2 (x, y)}{Draw line from current point to
point} \twocolitem{LineRel2 (dx, dy)}{} \twocolitem{MarkerAbs2 (x,
y)}{Draw marker at current position} \twocolitem{MarkerRel2 (dx,
dy)}{} \twocolitem{PolylineAbs (x[], y[], n)}{Draw a set of lines}
\twocolitem{PolylineRel (dx[], dy[], n)}{}
\twocolitem{wc\_to\_ndc(xwc, ywc, xndc, yndc)}{Convert from world
coord to NDC} \twocolitem{ndc\_to\_wc(xndc, yndc, xwc,
ywc)}{Convert from NDC to world coord} \twocolitem{DrawText
(str)}{Draw text string at current positon}
\end{twocollist}


\subsubsection{Normalized Coordinate level}%
\begin{twocollist}
\twocolitem{Viewport (xmin, ymin, xmax, ymax)}{Viewport for window
in NDC} \twocolitem{stylus (x, y, beam)}{Draw a line from current
position} \twocolitem{markerNDC(xndc, yndc)}{Draw marker at NDC
position}
\end{twocollist}


\subsection{Coordinate Mapping}

\subsubsection{Mapping from world coordinates to physical device coordinates}%

Window (World Coordinates):  $X_{wmin}, X_{wmax}, Y_{wmin}, Y_{wmax}$ \\
Viewport (Normalized Device Coordinates): $X_{vmin}, X_{vmax}, Y_{vmin}, Y_{vmax}$\\
Physical (Physicial Device Coordinates): $X_{pmax}, Y_{pmax}$\\

To convert from WC to NDC:\\
\begin{equation}
     X_{ndc} = X_{vmin} + (X_{vmax} - X_{vmin})  (X_{wc} - X_{wmin}) / (X_{wmax} - X_{wmin})
\end{equation}
\begin{equation}
     Y_{ndc} = Y_{vmin} + (Y_{vmax} - Y_{vmin}) (Y_{wc} - Y_{wmin}) / (Y_{wmax} - Y_{wmin})
\end{equation}

To convert from NDC to PDC:
\begin{equation}
     X_{pdc} = X_{ndc} X_{pmax}
\end{equation}
\begin{equation}
     Y_{pdc} = X_{ndc} Y_{pmax}
\end{equation}
