Index: /trunk/doc/pslib/ChangeLogSDRS.tex
===================================================================
--- /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 1692)
+++ /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 1693)
@@ -255,4 +255,5 @@
   arbitrary direction, instead of merging the data along a particular
   dimension.
+\item added \code{psVector *coords} to the API for \code{psImageCut}.
 \item Added \code{psLibVersion} (bug 156).
 \item Added specification of iterator to \code{psMetadataSetIterator}.
Index: /trunk/doc/pslib/psLibADD.tex
===================================================================
--- /trunk/doc/pslib/psLibADD.tex	(revision 1692)
+++ /trunk/doc/pslib/psLibADD.tex	(revision 1693)
@@ -1,3 +1,3 @@
-%%% $Id: psLibADD.tex,v 1.37 2004-09-03 21:05:42 price Exp $
+%%% $Id: psLibADD.tex,v 1.38 2004-09-07 00:52:16 eugene Exp $
 \documentclass[panstarrs]{panstarrs}
 
@@ -1065,7 +1065,7 @@
 (5,5).
 
-\subparagraph{Bilinear Interpolation ({\tt PS\_RESAMPLE\_SINC})}
-
-\subparagraph{Bilinear Interpolation ({\tt PS\_RESAMPLE\_LAGRANGE})}
+\subparagraph{Sinc Interpolation ({\tt PS\_RESAMPLE\_SINC})}
+
+\subparagraph{Lagrange Interpolation ({\tt PS\_RESAMPLE\_LAGRANGE})}
 
 \paragraph{Image Cuts and Slices}
@@ -1109,4 +1109,47 @@
 sum is renormalized by the ratio (12.57/16.00).
 
+\subparagraph{Radial Cuts}
+
+Consider an image with pixels $x_i,y_i$ and a reference coordinate
+$x_c, y_c$.  We want to construct a radial cut by measuring statistics
+for pixels in a sequence of radial annulii $r_s < r < r_e$.  For each
+annulus, we need to select the pixels which fall within this annulus.
+The coordinates of the center of pixel $i,j$ are $i+0.5,j+0.5$.  A
+given pixel has a distance from the reference coordinate of $dX = x_c
+- i - 0.5, dY = y_c - j - 0.5$.  The pixels to be used for a given
+radial annulus are all of those pixels for which $r_s < \sqrt{dX^2 +
+  dY^2} < r_e$.  This is more efficiently calculated by comparing the
+square of the radii and distances.  All pixels which satisfy the above
+condition are included in a specific annular radius.  All average
+quantities are calculated directly from the pixel ensemble
+statistics.  
+
+\subparagraph{Arbitrary Linear Cuts}
+
+Select the pixels which lie along a line following steps of 1 pixel
+length:
+
+\begin{verbatim}
+
+  dX = xe - xs;
+  dY = ye - ys;
+  L = hypot (dX, dY);
+  dX = dX / L;
+  dY = dY / L;
+
+  REALLOCATE (xvec[0].elements, float, MAX (L, 1));
+  REALLOCATE (yvec[0].elements, float, MAX (L, 1));
+  xvec[0].Nelements = L;
+  yvec[0].Nelements = L;
+
+  V = (float *)buf[0].matrix.buffer;
+  for (i = 0; i < L; i++) {
+    xi = xs + i*dX - 0.5;
+    yi = ys + i*dY - 0.5;
+    xvec[0].elements[i] = i;
+    yvec[0].elements[i] = V[xi + Nx*yi];
+  }
+\end{verbatim}
+
 \paragraph{Image Rotation}
 
@@ -1157,7 +1200,7 @@
 %
 \begin{eqnarray}
-\sin \theta                        = \sin \delta \cos \delta_p - \cos \delta \sin \delta_p \sin (\alpha - \alpha_p) 
-\cos \theta \sin (\phi - \phi_p)   = \cos \delta \cos \delta_p \sin (\alpha - \alpha_p) + \sin \delta \sin \delta_p
-\cos \theta \cos (\phi - \phi_p)   = \cos \delta \cos (\alpha - \alpha_p)
+\sin \theta                        & = & \sin \delta \cos \delta_p - \cos \delta \sin \delta_p \sin (\alpha - \alpha_p) 
+\cos \theta \sin (\phi - \phi_p)   & = & \cos \delta \cos \delta_p \sin (\alpha - \alpha_p) + \sin \delta \sin \delta_p
+\cos \theta \cos (\phi - \phi_p)   & = & \cos \delta \cos (\alpha - \alpha_p)
 \end{eqnarray}
 %
@@ -1403,5 +1446,5 @@
 \subsubsection{Offset}
 
-Coordinate offsets can either spherical offsets or linear offsets.  
+Coordinate offsets can be either spherical offsets or linear offsets.
 
 A spherical offset is performed by adding the components of the
@@ -1542,15 +1585,16 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\subsubsection{Offsets}
-
-\tbd{write down Offset calculation (from Bugzilla)}
-\tbd{define RadialCut}
-\tbd{define ImageCut}
-\tbd{define SINC, BICUBIC interpolation}
+\subsubsection{Missing and Todo}
+
+\tbd{define SINC, LAGRANGE interpolation}
+
 \tbd{define sunrise, sunset, sun position}
+
 \tbd{define moonrise, moonset, moon position, moon phase}
+
 \tbd{define planet functions}
-\tbd{clean up psProjections}
+
 \tbd{clean up FITS I/O issues}
+
 \tbd{define Brent's method \& minimization bracketing}
 
Index: /trunk/doc/pslib/psLibSDRS.tex
===================================================================
--- /trunk/doc/pslib/psLibSDRS.tex	(revision 1692)
+++ /trunk/doc/pslib/psLibSDRS.tex	(revision 1693)
@@ -1,3 +1,3 @@
-%%% $Id: psLibSDRS.tex,v 1.108 2004-09-04 04:29:14 price Exp $
+%%% $Id: psLibSDRS.tex,v 1.109 2004-09-07 00:52:16 eugene Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -2341,5 +2341,5 @@
 
 \begin{verbatim}
-psImage *psImageSubsection(const psImage *image, const char *section);
+psImage *psImageSubsection(psImage *image, const char *section);
 \end{verbatim}
 Similar to \code{psImageSubset}, but uses an image \code{section}, of
@@ -2364,5 +2364,5 @@
 
 \begin{verbatim}
-psImage *psImageTrim(psImage *image, int x0, int x1, int y0, int y1);
+psImage *psImageTrim(psImage *image, int x0, int y0, int x1, int y1);
 \end{verbatim}
 Trim the specified \code{image} in-place, which involves shuffling the
@@ -2418,26 +2418,36 @@
 
 \begin{verbatim}
-psVector *psImageCut(psVector *out, const psImage *input, 
-                     const psImage *mask, unsigned int maskVal,
-                     float xs, float ys, float xe, float ye, 
-                     unsigned int nSamples, psImageInterpolateMode mode);
-\end{verbatim}
-Extract pixels along a line segment, \code{(xs,ys)} to \code{(xe,ye)},
-on the image to a vector (array of the appropriate data type).  The
-line segment is sampled \code{nSamples} times, hence the output vector
-contains \code{nSamples} elements.  The interpolation method used to
-derive the output vector value at each sample along the line segment
-is specified by \code{mode}.  If the \code{mask} is non-\code{NULL},
-then pixels for which the corresponding mask value is \code{maskVal}
-are not included in the interpolation.  This function must be defined
-for the following types: \code{psS8}, \code{psU16}, \code{psF32},
+psVector *psImageCut(psVector *out, 
+                     psVector *coords, 
+                     const psImage *input, 
+                     const psImage *mask, 
+                     unsigned int maskVal,
+                     float x0, 
+		     float y0, 
+		     float x1, 
+		     float y1, 
+		     unsigned int nSamples, 
+		     psImageInterpolateMode mode);
+\end{verbatim}
+Extract pixels along a line segment, \code{(x0,y0)} to \code{(x1,y1)},
+on the image to a vector of the same data type.  The line segment is
+sampled \code{nSamples} times, hence the output vector contains
+\code{nSamples} elements.  The interpolation method used to derive the
+output vector value at each sample along the line segment is specified
+by \code{mode}.  If the \code{mask} is non-\code{NULL}, then pixels
+for which the corresponding mask value is \code{maskVal} are not
+included in the interpolation.  This function must be defined for the
+following types: \code{psS8}, \code{psU16}, \code{psF32},
 \code{psF64}.
 
 \begin{verbatim}
-psVector *psImageRadialCut(psVector *out, const psImage *input, 
+psVector *psImageRadialCut(psVector *out, 
+                           const psImage *input, 
                            const psImage *mask, 
                            unsigned int maskVal,
-                           float x, float y,
-                           const psVector *radii, const psStats *stats);
+                           float x, 
+			   float y,
+                           const psVector *radii, 
+			   const psStats *stats);
 \end{verbatim}
 Extract radial region data to a vector.  A vector is constructed where
@@ -2612,5 +2622,5 @@
 is specified by \code{x0,y0}, while the upper right-hand corner of the
 requested region is specified by \code{x1,y1}.  A negative value for
-either of \code{x1} or \code{y2} specifies the size of the region to
+either of \code{x1} or \code{y1} specifies the size of the region to
 be read counting down from the end of the array.
 
@@ -3395,5 +3405,5 @@
 The \code{psMetadataAdd} routine is required to check that all
 metadata names are unique unless the type is already qualified as
-\code{PS_META_NON_UNIQUE}; in this case the data are added to the
+\code{PS_META_ITEM_SET}; in this case the data are added to the
 corresponding \code{psMetadataItem.items} list.
 
@@ -3440,5 +3450,5 @@
 Care should be taken not to leak memory when appending an item for
 which the key already exists in the metadata (and is not
-\code{PS_META_NON_UNIQUE}).
+\code{PS_META_ITEM_SET}).
 %
 \begin{verbatim}
@@ -4036,63 +4046,2 @@
 
 \end{document}
-
-
-An example of the usage of the metadata APIs is as follows:
-\begin{verbatim}
-    for (int i = 0; i < 10; i += 5) {
-        float sqrti = sqrt(i);
-        psMetadataAdd(ms, PS_LIST_TAIL, psMetadataItemAlloc(PS_META_INT, &i, NULL, "const.%d", i));
-        psMetadataAdd(ms, PS_LIST_TAIL, psMetadataItemAlloc(PS_META_FLOAT, &sqrti,
-                      "square root", "const.sqrt%d", i));
-    }
-    psMetadataAdd(ms, psMetadataItemAlloc(PS_META_STR, "Bonjour", "French", "lang.hello"));
-    /*
-     * Remove a key
-     */
-    psMetadataItemFree(psMetadataRemove(ms, PS_LIST_UNKNOWN, "lang.hello"));
-    /*
-     * Print all metadata
-     */
-    fprintf(stdout, "------\n");
-    psMetadataSetIterator(ms, 1, PS_LIST_HEAD);
-    while ((meta = psMetadataGetNext(ms, NULL, 1)) != NULL) {
-        psMetadataItemPrint(stdout, meta, "");
-    }
-    /*
-     * Look up a key by name
-     */
-    fprintf(stdout, "------\n");
-    fprintf(stdout, "Looking up by name:\n");
-    meta = psMetadataLookup(ms, "const.5");
-    if (meta != NULL) {
-        psMetadataItemPrint(stdout, meta, "");
-    }
-\end{verbatim}
-
-\subsubsection{Naming convention for Metadata}
-
-The \code{psMetadataItem} struct includes a name.  This name should be of
-the form \code{name1.name2.name3}$\cdots$, e.g.\hfil\break
-\null\qquad\qquad\code{IPP.phase1.ota12.biassec}.
-
-We must set in place a system for assigning the top-level `domains'
-to responsible individuals, and for gathering a complete list of
-all metadata names in use throughout the project.
-
-\paragraph{Support for Multiple Values for a Given Name}
-
-\begin{verbatim}
-    psMetadataAdd(ms, PS_LIST_UNKNOWN, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,
-                                                           "Bonjour", "French", "lang.hello"));
-    psMetadataAdd(ms, PS_LIST_UNKNOWN, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,
-                                                           "Aloha", "Hawaiian", "lang.hello"));
-    psMetadataAdd(ms, PS_LIST_UNKNOWN, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,
-                                                           "Good Morning", "English", "lang.hello"));
-    /*
-     * Print all metadata starting "lang"
-     */
-    psMetadataSetIterator(ms, 2, PS_LIST_HEAD);
-    while ((meta = psMetadataGetNext(ms, "lang", 2)) != NULL) {
-        psMetadataItemPrint(stdout, meta, "");
-    }
-\end{verbatim}
