Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Thanks to this solution, I can draw tangent line to a path. I'd like to zoom a very little part of my drawing.

Here it is the code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,spy,decorations.markings,decorations.text}
\tikzset{tangent/.style={decoration={markings,
                                     mark=at position #1 with {\coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                                                               \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                                                               \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);}},
                                     postaction=decorate},
         use tangent/.style={shift = (tangent point-#1),
                             x     = (tangent unit vector-#1),
                             y     =(tangent orthogonal unit vector-#1)},
         use tangent/.default = 1
}

\usepackage{siunitx}

\begin{document}
\begin{tikzpicture}[>=angle 45,
                    spy scope = {connect spies,
                                 every spy on node/.style = {circle,draw},
                                 every spy in node/.style = {circle,draw},
                                 magnification            = 15}]

% Terrain parameters
\def\SoilWidth{7.75}
\pgfmathsetmacro{\MaxDepPos}{.3*\SoilWidth}
\pgfmathsetmacro{\ErDepth}{5/19}
\pgfmathsetmacro{\cdI}{.07*\SoilWidth}
\pgfmathsetmacro{\cdII}{.8*\MaxDepPos}
\pgfmathsetmacro{\cdIII}{.5*\SoilWidth}
\pgfmathsetmacro{\cdIV}{.2*\SoilWidth}

%%%%%%%%
% DRAW %
%%%%%%%%
\coordinate[label=O] (O) at (0,0);

%-> Terrain points 
\coordinate (S1) at ($(O)+(\MaxDepPos,-\ErDepth)$);
\coordinate (S2) at ($(O)+(\SoilWidth,0)$);

%-> Terrain control points
\coordinate (SC1) at ($(O)+(\cdI,0)$);
\coordinate (SC2) at ($(S1)+(-\cdII,0)$);
\coordinate (SC3) at ($(S1)+(\cdIII,0)$);
\coordinate (SC4) at ($(S2)+(-\cdIV,0)$);
\draw[densely dashed] (O)--(S2);

%-> Erosion depth
\draw[tangent=0.1] (O) ..controls (SC1) and
                   (SC2)..(S1)..controls (SC3) and
                   (SC4)..(S2);

%%%% PROBLEM HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\LineScale{.2}                                                                  %
\draw[use tangent,                                                                  %
      orange,                                                                       %
      line width= \LineScale*.4pt,                                                  %
      ->] (0,0)--(.1,0)                                                             %
          (0,0)coordinate(SlopedPoint)                                              %
          (0,-.1) -- (0,.1);                                                        %
                                                                                    %
\coordinate (SlopedPoint1) at (SlopedPoint|-O);                                     %
                                                                                    %
\draw[line width = \LineScale*.4pt,                                                 %
      decoration = {markings,                                                       %
                    mark=at position 0 with {\arrowreversed[scale=\LineScale]{>}};, %
                    mark=at position 1 with {\arrow[scale=\LineScale]{>}};},        %
      postaction = {decorate}](SlopedPoint1)--(SlopedPoint);                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\spy [red,
      height = 4cm,
      width  = 4cm] on ($(SlopedPoint1)!.57!(SlopedPoint)$) in node at (6,3);


\node[left,
      scale = .1] at($(SlopedPoint1)!.5!(SlopedPoint)$){$\delta$};
\end{tikzpicture}
\end{document}][1]

The problem I encounter is the arrow scaling. How it can be seen on the picture, the result is not so good.

Can somebody explain me how to scale only the line width and the arrows in a proper way?

With transformation canvas I obtain a total scaling, and it is not ok because it translate the lines.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I added the following code to solve my problem

\begin{tikzpicture}
\makeatletter
\newdimen\arrow@size
\tikzset{arrow size/.code       = {\arrow@size=#1},
         arrow theta/.code      = \def\arrow@theta{#1},
         fd style/.style 2 args = {arrow size=#1,arrow theta = #2}}

\pgfarrowsdeclare{fd}{fd}{
\pgfarrowsleftextend{0pt}
\pgfarrowsrightextend{.5\pgflinewidth}
}
{
\pgfmathsetlengthmacro{\arrow@theta}{\arrow@size*tan(\arrow@theta)}
\pgfsetdash{}{0pt} % do not dash
\pgfsetroundjoin % fix join
\pgfsetroundcap % fix cap
%\pgfsetstrokecolor{red}
\pgfpathmoveto{\pgfpointorigin}%{\pgfpoint{-4\arrowsize}{4\arrowsize}}
\pgfpathlineto{\pgfpoint{-\arrow@size}{\arrow@theta}}
\pgfpathmoveto{\pgfpointorigin}%{\pgfpoint{-4\arrowsize}{4\arrowsize}}
\pgfpathlineto{\pgfpoint{-\arrow@size}{-\arrow@theta}}
\pgfusepathqstroke
}
\makeatother




\draw[help lines] (-3,0)grid(3,15);

\foreach[count=\n] \lw/\l/\ang in {1pt/3pt/10,
                                   2pt/6pt/35,
                                   5pt/12pt/45,
                                   7pt/1cm/70}{
\draw[line width=\lw,fd-fd,fd style={\l}{\ang}](-2,3*\n)--(2,3*\n);}
\end{tikzpicture}

The result is the following

enter image description here

Let me know if you know a better solution.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.