0

I just started learning TikZ from the The TikZ and PGF Packages Manual for version 3.0.1a, and in the curved path construction subtopic I encountered the following piece of code

\begin{tikzpicture}
\filldraw [gray] (0,0) circle [radius=2pt]
(1,1) circle [radius=2pt]
(2,1) circle [radius=2pt]
(2,0) circle [radius=2pt];
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
\end{tikzpicture}

Now, related to the above code I would like to ask, what does a control point signify, all I could gather was that the tangent from the starting point of the curve is the line joining the starting point and the first control point.

Also, when I removed the command from the above piece of code, for seeing what happens, the LaTex editor just didn't compile and run the code it just displayed the message "Process Started" for quite some time till i closed the editor. So, what could have been the reason for this.

(0,0) circle [radius=2pt]
(1,1) circle [radius=2pt]
(2,1) circle [radius=2pt]
(2,0) circle [radius=2pt];
2

It is not clear which command you removed. If you removed

\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);

that should be fine. I can't test any of this because you didn't provide a complete minimal example, but it should work fine.

If you tried

\draw (0,0) .. .. (2,0);

or

\draw (0,0) .. (2,0);

then it will not work. It would be helpful if you said how it failed. Which error message did you get, for example?

The problem here is that you are requesting a curve but providing no information about its shape. So TikZ cannot construct it.

In contrast,

\draw (0,0) -- (2,0);

should work because the end points is all the information needed to construct a straight line.

If you just wrote

(0,0) circle [radius=2pt]
(1,1) circle [radius=2pt]
(2,1) circle [radius=2pt]
(2,0) circle [radius=2pt];

as the sole content of a tikzpicture, then the problem is that you haven't issued any command at all and TikZ does not know how to parse the coordinates etc. outside of any command context.

That is, TikZ/PGF parses the instructions it receives in a way that is context-sensitive. It depends on, among other things, the kind of thing it is constructing.

The above code specifies some coordinates, but without telling TikZ to expect a coordinate. So TikZ doesn't know they are meant to be coordinates. It also specifies the size and shape of some parts of a path, but without telling TikZ that it should construct a path. So TikZ doesn't know that these are meant to be part of a path specification.

In isolation, the code is meaningless. It only makes sense if you first tell TikZ it is going to be making a path using, for example,

\path

or

\draw

or

\filldraw

etc.

I asked How does one pick control points to control Bézier curves in TikZ? and the answer there may be of assistance.

However, if you are trying to learn TikZ without ever opening the manual i.e. purely from examples, then you may find it a painful experience. If you don't understand how something works, look it up in the manual. The documentation is generally very good. Overwhelming, yes, but fantastic as a reference.

| improve this answer | |
  • After giving some further read to the manual I found out that the code that i removed(the part which I listed lastly) was just for drawing points to indicate the position of the coordinates, so after learning this much I understood that it was not much of a problem to remove them so, I recompiled it but it still persisted. So, I still searched for the solution on web for about an hour. And, the solution that no one(obviously, as you are going to know) mentioned was restarting the editor, and after that everything worked out good. – user350331 Jul 26 '16 at 18:17
  • And about the way I study the manual, I do not try to learn it through examples only I did at first but when it just blew my mind off, I gave it a read from the start and it was a wonder to see how things were explained so interestingly. And about the Bézier curves I learned the starting material from wikipedia, and after trying to come up with a rigorous mathematical formula, which took about 2 hrs of my time and blew my mind off, I stumbled upon the post that you had asked, but it still did not clear my doubt that dealt with the control points that the manual came up with whiledrawingcircles – user350331 Jul 26 '16 at 18:25
  • Restarting the editor is never necessary unless you have a very odd editor. However, your editor might be set to delete certain files when closed. (This is not something I would recommend, but still.) In that case, deletion of generated files might have been required to clear the error. Nobody mentioned this because you provided far too little information for anybody to diagnose the problem properly. For example, the error message you received and the complete code for the example which produced that error. – cfr Jul 26 '16 at 18:28
  • So, if you could help me figure out how to figure out the control points for circles(as they cant be made accurately with control points) – user350331 Jul 26 '16 at 18:28
  • 1
    @user350331 See How to create circle with Bézier curves?ézier-curves for which control points to use to approximate a circle. – Torbjørn T. Jul 26 '16 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.