Guest User

Untitled

a guest
May 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. documentclass[tikz,border=7pt]{standalone}
  2. usetikzlibrary{decorations.markings,intersections}
  3. tikzset{
  4. intersection/times/.code={
  5. defa{.25} % <- mock value
  6. defb{.75} % <- mock value
  7. },
  8. test mark/.style 2 args={ % <- mark two posions on the path
  9. decoration={ markings,
  10. mark =at position #1 with {draw[purple,-latex](0,0) -- (1,0);},
  11. mark =at position #2 with {draw[purple,-latex](0,0) -- (-1,0);}
  12. }, decorate
  13. },
  14. dot/.style={insert path={node[inner sep=1pt,circle,fill=red]{}}}
  15. }
  16. deftestpath{(1,0) arc(270:90:1cm)}
  17. begin{document}
  18. begin{tikzpicture}[scale=2]
  19. draw[red, name path=arc] testpath;
  20. draw[blue, densely dotted, name path=line] (0,0) -- (1,1) --(0,2);
  21. draw[
  22. name intersections={
  23. of=arc and line, sort by=arc,
  24. by={a,b},
  25. times={a,b} % <- this is a mock style that recover the intersection times
  26. },
  27. test mark={a}{b} % <- mark at the intersection times
  28. ] testpath (a)[dot] (b)[dot]; % <- mark at the intersection positions
  29. end{tikzpicture}
  30. end{document}
  31.  
  32. documentclass[tikz,border=7pt]{standalone}
  33. usetikzlibrary{decorations.markings,intersections}
  34. usepackage{pgfplots} %<-added
  35. usepgfplotslibrary{fillbetween} %<-added
  36. pgfplotsset{compat=1.16} %<-added
  37.  
  38. tikzset{
  39. intersection/times/.code={
  40. defa{.25} % <- mock value
  41. defb{.75} % <- mock value
  42. },
  43. test mark/.style 2 args={ % <- mark two posions on the path
  44. decoration={ markings,
  45. mark =at position #1 with {draw[purple,-latex](0,0) -- (1,0);},
  46. mark =at position #2 with {draw[purple,-latex](0,0) -- (-1,0);}
  47. }, decorate
  48. },
  49. dot/.style={insert path={node[inner sep=1pt,circle,fill=red]{}}}
  50. }
  51. deftestpath{(1,0) arc(270:90:1cm)}
  52. begin{document}
  53. begin{tikzpicture}[scale=2]
  54. draw[red, name path=arc] testpath;
  55. draw[blue, densely dotted, name path=line] (0,0) -- (1,1) --(0,2);
  56. path[
  57. name intersections={
  58. of=arc and line, sort by=arc,
  59. by={a,b},
  60. total=Nint
  61. },
  62. ]
  63. pgfextra{typeout{numberspace ofspace intersections:space Nint}
  64. pgfintersectiongetsolutiontimes{1}{tmp}{dummy}
  65. pgfmathsetmacro{a}{tmp/2}
  66. pgfintersectiongetsolutiontimes{2}{tmp}{dummyTwo}
  67. pgfmathsetmacro{b}{tmp/2}
  68. typeout{a,b,dummy}}
  69. testpath (a)[dot] (b)[dot]; % <- mark at the intersection positions
  70.  
  71. % desired output with fillbetween library
  72. path [draw,blue,
  73. name path=middle arc,
  74. intersection segments={
  75. of=arc and line,
  76. sequence={A1}
  77. },
  78. postaction={test mark={0}{1}}];
  79. end{tikzpicture}
  80. end{document}
Add Comment
Please, Sign In to add comment