r521: no message
[ctsim.git] / doc / ctsim-appendix.tex
1 \chapter{Appendix}\label{appendix}\index{Appendix}%
2 \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
3 \setfooter{\thepage}{}{}{}{}{\thepage}%
4
5 \section{Simple Graphics Package}\index{Simple Graphics Package}%
6
7 \subsection{Overview}%
8 Simple Graphics Package was created in 1980 by Kevin Rosenberg and
9 is modelled after the graphics library in Foley and van
10 Dam\cite{FOLEY82}.
11
12 \begin{verbatim}
13                        +------------------------+
14                        | World Coordinate level |
15                        +-----------+------------+
16                                    |
17                      +-------------+-------------+
18                      | Clipping against Window() |
19                      +-------------+-------------+
20                                    |
21                       +------------+-------------+
22                       | Convert to Normalized    |
23                       | device coordinates (NDC) |
24                       +------------+-------------+
25                                    |
26                      +-------------+-------------+
27                      | Clipping against Viewport |
28                      +-------------+-------------+
29                                    |
30                       +------------+-------------+
31                       | Convert to Physical      |
32                       | device coordinates (PDC) |
33                       +--------------------------+
34 \end{verbatim}
35
36 \subsection{Functions}%
37
38 \subsubsection{World Coordinate Level}
39 \begin{twocollist}
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
47 attibutes}
48 \end{twocollist}
49
50 \subsubsection{State Commands}
51 \begin{twocollist}
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}
65 \end{twocollist}
66
67
68 \subsubsection{Normalized Coordinate level}%
69 \begin{twocollist}
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
73 position}
74 \end{twocollist}
75
76
77 \subsection{Coordinate Mapping}
78
79 \subsubsection{Mapping from world coordinates to physical device coordinates}%
80
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}$\\
84
85 To convert from WC to NDC:\\
86 \begin{equation}
87      X_{ndc} = X_{vmin} + (X_{vmax} - X_{vmin})  (X_{wc} - X_{wmin}) / (X_{wmax} - X_{wmin})
88 \end{equation}
89 \begin{equation}
90      Y_{ndc} = Y_{vmin} + (Y_{vmax} - Y_{vmin}) (Y_{wc} - Y_{wmin}) / (Y_{wmax} - Y_{wmin})
91 \end{equation}
92
93 To convert from NDC to PDC:
94 \begin{equation}
95      X_{pdc} = X_{ndc} X_{pmax}
96 \end{equation}
97 \begin{equation}
98      Y_{pdc} = X_{ndc} Y_{pmax}
99 \end{equation}