Guest User

Untitled

a guest
Oct 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. documentclass[preview]{standalone}
  2.  
  3. usepackage{filecontents}
  4.  
  5. usepackage{tikz}
  6. usetikzlibrary{decorations.markings}
  7. usetikzlibrary{intersections}
  8. begin{filecontents}{projection.tikz}
  9. % tangent: https://tex.stackexchange.com/a/25940/74942
  10. % intersection: https://tex.stackexchange.com/a/58216/74942
  11. begin{tikzpicture}[
  12. tangent/.style={
  13. decoration={
  14. markings,% switch on markings
  15. mark=
  16. at position #1
  17. with
  18. {
  19. coordinate (tangent point-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
  20. coordinate (tangent unit vector-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
  21. coordinate (tangent orthogonal unit vector-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
  22. }
  23. },
  24. postaction=decorate
  25. },
  26. use tangent/.style={
  27. shift=(tangent point-#1),
  28. x=(tangent unit vector-#1),
  29. y=(tangent orthogonal unit vector-#1)
  30. },
  31. use tangent/.default=1
  32. ] % tangent
  33.  
  34. draw[help lines,xstep=.5,ystep=.5] (0,0) grid (4,3); %grid
  35.  
  36. draw [
  37. name path=curve,
  38. tangent=0.4
  39. ] (0,0)
  40. to [out=60,in=180] (2,2)
  41. to [out=0, in=160] (3,1.75)
  42. to [out=-20, in=-120] (4,3);
  43.  
  44. draw [blue, name path=tangent, use tangent] (-1,0) -- (2,0)
  45. node[sloped,inner sep=0cm,below,pos=.8,
  46. anchor=north west,
  47. minimum height=1cm,
  48. minimum width=1cm](N){a};
  49.  
  50. path [name path=proj] (N.north west)% intersection
  51. node (P) {b} -- (N.south west);
  52.  
  53. draw [name intersections={of=curve and proj}, blue] (P.center)
  54. --
  55. (intersection-1);
  56.  
  57. end{tikzpicture}
  58. end{filecontents}
  59.  
  60. begin{document}
  61. input{./projection.tikz}
  62. end{document}
  63.  
  64. documentclass[preview]{standalone}
  65.  
  66. usepackage{filecontents}
  67.  
  68. usepackage{tikz}
  69. usetikzlibrary{decorations.markings}
  70. usetikzlibrary{decorations.text}
  71. usetikzlibrary{intersections}
  72. begin{filecontents}{projection.tikz}
  73. % tangent: https://tex.stackexchange.com/a/25940/74942
  74. % intersection: https://tex.stackexchange.com/a/58216/74942
  75. % text along path: https://tex.stackexchange.com/a/22316/74942
  76. begin{tikzpicture}[
  77. tangent/.style={
  78. decoration={
  79. markings,% switch on markings
  80. mark=
  81. at position #1
  82. with
  83. {
  84. coordinate (tangent point-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
  85. coordinate (tangent unit vector-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
  86. coordinate (tangent orthogonal unit vector-pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
  87. }
  88. },
  89. postaction=decorate
  90. },
  91. use tangent/.style={
  92. shift=(tangent point-#1),
  93. x=(tangent unit vector-#1),
  94. y=(tangent orthogonal unit vector-#1)
  95. },
  96. use tangent/.default=1
  97. ] % tangent
  98.  
  99. draw[help lines,xstep=.5,ystep=.5] (0,0) grid (4,3); %grid
  100.  
  101. defmyshift#1{raisebox{-2.5ex}} %text along path - height from line
  102. draw [
  103. name path=curve,
  104. tangent=0.4, % where tangent is set (percent of total curve)
  105. postaction={decorate,
  106. decoration={text along path,
  107. text align=center,
  108. text={|sffamilyfootnotesizemyshift| and maybe here too }
  109. }
  110. } %text command
  111. ] (0,0)
  112. to [out=60,in=180] (2,2)
  113. to [out=0, in=160] (3,1.75)
  114. to [out=-20, in=-120] (4,3);
  115.  
  116. defmyshift#1{raisebox{1ex}} %text along path - height from line
  117. draw [blue,
  118. name path=tangent,
  119. use tangent,
  120. postaction={decorate,
  121. decoration={text along path,
  122. text align=center,
  123. text={|sffamilyfootnotesizemyshift| I want some text here }
  124. }
  125. } %text command
  126. ] (-1,0) -- (2,0)
  127. node[sloped,inner sep=0cm,below,pos=.8,
  128. anchor=north west,
  129. minimum height=1cm,
  130. minimum width=1cm](N){a};
  131.  
  132. path [name path=proj] (N.north west)% intersection
  133. node (P) {b} -- (N.south west);
  134.  
  135. draw [ name intersections={of=curve and proj},
  136. blue,
  137. postaction={decorate,
  138. decoration={text along path,
  139. text align=center,
  140. text={|sffamilytinymyshift| and here }
  141. }
  142. } %text command
  143. ] (P.center)
  144. --
  145. (intersection-1);
  146.  
  147. end{tikzpicture}
  148. end{filecontents}
  149.  
  150. begin{document}
  151. input{./projection.tikz}
  152. end{document}
Add Comment
Please, Sign In to add comment