\documentclass[12pt,a4paper]{article}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pstcol,eepic,epic}

\def\ePiX{\texttt{ePiX}}
\def\ext{\texttt{ePiX\_ext}}

\setlength{\oddsidemargin}{0cm}
\parindent = 0pt
\parskip = 1pc

\begin{document}

  \pagestyle{headings}  % empty plain headings myheadings

  \section{Introduction}

  \ext\ is an extension to the \ePiX\ pre-processor. This extension offers
  a new style coordinate system with a lot of parameters that can be set by
  the user. Further more it offers drawing of a hatched polygon as well as
  hatched area between two function graphs.

  You need to be familiar with \ePiX\ to be able to use this extension.

  \section{Installation}

  Do \texttt{make contrib}, then \texttt{make install}.

  \section{Cartesian Coordinate System}

  The procedure
  \begin{verbatim}
  void cartesianCoord(struct CartesianStyle cs);
  \end{verbatim}
  \vspace{-1pc}
  is used to make a Cartesian coordinate system. The parameter \textit{cs} is
  a structure whose fields specify the style of the coordinate system (number
  of division points on the axis, name of the axis, graph paper etc.)

  By calling the procedure
  \begin{verbatim}
  void initCartesianStruct(struct CartesianStyle* cs);
  \end{verbatim}
  \vspace{-1pc}
  this structure is filled with standard values giving a reasonable standard
  layout.

  Here is an example of a C-program making such a standard coordinate system:

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
 #include <epix.h>

 main()
 {
   struct CartesianStyle cs;

   bounding_box(P(-3,-2),P(5,6));
   picture(P(12,12));
   unitlength("5mm");
   begin();
   initCartesianStruct(&cs);
   cartesianCoord(cs);
   end();
 }
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf1.eepic}
    %\end{center}
  \end{minipage}

  To make more division points you have to set the \textit{xn} and \textit{x1}
  fields (for the x-axis -- similar for the y-axis) to specify the number of
  points and the position of the first point (the distance between the points
  is set to 1 by initCartesianStruct).

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
   begin();
   initCartesianStruct(&cs);
   cs.xn = 6;
   cs.x1 = -2;
   cs.yn = 6;
   cs.y1 = -1;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf2.eepic}
    %\end{center}
  \end{minipage}

  The fields \textit{xlabels} and \textit{ylabels} holds the labels as a
  NULL terminated array of string pointers. initCartesianStruct sets them
  to \{"1",NULL\}, but you can set them to other values. If the label fields
  are set to other value, the default position of the first label is x1
  for the \textit{xlabels} and y1 for the \textit{ylabels}.

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
  static char* xlabels[] =
    {"-2","-1","","1","2","3",NULL};
  static char* ylabels[] =
    {"-1","","1","2","3","4",NULL};
     :
   begin();
   initCartesianStruct(&cs);
   cs.xn = 6;cs.x1 = -2;
   cs.xlabels = xlabels;
   cs.yn = 6;cs.y1 = -1;
   cs.ylabels = ylabels;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf3.eepic}
    %\end{center}
  \end{minipage}

  Note the empty string at the 0-position to avoid the collision between a
  label and the axis.

  The length and position of the marks as well as the position of the labels
  can be specified:

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
   begin();
   initCartesianStruct(&cs);
   cs.xmrklen = 2;
   cs.xmrkpos = ABOVE;
   cs.xlabpos = ABOVE;
   cs.ymrklen = 2;
   cs.ylabpos = LEFT;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf4.eepic}
    %\end{center}
  \end{minipage}

  The fields \textit{xname} and \textit{yname} holds the names of the axis and
  \textit{xnampos} and \textit{ynampos} the position (ABOVE, BELOW, CENTER for
  the x-axis and LEFT, RIGHT and CENTER for the y-axis):

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
   begin();
   initCartesianStruct(&cs);
   cs.xname = "t/s";
   cs.xnampos = ABOVE;
   cs.yname = "E/kJ";
   cs.ynampos = LEFT;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf5.eepic}
    %\end{center}
  \end{minipage}

  The CENTER position of the names places the names at the end of the axis. If
  this position is used you probably need to shorten the length of the axis (or
  the names will be written outside the picture bounds). This can be done by
  setting the lower left "corner". \textit{ll} and the upper right "corner",
  \textit{ur} (only the upper right corner need to be set here):

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
   begin();
   initCartesianStruct(&cs);
   cs.ur = P(4,5);
   cs.xnampos = CENTER;
   cs.ynampos = CENTER;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf6.eepic}
    %\end{center}
  \end{minipage}

  Also the crossing point for the axis (\textit{x0,y0}) can be specified
  (default i (0,0)) and you can ask for a "broken" axis:

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
     :
   static char* ylabels[] =
     {"22","23","24","25",NULL};
     :
   begin();
   initCartesianStruct(&cs);
   cs.y0  = 20;
   cs.xn = 6;
   cs.yn = 5;
   cs.y1 = 22;
   cs.ylabels = ylabels;
   cs.ybroken = 1;
   cartesianCoord(cs);
   end();
     :
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf7.eepic}
    %\end{center}
  \end{minipage}

  A graph paper can be added simply by setting \textit{graphpap} to 1 (TRUE):

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
 #include <epix.h>

 main()
 {
   struct CartesianStyle cs;

   bounding_box(P(-2,-1),P(4,5));
   picture(P(12,12));
   unitlength("5mm");
   begin();
   initCartesianStruct(&cs);
   cs.graphpap = 1;
   cartesianCoord(cs);
   end();
 }
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf8.eepic}
    %\end{center}
  \end{minipage}

  Note that the axis are drawn with thick lines in this case.

  The placement of the paper is specified by the crossing point \textit{gp0 }
  for a pair of bold lines (default: P(cs.x0,cs.y0)), distance between bold
  lines \textit{xbolddist} and \textit{ybolddist} (default: 1), the number
  of fine lines between bold lines, \textit{nfinevert} and \textit{nfinehorz}
  (default: 9) and lower left corner \textit{gpll} and upper right corner
  \textit{gpur} of the paper (default: coordinate system bounding box).

  All the fields of \textit{struct CartesianStyle} and its default values can
  be found in the header file epix\_ext.h.

  \section{Hatched figures}

  \subsection{Hatched polygon}

  Commands to draw a hatched polygon are generated by calling the procedure
  \begin{verbatim}
void hatch_polygon(double v,double d,int n, pair& pts, ...);
  \end{verbatim}
  \vspace{-2pc}
  The first two parameters \textit{v} and \textit{d} specifies the angle of
  and the distance between the hatch lines. The next parameter \textit{n} is
  the number of corners of the polygon and finally follows the coordinates of
  the corners.

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
  #include "epix.h"

  pair p1 = P(-2,-3), p2 = P(-3,1), p3 = e_1;
  pair p4 = P(2,3),   p5 = P(4,-2), p6 = P(-1,-1);

  main() 
  {
    bounding_box(P(-4,-3),P(4,2));
    picture(P(12, 7.5));
    unitlength("5mm");

    begin();

    grid(P(x_min, y_min), 
         P(x_max, y_max), 
         x_size, y_size);

    hatch_polygon(45, 0.2, 6, p1, p2, p3, p4, p5, p6);

    end();
  }
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf9.eepic}
    %\end{center}
  \end{minipage}

  As is seen from the example, the polygon need not be convex. But the
  result is unpredictable if some of the edges crosses each other.

  \newpage
  \subsection{Hatched area}

  Commands to draw a hatched area between two graphs (or one graph and the
  x-axis) are generated by calling the procedure
  \vspace{-1pc}
  \begin{verbatim}
void hatch_area(double v,double d,
   double f(double),double g(double),double a,double b,int n);
  \end{verbatim}
  \vspace{-2pc}

  The first two parameters has the same meaning as for the \textit{hatch\_polygon}
  procedure. The following parameters are the functions (the second may be NULL
  meaning the x-axis), the start and the end point and the number of points used
  to draw the graphs.

  \begin{minipage}{7.5cm}
    \small
    \begin{verbatim}
 #include <epix.h>
 double f(double x)
 {
   return 4.5-(x-3)*(x-3)/2;
 }
 main()
 {
   struct CartesianStyle cs;

   bounding_box(P(-1,-2),P(7,6));
   picture(P(12,12));
   unitlength("5mm");
   begin();
   initCartesianStruct(&cs);
   cs.ylabpos = LEFT;
   cartesianCoord(cs);
   hatch_area(150,0.2,f,sin,0,5.5,100);
   end();
 }
    \end{verbatim}
  \end{minipage}
  \begin{minipage}{5.5cm}
    %\begin{center}
      \input{graf10.eepic}
    %\end{center}
  \end{minipage}


\end{document}

