Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bezier curves in LaTeX and PostScript

214 views
Skip to first unread message

Paulo Tribolet Abreu

unread,
May 29, 1997, 3:00:00 AM5/29/97
to

Hi!

I'm trying to fill areas limited by Bezier curves
drawn by LaTeX in grey. I thought the best way
would be to simulate the curves in PostScript
(with the curveto command). Unfortunately, LaTeX
draws quadratic Bezier curves (three points
needed) and PostScript draws cubic curves
(four points needed).

I can't make the curves match!

Anyone knows of a way to find the equivalent
cubic Bezier curve of a quadratic one, and vice-versa?

Thanks

Paulo Tribolet Abreu


Piet van Oostrum

unread,
May 29, 1997, 3:00:00 AM5/29/97
to Paulo Tribolet Abreu

>>>>> brit...@mail.telepac.pt (Paulo Tribolet Abreu) (PTA) writes:

PTA> Hi!
PTA> I'm trying to fill areas limited by Bezier curves
PTA> drawn by LaTeX in grey. I thought the best way
PTA> would be to simulate the curves in PostScript
PTA> (with the curveto command). Unfortunately, LaTeX
PTA> draws quadratic Bezier curves (three points
PTA> needed) and PostScript draws cubic curves
PTA> (four points needed).

PTA> I can't make the curves match!

PTA> Anyone knows of a way to find the equivalent
PTA> cubic Bezier curve of a quadratic one, and vice-versa?

If you have a quadratic Bezier curve with control points z0, z1, z2, the
equivalent cubic curve has control points: z0, (z0+2z1)/3, (2z1+z2)/3, z2.

The opposite transformation is not generally possible.

By the way, if you use postscript for filling, why don't you draw the
vurves with postscript in the first place. That would give nicer results as
LaTeX approximates the curves with a lot of dots. I think especially the
pstricks package would be a good tool to accomplish this.
--
Piet van Oostrum <pi...@cs.ruu.nl>
URL: http://www.cs.ruu.nl/~piet [PGP]

Berthold K.P. Horn

unread,
May 29, 1997, 3:00:00 AM5/29/97
to

brit...@mail.telepac.pt (Paulo Tribolet Abreu) writes:

>
> Hi!


>
> I'm trying to fill areas limited by Bezier curves

> drawn by LaTeX in grey. I thought the best way

> would be to simulate the curves in PostScript

> (with the curveto command). Unfortunately, LaTeX

> draws quadratic Bezier curves (three points

> needed) and PostScript draws cubic curves

> (four points needed).

>
> I can't make the curves match!
>

> Anyone knows of a way to find the equivalent

> cubic Bezier curve of a quadratic one, and vice-versa?

> Thanks

> Paulo Tribolet Abreu

Use TPIC \specials. These provide a device independent way of doing graphics.
Including lines, dotted lines, circles, arc, quadratic splines and filling
of same. Supported by several drivers including DVIPS, DVIWindo, DVIPSONE.
Higher level interfaces to TPIC include eepic.sty (and some Unix drawing
programs - maybe someone else can fill in this information).

--
Berthold K.P. Horn mailto:bk...@ai.mit.edu
Cambridge, Massachusetts, USA
DISCLAIMER: respondent has connection with http://www.YandY.com

David Handscomb

unread,
May 29, 1997, 3:00:00 AM5/29/97
to

In article <5miike$n...@duke.telepac.pt>,

Paulo Tribolet Abreu <brit...@mail.telepac.pt> wrote:
>
>Anyone knows of a way to find the equivalent
>cubic Bezier curve of a quadratic one, and vice-versa?
>
>
If the quadratic has 3 control points P0, P1, P2, then the equivalent
cubic has 4 control points P0, (P0+2P1)/3, (2P1+P2)/3, P2.
In other words, the end points are the same (naturally), and the intermediate
points are on the tangents at the end points but only 2/3 of the distance
to the point (P1) where the two tangents cross.

[vice versa is more difficult, since every quadratic is a special case of a
cubic but the reverse is false]

Sebastian Rahtz

unread,
May 30, 1997, 3:00:00 AM5/30/97
to

Use TPIC \specials. These provide a device independent way of doing graphics.
Including lines, dotted lines, circles, arc, quadratic splines and filling
of same. Supported by several drivers including DVIPS, DVIWindo, DVIPSONE.
Higher level interfaces to TPIC include eepic.sty (and some Unix drawing
programs - maybe someone else can fill in this information).

If they meet your needs, I agree, a good way to go.

There is a specification of tpic \special commands in The LaTeX
Graphics Companion for those who want gory details.

Sebastian

Denis Girou

unread,
May 30, 1997, 3:00:00 AM5/30/97
to

>>>>> brit...@mail.telepac.pt (Paulo Tribolet Abreu) (PTA) writes:
PTA> Hi!

PTA> I'm trying to fill areas limited by Bezier curves
PTA> drawn by LaTeX in grey. I thought the best way
PTA> would be to simulate the curves in PostScript
PTA> (with the curveto command). Unfortunately, LaTeX
PTA> draws quadratic Bezier curves (three points
PTA> needed) and PostScript draws cubic curves
PTA> (four points needed).

Piet.van.Oostrum> I think especially the
Piet.van.Oostrum> pstricks package would be a good tool to accomplish this.

Here is a simple example with PSTricks.

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{pspicture}(4,4)
\pscustom{%
\psbezier(0,1)(1,3)(2,2.5)(4,4)
\gsave
\psbezier[liftpen=1](4,1)(3,0.5)(2,2)(1,0)
\fill[fillstyle=solid,fillcolor=yellow]
\grestore}
\psbezier(4,1)(3,0.5)(2,2)(1,0)
\end{pspicture}

% Same with control points shown
\begin{pspicture}(4,4)
\pscustom{%
\psbezier(0,1)(1,3)(2,2.5)(4,4)
\gsave
\psbezier[liftpen=1](4,1)(3,0.5)(2,2)(1,0)
\fill[fillstyle=solid,fillcolor=yellow]
\grestore}
\psbezier[showpoints=true](4,1)(3,0.5)(2,2)(1,0)
\psbezier[showpoints=true](0,1)(1,3)(2,2.5)(4,4)
\end{pspicture}

\end{document}


Denis Girou
--

---------------------------------------------------------------------------
Institut du De'veloppement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique |
Ba^timent 506 - B.P. 167 - 91403 Orsay Cedex - France |
Tel. : 01.69.35.85.75 (33.1.69.35.85.75 from foreign countries) |
Messagerie : Denis...@idris.fr |
---------------------------------------------------------------------------

Tonio Voerman

unread,
Jun 4, 1997, 3:00:00 AM6/4/97
to

In <vuxwwoh...@ai.mit.edu> bk...@ai.mit.edu (Berthold K.P. Horn) writes:


>Use TPIC \specials. These provide a device independent way of doing graphics.
>Including lines, dotted lines, circles, arc, quadratic splines and filling
>of same. Supported by several drivers including DVIPS, DVIWindo, DVIPSONE.
>Higher level interfaces to TPIC include eepic.sty (and some Unix drawing
>programs - maybe someone else can fill in this information).

Hello everyone,

I would like to jump in on this topic. For my paper I have used tpic to
create a few pictures for inclusion in latex. In the Unix system
this works without problems, i.e. latex'ing, xdvi'ing and printing
on the laserprinter work without any problems.

At home I have the pastex system working on my Amiga. For some reason
pastex has big problems with the \special from tpic.
Here's a few lines from a picture file:
\expandafter\ifx\csname graph\endcsname\relax \csname
newbox\endcsname\graph\fi
\expandafter\ifx\csname graphtemp\endcsname\relax \csname
newdimen\endcsname\graphtemp\fi
\setbox\graph=\vtop{\vskip 0pt\hbox{%
\special{pn 8}%
\special{pa 2400 6500}%
\special{pa 3400 6500}%
\special{pa 3400 6000}%
\special{pa 2400 6000}%
\special{pa 2400 6500}%
\special{fp}%
\graphtemp=.5ex\advance\graphtemp by 6.250in
\rlap{\kern 2.900in\lower\graphtemp\hbox to 0pt{\hss Widget\hss}}%
\special{pa 2400 5500}%
\special{pa 3400 5500}%
[vi messed up the indenting, sorry for that]

Pastex would complain about this \special at all three stages.
Then I thought it would probably be some add-on just missing, so
I grabbed some .sty etc. files which seemed usefull from Unix.
This was not a complete succes (problems with some files older
than others expected), but somehow I managed to stop pastex whining
about the \special when latex'ing.
ShowDVI and DVIPrint however still don't work with the \special
commands as no lines are drawn in the pictures!!

I have checked that the problem is not the dvi file itself by showing
and printing both the dvifiles created at Unix and Amiga at the same
and at the other system. It's definitely a software problem!

Anybody has a good idea how come I managed (I don't know how I did that)
to get pastex working and why that didn't help showing and printing?
And of course how to get ShowDVI and DVIPrint to use those \specials?

Thanks if you can help me out.

Tonio

>
>--
>Berthold K.P. Horn mailto:bk...@ai.mit.edu
>Cambridge, Massachusetts, USA
>DISCLAIMER: respondent has connection with http://www.YandY.com

--
---------------------------------------------------------------------------
Tonio Voerman
email ajlm...@cs.ruu.nl


0 new messages