Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass[tikz,border=7pt]{standalone}
- usetikzlibrary{decorations.markings,intersections}
- tikzset{
- intersection/times/.code={
- defa{.25} % <- mock value
- defb{.75} % <- mock value
- },
- test mark/.style 2 args={ % <- mark two posions on the path
- decoration={ markings,
- mark =at position #1 with {draw[purple,-latex](0,0) -- (1,0);},
- mark =at position #2 with {draw[purple,-latex](0,0) -- (-1,0);}
- }, decorate
- },
- dot/.style={insert path={node[inner sep=1pt,circle,fill=red]{}}}
- }
- deftestpath{(1,0) arc(270:90:1cm)}
- begin{document}
- begin{tikzpicture}[scale=2]
- draw[red, name path=arc] testpath;
- draw[blue, densely dotted, name path=line] (0,0) -- (1,1) --(0,2);
- draw[
- name intersections={
- of=arc and line, sort by=arc,
- by={a,b},
- times={a,b} % <- this is a mock style that recover the intersection times
- },
- test mark={a}{b} % <- mark at the intersection times
- ] testpath (a)[dot] (b)[dot]; % <- mark at the intersection positions
- end{tikzpicture}
- end{document}
- documentclass[tikz,border=7pt]{standalone}
- usetikzlibrary{decorations.markings,intersections}
- usepackage{pgfplots} %<-added
- usepgfplotslibrary{fillbetween} %<-added
- pgfplotsset{compat=1.16} %<-added
- tikzset{
- intersection/times/.code={
- defa{.25} % <- mock value
- defb{.75} % <- mock value
- },
- test mark/.style 2 args={ % <- mark two posions on the path
- decoration={ markings,
- mark =at position #1 with {draw[purple,-latex](0,0) -- (1,0);},
- mark =at position #2 with {draw[purple,-latex](0,0) -- (-1,0);}
- }, decorate
- },
- dot/.style={insert path={node[inner sep=1pt,circle,fill=red]{}}}
- }
- deftestpath{(1,0) arc(270:90:1cm)}
- begin{document}
- begin{tikzpicture}[scale=2]
- draw[red, name path=arc] testpath;
- draw[blue, densely dotted, name path=line] (0,0) -- (1,1) --(0,2);
- path[
- name intersections={
- of=arc and line, sort by=arc,
- by={a,b},
- total=Nint
- },
- ]
- pgfextra{typeout{numberspace ofspace intersections:space Nint}
- pgfintersectiongetsolutiontimes{1}{tmp}{dummy}
- pgfmathsetmacro{a}{tmp/2}
- pgfintersectiongetsolutiontimes{2}{tmp}{dummyTwo}
- pgfmathsetmacro{b}{tmp/2}
- typeout{a,b,dummy}}
- testpath (a)[dot] (b)[dot]; % <- mark at the intersection positions
- % desired output with fillbetween library
- path [draw,blue,
- name path=middle arc,
- intersection segments={
- of=arc and line,
- sequence={A1}
- },
- postaction={test mark={0}{1}}];
- end{tikzpicture}
- end{document}
Add Comment
Please, Sign In to add comment