1

Is there a way in Tikz to draw a smooth curve that passes through some specified points without the need of specifying control points, like you can do in Asymptote?

For example, in Asymptote I can do

draw((0,0)..(100,0)..(100,100)..(0,100)..cycle);

to obtain a curve that looks like a circle.

What's the Tikz analogous for plain TeX?

percusse
  • 157,807
User
  • 2,530
  • 1
  • 14
  • 25
  • 2
    Yes it's the hobby package. – percusse Jan 21 '16 at 11:02
  • @percusse In the package documentation I see that hobby is written using LaTeX3. I am running Tikz on top of plain TeX, so I can't use hobby – User Jan 21 '16 at 11:07
  • Then no there is none. Any reason to stick to plain? – percusse Jan 21 '16 at 11:08
  • @percusse I am not really using plain TeX, but OPmac, which is a set of macros built upon plain TeX. The reason is that I like more OPmac than LaTeX – User Jan 21 '16 at 11:14
  • Ah then you need to ask @wipet – percusse Jan 21 '16 at 11:14
  • @percusse But I don't think using OPmac instead of pure plain TeX is relevant for this question. I mean, If a solution exists in plain TeX then it should work also in OPmac – User Jan 21 '16 at 11:17
  • You can (of course) use that Asymptote / hobby syntax with Metapost --- since that's where they got it from. So if luatex is an option for you, you could try luamplib for drawing... – Thruston Jan 21 '16 at 11:42
  • @Thruston I need to use xetex, so I can't use luatex. But I can produce a picture with Metapost and then include it in my document. This is not really ideal because I would like to use this curve construction inside of some already made Tikz picture. Anyway, thank you for the suggestion. – User Jan 21 '16 at 11:47
  • Yes but there is none as far as I know for plain and thus for opmac. – percusse Jan 21 '16 at 13:01

2 Answers2

2

Page 30 in the tikz/pgf manual?

\input tikz.tex
\baselineskip=12pt
\hsize=6.3truein
\vsize=8.7truein
We are working on
\tikzpicture[x=1mm,y=1mm]
\draw (0,0) to (100,0) to (100,100) to (0,100) to cycle;

\endtikzpicture.
\bye

the default unit in tikz is cm, so (100,100) was a little large.

daleif
  • 54,450
  • Doesn't this produce a square instead of something that looks like a circle? – User Jan 21 '16 at 11:26
  • 1
    @User \draw (0,0) to[out=90,in=180] (50,50) to[out=0,in=90] (100,0) to[out=270,in=0] (50,-50) to[out=180,in=270] cycle; – Torbjørn T. Jan 21 '16 at 11:34
  • @TorbjørnT. This is not what I was looking for because you have to specify in and out directions, but it could be a good compromise :) – User Jan 21 '16 at 11:40
  • @User I do not ue asymptote, so I do know know its details – daleif Jan 21 '16 at 11:42
2

For this case perhaps plot coordinates with smooth cycle,tension=1 is useful. I borrowed and modified daleif's code.

enter image description here

\input tikz.tex
\baselineskip=12pt
\hsize=6.3truein
\vsize=8.7truein
We are working on
\tikzpicture[x=0.5mm,y=0.5mm]
\draw [smooth cycle,tension=1] plot coordinates {(0,0)(100,0)(100,100)(0,100)};
\endtikzpicture.
\bye
Torbjørn T.
  • 206,688