# Tag Info

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

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

13

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

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

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

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

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

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

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

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

8

You may use \pgfextra{\xdef\Nb{\t}} or \pgfextra{\global\let\Nb\t}: \documentclass[tikz]{standalone} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \clip (-2,-2) rectangle (2,2); \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); \draw [name path=curve 2] (-1,-2) .. controls (-1,8) and (1,-8) .. (1,2); \...

8

The problem seems to be that the brackets around P1 and P2 throw the foreach parser off: \i contains (P1) and (P2), not 1 and 2. You can fix this by removing the brackets: \documentclass[border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \coordinate (P1) at (60:4cm); \...

8

You can use the calc TikZ package to do the job: \documentclass[tikz,border=1mm]{standalone} \usetikzlibrary{intersections,calc} \begin{document} \begin{tikzpicture} \def \borderSep {3pt} % Define the border separation as a constant \node (rect) [name path=rect,draw,double,ultra thick,double distance=\borderSep, rounded corners,minimum size=1cm]{}; \draw[...

8

You can also use the calc library to extend lines. Note that when \t=0 the \foreach will still execute \s=1, hence the \ifnum ... \fi test. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes,intersections,calc} \begin{document} \begin{tikzpicture} \node[shape=circle,draw] (eye) {}; \draw[name path=circle1] (5,0) circle (1); \foreach \i ...

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