1\section{Design\label{design}}
2\emph{Scatterplot3d} is designed to plot three dimensional point clouds
3by exclusive usage of functions in the \RR\ base package.
4Advantages of this ``\emph{\RR\ code only}'' design are the well known
5generality and extensibility of the \RR\ graphics system, the similar
6behavior of arguments and the similar look and feel with respect to common
7\RR\ graphics, as well as the quality of the graphics, which is extremely
8important for publications.
9Drawbacks are the lack of interactivity, and the missing 3D support (2D
10design).
11
12While the function {\tt persp} for plotting surfaces (cf.\ Section
13\ref{tools}) applies a perspective projection, in \sdd\ a parallel
14projection for a better comparison of distances between different points
15is used.
16
17The final implementation of the function and the building of the package
18was done according to the ``\RR\ Language definition'' and ``Writing \RR\ Extensions''
19manuals of the \shortciteANP{r-lang} (in short, `\emph{R core}'),
20\citeyearNP{r-lang} and \citeyearNP{r-ext}.
21
22\enlargethispage{10mm}
23
24\subsection{Arguments\label{arguments}}
25The \sdd\ function has been designed to accept as many common arguments to
26\RR\ graphics functions as possible, particularly those mentioned in the help
27pages of the function {\tt par} and {\tt plot.default} (R core, \citeyearNP{r-ref}).
28In principle, arguments of {\tt par} with a particular 2D design are
29replaced by new arguments in \sdd .
30%
31Regularly, values of the corresponding arguments in {\tt par} for the first
32two dimensions are read out, and \sdd\ either ``guesses'' the value for the
33third dimension or has an appropriate default.
34
35A few graphical parameters can only be set as arguments in \sdd\ but not in
36{\tt par}.  For details on which arguments have got a non common default
37with respect to other \RR\ graphics functions see the ``Usage'' and
38``Arguments'' sections of the help page in the Appendix.
39%
40Other arguments of {\tt par} may be split into several arguments in \sdd
41, e.g. for specification of the line type.  Finally, some of the arguments
42in {\tt par} do not work, e.g. some of those for axis calculation.  As
43common in \RR , additional arguments that are not mentioned on the help
44page can be passed through to underlying low level graphics functions by
45making use of the general `\texttt{...}' argument.
46
47
48\subsection{xyz.coords()\label{xyzcoords}}
49As well known from other \RR\ functions, vectors $x$, $y$ and $z$ (for the
503D case) are used to specify the locations of points.
51
52If $x$ has got an appropriate structure, it can be provided as a single
53argument.  In this case, an attempt has to be made to interpret the
54argument in a way suitable for plotting.
55%
56For that purpose, we added the function {\tt xyz.coords} (R core, \citeyearNP{r-ref})
57into the \RR\ base package that accept various combinations of $x$ and
58optionally $y$ and $z$ arguments.
59%
60It is a ``utility for obtaining consistent $x$, $y$ and $z$ coordinates and
61labels for three dimensional plots'' (R core, \citeyearNP{r-ref}).  Many
62ideas used in this function are taken from the function {\tt xy.coords}
63already existing for the 2D case.
64%
65Even though {\tt xyz.coords} was introduced to support \sdd , it is
66designed to be used by \textsl{any} 3D plot functions making use of $(x_i,
67y_i, z_i)$ triples\footnote{The functions \code{persp}, \code{image} and
68  \code{contour} are restricted to use a \emph{grid} of $x,y$ values and
69  hence only need $n$ $x-$ and $m$ $y-$ values for $n \times m$ $z-$
70  values.}.
71
72If the argument is a formula of type \verb& zvar ~ xvar + yvar&
73(cf.\ R core \citeyear{r-lang} for details on formulas), {\tt xvar},
74{\tt yvar} and {\tt zvar} are used as $x$, $y$ and $z$ variables.  If the
75argument is a
76list with components $x$, $y$ and $z$, these are assumed to define
77plotting coordinates.  If it is a matrix with three columns, the first is
78assumed to contain the $x$ values, etc.  Alternatively, two arguments $x$
79and $y$ can be be provided, one may be real, the other complex.  In any
80other case, the arguments are coerced to vectors and the values plotted
81against their indices.  If no axis labels are given explicitly, {\tt
82  xyz.coords} attempts to extract appropriate axis labels {\tt xlab}, {\tt
83  ylab} and {\tt zlab} from the above mentioned data structures.
84
85Additionally, color vectors contained in a matrix, data frame or list can
86be detected by \sdd\ internally.
87
88
89\subsection{Structure\label{structure}}
90The \RR\ code of \sdd\ is structured into a few parts:\\
91A quite long list of arguments in the first part of the function is followed by some plausibility checks,
92extraction of characters, conversion of data structures (cf.\ Section \ref{xyzcoords}),
93basic calculations of the angle for displaying the cube, and calculations regarding the data region limits,
94as well as data sorting for an optional ``3D highlighting" feature.
95
96In order to optimize the fit of the data into the plotting region, the second part of the function deals
97with optimal scaling of the three axis.
98This yields a high printout quality as well known from regular \RR\ graphics,
99but unfortunately it results also in a static plot, i.e.~rotation is not possible.
100If \sdd s with different viewing angles are put together as a ``slide show" to imitate a rotation,
101each of these ``slides" is {\sl individually} optimally sized regarding the plotting region,
102so all in all such a ``slide show" will not work.
103
104After the graphics device is initialized in the third part, axis, tick marks, box, grid and labels are added
105to the plot, if it is required.
106In the last but one part, the data is plotted and overlayed by the front edges of the box.
107
108Besides the primarily expected result, a drawn plot, four functions are generated and invisibly returned as
109\emph{Values} in the last part of \sdd\ (cf. the Appendix).
110
111These functions, namely \code{xyz.convert}, \code{points3d}, \code{plane3d}
112and \code{box3d}, are required to provide extensibility of the three
113dimensional plot; details are described in Section~\ref{extend}.
114
115