Tuesday, December 6, 2011

Some basic graph objects in pstricks (4) ---- Curves

There are several commands for curve drawing in Pstricks. "\psbezier" draws a Bezier curve, "\parabola" draws a parabola, and "\pscurve", "psecurve", "psccurve" interpolate curves through the given points. In the following they will be introduced one by one.

Bezier curve is really a set of curves (Linear Bezier curve, Quadratic Bezier curve, Cubic bezier curve ...). The Bezier curve in Pstricks is cubic Bezier curve. And to to determine a cubic Bezier curve four control points are needed ("How to draw a cubic Bezier curve according to four given points" can be found in Wikipedia). So the complete form of "\psbezier" is "\psbezier [parameters] {arrowtype} (x0,y0)(x1,y1)(x2,y2),(x2,y3)".

"\parabola [parameters] {arrowtype} (x0,y0)(x1,y1)" draws a parabola with maximum or minimum (x1,y1) staring from (x0,y0).

"\pscurve [parameters] {arrowtype} (x1,y1)...(xn,yn)" interpolates an open curve through the given points. "\psecurve" is similar to "\pscurve" except that the curve is not extend to the first and last points. "\psccurve" draws a closed curve.

The curvature of a curve is controlled by the parameter "curvature".

Now we use these commands to draw several curves.

\documentclass{article}
\usepackage{pstricks}
\begin{document}
  \begin{pspicture}(5,5)
    \psset{showpoints=true}
    \psbezier[linecolor=green]
      (0,0)(0,3)(5,1)(5,5)
    \parabola[arrowsize=10pt]
      {->}(5,5)(2.5,0)
    \pscurve[linecolor=red]
      (0,4)(1.25,5)(2.5,4)(3.75,3)(5,4)
    \pscurve[linecolor=blue,
      curvature=0.5 0.1 0]
      (0,1)(1.25,0)(2.5,1)(3.75,2)(5,1)
    \psccurve[fillstyle=solid,
      fillcolor=yellow]
      (3,4)(4.5,4)(4.5,4.5)(3,4.5)
  \end{pspicture}
\end{document} 

Fig.1 Draw Curves using Pstricks
Files Download: tex ps pdf

No comments:

Post a Comment

Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.