r500: no message
[ctsim.git] / doc / ctsim-appendix.tex
diff --git a/doc/ctsim-appendix.tex b/doc/ctsim-appendix.tex
new file mode 100644 (file)
index 0000000..c25c257
--- /dev/null
@@ -0,0 +1,105 @@
+\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 creates in 1983 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}%
+     initgrf2 ()                         Initialize 2 dimensional graphics\\
+     termgrf2 ()                         Terminate 2 dimensional graphics\\
+     Window  (xmin, ymin, xmax, ymax)   Set window for world coordinates\\
+     Viewport (xmin, ymin, xmax, ymax)   Viewport for window in NDC\\
+     MoveAbs (x, y)                     Move graphics cursor\\
+     MoveRel (dx, dy)\\
+     PointAbs (x, y)                      Plot point at current position\\
+     PointRel (dx, dy)\\
+     LineAbs2 (x, y)             Draw line from current point to point\\
+     LineRel2 (dx, dy)\\
+     MarkerAbs2 (x, y)                     Draw marker at current position\\
+     MarkerRel2 (dx, dy)\\
+     PolylineAbs (x[], y[], n)             Draw a set of lines\\
+     PolylineRel (dx[]. dy[]. n)\\
+     wc\_to\_ndc (xwc, ywc, xndc, yndc)    Convert from world coord to NDC\\
+     ndc\_to\_wc (xndc, yndc, xwc, ywc)    Convert from NDC to world coord\\
+     DrawText (str)                      Draw text string at current positon\\
+
+     INTERNAL:\\
+          calc\_map ()                        Calculate wc to ndc factors\\
+          clip(rectangle[4], x1, y1, x2, y2) Clip a line againt rectangle\\
+
+
+\subsubsection{Normalized Coordinate level}%
+     stylus (x, y, beam)                 Draw a line from current position\\
+     setColor (color)            Set current drawing color\\
+     setLinestyle (style)                Set current line style\\
+     setLinewidth (width)                Set current line width\\
+     setTextColor (foreground, background) If back=-1, then transparent \\
+
+     setMarker (type, color)      Set marker attibutes\\
+     markerNDC (xndc, yndc)                Draw marker at NDC position\\
+
+\subsection{Coordinate Mapping}%
+
+\subsubsection{Mapping from world coordinates to physical device coordinates}%
+
+Window (World Coordinates):   xwmin, xwmax, ywmin, ywmax \\
+Viewport (Normalized Device Coordinates): xvmin, xvmax, yvmin, yvmax\\
+Physical (Physicial Device Coordinates): xpmax, ypmax\\
+
+To convert from WC to NDC:\\
+\begin{equation}
+     X_{ndc} = X_vmin + (X_wc - X_wmin) / (X_wmax - X_wmin)
+\end{equation}
+\begin{equation}
+     Y_{ndc} = 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}
+
+So, for each device set up the following composite transformation:\\
+\begin{equation}
+     x_{pdc} = x_{pmax} (x_{vmin} + (x_{wc} - x_{wmin}) / (x_{wmax} - x_{wmin}))
+\end{equation}
+\begin{equation}
+     y_{pdc} = y_{pmax} (y_{vmin} + (y_{wc} - y_{wmin}) / (y_{wmax} - y_{wmin}))
+\end{equation}
+\begin{equation}
+     X_{pdc} = X_{pmax} X_{vmin} + ((X_{wc} \- X_{wmin})  X_{pmax})/(X_{wmax} \- X_{wmin}))
+\end{equation}
+\begin{equation}
+     X_{pdc} = X_{add} + (X_wc - X_{sub})  X_{fract}
+\end{equation}