[pstricks] Calculating curves in PsTricks

Denis Girou Denis.Girou at idris.fr
Wed Jun 27 20:36:52 CEST 2001

>>>>> "Chris.Sangwin" == Chris Sangwin <sangwinc at for.mat.bham.ac.uk> writes:

    Chris.Sangwin> I wish to typeset a smooth curve using 
    Chris.Sangwin> \pscurve...

    Chris.Sangwin> To use this I need to calculate a list of co-ordinates 

    Chris.Sangwin> \pscurve(x_1,y_1)(x_2,y_2)...

    Chris.Sangwin> Typically I might have a complicated curve that needs many such points.  I
    Chris.Sangwin> often typeset mathematical diagrams and need to *calculate* this list of
    Chris.Sangwin> points - using something like the fp package.  This is what I've done
    Chris.Sangwin> below.  I believe this sort of calculated typesetting of diagrams is very
    Chris.Sangwin> much in the spirit of PST.


    Chris.Sangwin> I'd like LaTeX to perform the calculations (rather than generating a list
    Chris.Sangwin> of points with external C code and importing them) to keep the file self
    Chris.Sangwin> contained.  I don't find the speed of the fp package too slow.

    Chris.Sangwin> How do I connect the dots in the example below with a smooth curve (which
    Chris.Sangwin> in this example happens to be an ellipse - but that would be cheating as
    Chris.Sangwin> this is only an example of a more general problem!)

  Ulrich Dirr gave you the way to follow. Here is your example rewritted using
external temporary files to store the data.

  Just note that I made few other changes:

    - You doesn't need to use fixed point real numbers in the multido loops,
are you use only integer values.
    - I use two files. The problem is that you need to store consecutively
in a file the values to join, so you can't store in the same time the
symetrical part of the curve in one unique file. An alternative solution
is to use only one file but to split the loop in two ones (but this will be
of course slower).
    - I suppress the "\psdots(\iX,\iY)(\iXX,\iY)" line, as this is easiest
to plot the points during curve drawing, using the "showpoints" parameter.


\usepackage{pst-plot}     % From PSTricks






\FPeval{\iY}{\Ypsz * \iy / (\iy + 1.0)}  % Calculates Y-coordinate
\FPeval{\iX}{(\Ypsz - \iY)* \ix / \Xpsz} % Calculates X-coordinate
}% End perspective calculate


  % The horizontal perspective grid
    \FPneg{\iXX}{\iX}                    % Exploits symmetry 
    \psline(\iXX,\iY)(\iX,\iY)}          % End of the horizontal grid


    \FPeval{\Ry}{ (\IRx * \IRx) / 30.0 }   % Defines the quadratic
    \FPneg{\iXX}{\iX} % Exploits symmetry - so we'll have to loose this...






More information about the PSTricks mailing list