38

The reason the code does not work as provided is that there is only one intersection, and so (intersection-2) does not exist. One way to alleviate this kind of issue is to specify total=\t to contain the total number of intersections and the use a foreach to loop through each intersection: \documentclass{article} \usepackage{tikz} \usetikzlibrary{...


33

Reading the PGF Manual helps ;). See page 54ff, I made this from it: \documentclass[parskip]{scrartcl} \usepackage[margin=15mm]{geometry} \usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds} \begin{document} \begin{tikzpicture} \coordinate (A) at (0,0); \coordinate (B) at (3,3); \draw [name path=A--B] (A) -- (B); \coordinate (C) at (3,...


25

This can't be done automatically, unfortunately, since pgfplots can't do z buffering between different \addplot commands. For this concrete application, you could construct the plot "by hand", however: First, you draw the part of the cone below 0, then you draw the plane and the circle, then you draw the part of the cone above 0. I've used a polar ...


17

As wh1t3 said in the comment, you can extract the coordinate using \pgfgetlastxy{<macro for x>}{<macro for y>}. In order to transform this into axis units, you have to apply the inverse of the coordinate transformation that PGFplots uses. In the example below, I've wrapped the transformation in a macro \transformxdimension, which takes a length ...


16

A combination of surface colors, opacities and parametric plots can get you close to the desired result: Code follows: \documentclass{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30] \addplot3[surf, opacity=0.25, blue, shader=flat] {0}; \addplot3[surf, opacity=0.25] {(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/...


16

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

Another hackish solution: \documentclass{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30] \addplot3[surf] {min(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100))}; \addplot3[surf] {max(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100)))}; \addplot3[domain=4:30,samples=80,samples y=0,mark=none,black, opacity=0.5,...


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 name path global instead of name path to make the paths available for finding the intersections in a different scope. Note that you shouldn't use name intersection like a macro with \tikz, but instead use it as an option in a \path command (or similar). As percusse pointed out, instead of using name path global you can also find the intersection ...


13

You made a mistake here (I removed the unknown styles) \draw[,thick] (S_21L) -- (S_22L) node[right] (S_22L) {$S_2$}; You need to remove the last (S_22L) \draw[, thick] (S_21L) -- (S_22L) node[right] {$S_2$}; You move the the coordinates (S_22L) with node[right] and S_22L) now is not on the line. \documentclass{scrartcl} \usepackage{tikz} \...


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

An alternative, in the form of tkz-euclide. \documentclass{article} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture} \tkzDefPoint(0,0){A} \tkzDefPoint(2,2){B} \tkzDefPoint(0,2){C} \tkzDefPoint(2,0){D} \tkzDrawSegments(A,B C,D) \tkzInterLL(A,B)(C,D) \tkzGetPoint{E} \tkzDrawPoints(E) \tkzLabelPoints[below](E) \end{tikzpicture} \end{...


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}{% \...


11

The problem is due to how pgf tracks items between runs using the .aux file, and how this interacts with your particular situation. On the first run, there is no .aux file and so no issues. During this first run, pgf writes a number of lines of the form \pgfsyspdfmark {pgfid<id>}{<x>}{<y>} to the .aux file. These are used to track items ...


11

Not a direct answer to the question, but rather a suggestion of a different approach: If you use PGFplots and treat your lines as proper functions, you can plot the convex function simply using \addplot {min(f,g,h,i)};: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[/pgf/declare function={ f=tan(60)*x+1.7; g=...


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

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 ...


10

I try the idea of whlt3 but it's was not easy; see the next code (perhaps I do some wrong things because I don't know very well pgfplots). I try also \pgfextractx. I need in each case to use \pgfextra to get the x component. Update with the excellent answer of Jake : \documentclass{minimal} \usepackage{tikz,pgfplots} \usetikzlibrary{intersections} ...


10

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 but it does mean you'd need the spath3.dtx file from TeX-SX Launchpad instead of CTAN (don't be fooled by the existence of knot.dtx or spath.dtx, you want spath3.dtx ...


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[...


9

The following excerpts of text can be found on pages 243 and 244 of the manual: One final word of warning: Decorations can be pretty slow to typeset and they can be inaccurate. and Due to the limits on the precision in TEX, some inaccuracies in positioning when crossing input segment boundaries may occasionally be found. That is, the accuracy of the ...


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

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} \...


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