AW: [pstricks] Calculating curves in PsTricks

Ulrich Dirr ud at art-satz.de
Wed Jun 27 16:07:50 CEST 2001


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

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

> \documentclass[11pt]{article}
>
> \usepackage{graphicx}     % From LaTeX distribution
> \usepackage{pst-all}      % From PSTricks
> \usepackage{multido}      % From PSTricks
> \usepackage[nomessages]{fp}
>
> \begin{document}
>
> \def\Xpsz{6}
> \def\Ypsz{6}
>
> \newcommand{\PerCalc}[2]{%
> \def\ix{#1}\def\iy{#2}%
> \FPeval\iY{\Ypsz * \iy / (\iy + 1.0)} % calculates Y-coodinate
> \FPeval\iX{(\Ypsz - \iY)* \ix / \Xpsz} % calculates X-coodinate
> }% end perspective calculate
>
> \pspicture(-6,0)(6,6)
> \multido{\I=-6+1}{13}{\psline(0,6)(\I,0)}
> % The horizontal perspective grid
> \multido{\R=0.0+1.0}{13}{%
> \PerCalc{-6.0}{\R}
> \FPmul\iXX\iX{-1.0} % Exploits symmetry
> \psline(\iXX,\iY)(\iX,\iY)
> } % end of the horizontal grid
>
> % some dots - I WANT TO CONNECT THESE!!!
> \multido{\Rx=0.0+1.0}{90}{%
> \FPeval\Ry{ (\Rx * \Rx) / 30.0 }  % Defines the quadratic
> \PerCalc{\Rx}{\Ry}
> \FPmul\iXX\iX{-1.0} % Exploits symmetry - so we'll have to
> loose this...
> \psdots(\iX,\iY)(\iXX,\iY)
> }
> \endpspicture
>
>
> \end{document}

Hi.

It's not to difficult to get an ad hoc solution:

You have to write the calculated points to an external file in an
appropriate format. Read this file in and use the points as input for
\dataplot (exactly like in the doc).

I got the curve with the quick and dirty method:
I used (inside your \multido)

\wlog{{\iX}, {\iY}}

to write the points to the log (as an example), copied the points to

\savedata{\mydata}[{<input>}]

and finally plot the curve with

\dataplot[plotstyle=curve]{\mydata}


You can influence smoothness with the plotpoints and curvature
parameters.

So it's quiet easy to obtain the curve (probably easiest with \write
and \read so you don't have to do it by hand ...)



Regards,
Ulrich Dirr


--
Art & Satz
Ulrich Dirr
Arnimstraße 9
81369 München
Germany/Deutschland
--
fon (+49 89) 743 30 60
fax (+49 89) 743 30 61
email ud at art-satz.de
--
-=*:-)




More information about the PSTricks mailing list