20

A trick which seems to work here: searching the intersection of the curve… and its reverse. Applied with MetaPost. u := 3cm; path curve[]; curve1 = ((0,0)--(3,0)--(2,1)--(1,-1)) scaled u; curve2 = ((0,0) .. controls (5,1) and (0,3) .. (2,-1)) scaled u; def self_intersection(expr curve) = draw curve; drawdot curve intersectionpoint reverse curve ...


15

Just for fun and learn, an option using let to calculate the angle of the shadow lines to draw from the top and bottom of the sun to certain distance to the planet (0,2) -- +(-\n1:9.5), then save this coordinate as coordinate (a) and the other from (0,-2) -- +(\n1:9.5) save as coordinate (b) to draw easily the shadow using the coordinates of the moon, also ...


14

The basic idea is to use a double line, with a white border. The problem is the default way tikz draws this is to draw the path completely a first time (the white border) and then completely a second time. The way around this is to use a decoration, more specifically the "show path construction" decoration. This decorates the path piecewise. The code is \...


13

You can use the intersections library: \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \pagestyle{empty} \begin{document} \begin{tikzpicture} \node (A) at (0,0) {1}; \node (B) at (1,0) {2}; \node (C) at (5,3) {3}; \node (D) at (-2,7) {4}; \draw[cyan,name path=d1] (A.center) -- (C.center); \draw[cyan,name path=d2] (B.center) ...


13

or \documentclass[border=3pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\firstellip{(0, 1.6) ellipse [x radius=4cm, y radius=1.5cm, rotate=90]} \\ \def\secondellip{(2.9, -0.25) ellipse [x radius=4cm, y radius=1.5cm, rotate=29]} \def\thirdellip{(2, -3.5) ellipse [x radius=4cm, y radius=1.5cm, rotate=-57]} \def\fourthellip{(-...


12

Using the fillbetween library that was introduced in PGFPlots 1.10: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepgfplotslibrary{fillbetween} \usetikzlibrary{intersections} \pgfmathdeclarefunction{normal}{2}{% \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}% } \makeatletter \pgfmathdeclarefunction{erf}{1}{% \...


12

With a real intersection you can write (I changed the coordinates of D) \begin{tikzpicture} \tikzset{dot/.style={circle,inner sep=1pt,fill,label={\tiny #1},name=#1}} \node[dot=A] (A) at (0,0) {}; \node[dot=B] (B) at (1,0) {}; \node[dot=C] (C) at (0,1) {}; \node[dot=D] (D) at (1,-0.5) {}; \draw [name path=P1] (A) -- (B); \draw [name path=P2] (C) -- (D); \...


12

A PSTricks solution just for comparison purpose. \documentclass[pstricks]{standalone} \usepackage{pstricks-add,pst-vehicle,tikzducks} \def\V{\rput(1,1.5){\psscalebox{-2 2}{\tikz{\duck[alien=red]}}}} \def\F{2*cos(x)+x/3} \def\Fp{Derive(1,\F)} \def\tangent#1#2#3{\psplotTangent[linecolor=blue,showpoints]{#1}{.5}{\F}\uput[#2](*#1 {\F}){\scriptsize$f'#30$}} \...


11

For the intersection of two segments, we don't need the intersections library. We can use directly in tikz points like (intersection of A--B and C--D). \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) coordinate(A) -- (2,2) coordinate (B); \draw (2,0) coordinate(C) -- (0,2) coordinate (D); \node[...


11

I was going to say that this is just what the knots TikZ library is for, except that in testing it then I found that it didn't cope well with rounded corners. Fortunately, it was a quick fix (which is now on CTAN). \documentclass[border=5pt]{standalone} %\url{http://tex.stackexchange.com/q/115923/86} \usepackage{tikz} \usetikzlibrary{knots} \begin{...


11

Apparently Tikz doesn't like when you extend the lines artificially using shorten >=-5cm so that's the problem. Your lines don't actually reach the circle, so there are no intersections. This is solved by either placing the nodes behind the circle or drawing the lines independently from the nodes. Here's a slightly different version of your code (which ...


11

You already loaded the intersections library, but then just didn't make use of it. Here one possible way to achieve the desired result. For details please have a look at the comments in the code. % used PGFPlots v1.14 \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{intersections} % use this `compat' level or higher so ...


10

Built-in three-dimensional version of the function intersectionpoints returns an array of intersection points of the two 3d paths. To get the intersections of two path3[] arrays, a simple function intersectionpoints3 can be used, that checks and accumulates all combinations of the intersection points: import three; currentprojection=orthographic(camera=(...


10

I don’t know why PGF doesn’t find these intersections, it probably has do to something with how the path is built internally from the points of the table of values gnuplot creates. It works if you either set set samples 100 or use—with the original samples setting—the smooth option. All intersections are found now. The of key (\tikz@intersect@path@names@...


10

The main problem was that step was too small to be recognized by the intersections library (some ideas are written in the comment section). We also needed to correct a coefficient of 1.1 to get arrowheads back on the curve. The presented layout is in a way similar to this one, http://i.stack.imgur.com/mcmob.png. %! *latex mal-helicoid.tex \documentclass[...


10

Note: I edited the code a couple of times (mostly small cosmetic changes). So, here is the code I finally used (pardon all the commented code, part of it is dedicated to creating raster output). I didn't comment out my code since I was the asker :) but if there is need for some explanation post it as a comment and I'll be glad to answer. settings.render = 0;...


10

Note that I know nothing about Asymptote. Caveat emptor ... This answer is almost exclusively drawn from Charles Staats's fantastic tutorial and the interested reader is encouraged to look there for further details and more correct advice! If you use settings.render=0, then Asymptote draws things in the order they are given i.e. pretty much as ...


9

These points are best found via an intersection. I used the intersection of syntax (which is a wrapper for the intersection cs). The |-/-| short hands are used to find a coordinate in the perpendicular cs. I took the liberty to clean up a little bit in the code and use styles. Also the labels A, B, and so on are in fact labels. Code \documentclass[tikz,...


9

After loading the intersections library, you name the involved paths using name path=<name>, then you can use the name intersections={<options>} key to find intersection points (details in Section 13.3.2 Intersections of Arbitrary Paths of the pgf manual). \documentclass[a4paper]{scrartcl} \usepackage{lmodern} \usepackage[T1]{fontenc} \...


9

Et voila. I define an \intersect command. If you call \intersect{p1}{p2}{q1}{q2}, it will draw the line p1--p2 with a little semicircle where it intersects the line q1--q2. It draws the p1--p2 line in three segments: a straight line from p1 until 0.75mm before the intersection point, and then a semicircle of diameter 1.5mm, and finally the remainder of the ...


9

Here's an Asymptote version. The idea is to rotate everything virtually so that the red line is horizontal, and then compute the bounding box of the gray curve. Its minimum coordinate (i.e., "height") is the desired shifting distance. Update: Abstracted shifting/tangent code into function. Added a curve tangent to the green dashed line as well. \...


9

There must be a real intersection between path P1 and path P2. You could use something like \path[name path=P1,overlay] (A) -- (B)--([turn]0:5cm); \path[name path=P2,overlay] (C) -- (D)--([turn]0:5cm); to enlarge the paths without enlarging the bounding box of the picture. Then you can use \path [name intersections={of=P1 and P2,by={CS}}]; to define a ...


9

Here a workaround, you can divide your area on two parts: first between curve A and C, and the second between A and B and use soft clip to limit filling \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmin=-0.5,xmax=3.5,ymin=-0.5,...


9

In essence, \coordinate is an alias for \node[shape=coordinate]. Looking through tikz.code.tex, it would appear that \coordinate[options] becomes \node[shape=coordinate,options] and so your \coordinate syntax ought to work. I'm not entirely sure why it doesn't (and my investigation time is a bit short today), but the following code does work, which I would ...


9

If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection. \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.pathreplacing} \usetikzlibrary{calc} % <-- added \usetikzlibrary{intersections} \begin{document} \newcommand*{\DeltaX}{0.01} \...


Only top voted, non community-wiki answers of a minimum length are eligible