4

How can I make the line segments going to the arrowhead labelled "ds" in het picture below actually go to the arrowhead point? I faked it by using a coordinate near the arrowhead, but it just looks bad.

TikZ drawing

The line segments in question are

\draw (sigma002) -- (ds) node [midway, above, sloped] (EdgeBC) {\huge $r-r'$};
    \draw (ds) -- (origin) node [midway, left] (EdgeCA) {\huge $r$};

EDIT: I can get it just right with

\coordinate (ds) at ($(-1,0)+(158:0.8 and 2)$);

But I wonder if I could label the arrowhead somehow so I can refer to it, instead of fiddling with degrees.

The whole code is

  \documentclass[tikz]{standalone} % Font size (can be 10pt, 11pt or 12pt) and paper size (remove a4paper for US letter paper)

\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[european resistor, european voltage, european current]{circuitikz}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{decorations.markings,decorations.pathmorphing,
decorations.pathreplacing}
\usetikzlibrary{calc,patterns,shapes.geometric}



\usepackage[backend=bibtex]{biblatex}



\begin{document}



\begin{tikzpicture}[axis/.style={thick,->}]

\begin{scope}[scale=2]

    \coordinate (O) at (2, -4, 0);
    \draw[axis] (O) -- +(1, 0, 0) node [right] {$X$};
    \draw[axis] (O) -- +(0, 1, 0) node [right] {$Y$};
    \draw[axis] (O) -- +(0, 0, 1) node [above] {$Z$};
        \coordinate (origin) at (2,-4,0);
\end{scope}

  \begin{scope}[yshift=15cm,xshift=-1cm,y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \draw (480,650) node [left] {\huge $\Omega$};
\path[draw=black,line join=miter,line cap=butt,even odd rule,line width=0.652pt]
    (484.9568,435.1993) .. controls (484.9568,435.1993) and (599.0510,425.7490) ..
    (496.9338,527.8977) .. controls (423.2250,601.6293) and (567.8460,666.1913) ..
    (508.4049,681.9064) .. controls (448.9638,697.6216) and (314.0241,802.7694) ..
    (305.6815,721.0505) .. controls (297.3389,639.3316) and (159.7951,715.9228) ..
    (195.2512,646.7760) .. controls (230.7073,577.6292) and (204.9425,339.3156) ..
    (268.5549,410.0339) .. controls (326.9830,454.7585) and (450.7616,447.3561) ..
    (484.9568,435.1993) -- cycle;
    \end{scope}


\begin{scope}[scale=1.75,xshift=4.5cm,yshift=-0.8cm,
                    cube/.style={very thick,black},
                    grid/.style={very thin,gray},
                    axis/.style={->,blue,ultra thick},
                    rotated axis/.style={->,purple,ultra thick}]

                                          %draw the top and bottom of the cube
    \draw[cube,fill=blue!5] (0,0,0) -- (0,2,0) -- (2,2,0) -- (2,0,0) -- cycle;

    %draw the top and bottom of the cube
    \draw[cube,fill=red!5] (0,0,0) -- (0,2,0) -- (0,2,2) -- (0,0,2) -- cycle;

    %draw the top and bottom of the cube
    \draw[cube,fill=green!5] (0,0,0) -- (2,0,0) -- (2,0,2) -- (0,0,2) -- cycle;

        \foreach \x in {0,1,2}
   \foreach \y in {0,1,2}
      \foreach \z in {0,1,2}{
           %#####################################################
           \ifthenelse{  \lengthtest{\x pt < 2pt}  }
           {
             % True
                \draw [black]   (\x,\y,\z) -- (\x+1,\y,\z);
           }
           {% False
           }
           %#####################################################
           \ifthenelse{  \lengthtest{\y pt < 2pt}  }
           {
             % True
                \draw [black]   (\x,\y,\z) -- (\x,\y+1,\z);
           }
           {% False
           }
           %#####################################################
           \ifthenelse{  \lengthtest{\z pt < 2pt}  }
           {
             % True
                \draw [black]   (\x,\y,\z) -- (\x,\y,\z+1);
           }
           {% False
           }
           \shade[rotated axis,ball color = black!80] (\x,\y,\z) circle (0.06cm);          
}
\coordinate (sigma002) at (0,0,2);

\end{scope}

\begin{scope}
\tikzstyle arrowstyle=[scale=2] %Taille de la flèche 
\draw[thick, black, postaction={decorate,decoration={markings,mark=at position .42 with {\arrow[arrowstyle]{stealth}}}}](-1,0) ellipse (0.8cm and 2cm);
\draw (-2,1) node [left] {\huge $ds$};
\coordinate (ds) at (-1.58,1);

\end{scope}

  \draw (origin) -- (sigma002) node [midway, right] (EdgeAB) {\huge $r'$};
    \draw (sigma002) -- (ds) node [midway, above, sloped] (EdgeBC) {\huge $r-r'$};
    \draw (ds) -- (origin) node [midway, left] (EdgeCA) {\huge $r$};

    \begin{scope}[scale=1.75,xshift=4.5cm,yshift=-0.8cm,
                    cube/.style={very thick,black},
                    grid/.style={very thin,gray},
                    axis/.style={->,blue,ultra thick},
                    rotated axis/.style={->,purple,ultra thick}]

        \draw (0,0,2.25) node [left] {\huge $\sigma(r')$};
\end{scope}
\end{tikzpicture}


\end{document}
5
  • The coordinate of (ds) you have explicit defined by \coordinate (ds) at (-1.58,1). If you change it to \coordinate (ds) at (-1.72,0.75); do you obtain what you looking for?
    – Zarko
    Commented Jan 30, 2016 at 18:41
  • Oh, yes, thanks. How did you get those coordinates? Commented Jan 30, 2016 at 18:44
  • By trial-and-error method :-). Very nice picture!
    – Zarko
    Commented Jan 30, 2016 at 18:50
  • Here I was expecting some neat mathematical trick. Honi soit qui mal y pense though :p Thanks! Commented Jan 30, 2016 at 18:52
  • See, if the trick in my answer is enough (mathematical) net :-)
    – Zarko
    Commented Jan 30, 2016 at 19:12

1 Answer 1

2

Well, now without trial-and-error method:

To \arrow in decoration add coordinate of arrow, by something like this:

\begin{scope}
\tikzstyle arrowstyle=[scale=2] %Taille de la flèche
\draw[thick, black, 
      postaction={decorate,
                  decoration={markings,mark=at position 0.42 with {\arrow[arrowstyle]{stealth}
                   \coordinate[label=left:\huge$ds$] (ds) {}; %<-- added
                   }}}] (-1,0) ellipse (0.8cm and 2cm);
%\draw (-2,1) node [left] {\huge };
\end{scope}

and erase old manual settings of this coordinate. This should do the neat TikZ trick ... As you see, I also move content of node with $ds$ into coordinate as label.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .