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.

In Tikz: unit tangent vectors to a curve, Jake helped with adding a tangent vector to the ellipse. However, in that question, the ellipse was oriented with the semi-major and minor axis in line with the x and y axis.

In this question TikZ: Drawing an ellipse through two points, Percusse helped with the constructing of a random elliptical arc which is what I am using here. So we don't know the alignment of the semi-major and minor axis. Maybe we can find the rotation of it, but I am not 100% on that yet.

In the absence of this information, my question is how can I add a normal and tangent vector to the path ending at P2?

Can Jake's answer be adapted, or do we need a different method due to the ambiguity of the elliptical orientation?

  \documentclass[tikz]{standalone}
  \usetikzlibrary{arrows,calc}

  \begin{document}

  \begin{tikzpicture}[
    dot/.style = {outer sep = +0pt, inner sep = +0pt, shape = circle, draw = black, label = {#1}},
    small dot/.style = {minimum size = 1pt, dot = {#1}},
    big dot/.style = {minimum size = 2pt, dot = {#1}},
    line join = round, line cap = round, >=triangle 45
    ]
    \node[ fill = black, big dot = {below: \(F\)}] (F) at (0, 0) {};
    \node[ fill = black, big dot = {below: \(P_1\)}] (P1)  at (2, 0) {};
    \node[ fill = black, big dot = {above right=.25cm:\(P_2\)}] (P2) at (-2, 2) {};    

    \begin{pgfinterruptboundingbox}                  
    \begin{scope}[decoration = {markings,
        mark = at position 0.5 with {\arrow{>}}
      }]
      \clip (2, 0) -- (-2, 0) -- (-2, 4) -- (2, 4) -- cycle;
      \draw[name path global = ellp, postaction = decorate] let
        \p0 = ($(P2) - (F)$),
        \p1 = ($(P1) - (P2)$)
      in (P2|-P1) ++ (\x1, 0) arc (0:100: \x1 and \y0);                                         
  \end{scope}
\end{pgfinterruptboundingbox}

\path[name path = aux1] (P2) circle [radius = 1bp];
\draw[name intersections = {of = ellp and aux1}, -latex] (P2) --
($(intersection-2)!.75cm!(intersection-1)$);


  \end{tikzpicture}
  \end{document} 

enter image description here

share|improve this question
    
The solution I gave for constructing the normal vector is completely independent of the rotation of the ellipse (or whether it even is an ellipse at all, it works for arbitrary paths). However, you need to name the path using name path for it to work, and I'm not sure how to do that with low level pgf paths. Why are you using pgf syntax here, instead of a TikZ \draw command? –  Jake Jun 23 '13 at 19:01
    
Percusse's second solution doesn't actually do what I think you want it to do, though: In the \pgfpatharcto command, you specify the major and minor axis lengths and the rotation (3.25cm, 3cm and , in your example) and then let PGF shift the ellipse so that both the specified points lie on the ellipse. (F) isn't necessarily the focus, though (and it's not in your code). –  Jake Jun 23 '13 at 19:12
    
I'm not sure about the exact problem you pose. I think you mean: How can I draw a part of an ellipse through two points with tangential and normal vector in one of these points? In that case, the answer is trivial and partially given in your references questions: Simply draw a cartesian quarter arc from one point to the other. The tangential and normal vectors in the endpoints then lie parallel to the axis. –  Toscho Jun 23 '13 at 20:22
1  
@dustin: You can use the calc syntax (P2) -- ($(intersection-2)!.75cm!-90:(intersection-1)$), which rotates the coordinate around the (intersection-2) point. See tex.stackexchange.com/a/120326/2552 for an explanation of the syntax. –  Jake Jun 23 '13 at 20:33
1  
@dustin: A more precise approach for that would be to use (P2) -- ($(P2)!0.75cm!-90:($(intersection-2)!.75cm!(intersection-1)$)$). That way, the vectors will be exactly 90 degrees apart. –  Jake Jun 23 '13 at 20:44

1 Answer 1

up vote 3 down vote accepted

You can draw a normal vector using a similar approach to what was done in Tikz: unit tangent vectors to a curve for getting a tangential vector:

If you've defined a very small circle path called aux1, say, around your tangential/normal point, you can find the intersections between this circle and the curve. The connecting line between the two intersections will be approximately tangential to the curve. To draw a normal line, you can use the calc syntax for a rotated line:

(P2) -- ($(P2)!0.75cm!-90:($(intersection-2)!.75cm!(intersection-1)$)$)


  \documentclass[tikz, border=5mm]{standalone}
  \usetikzlibrary{arrows,calc, decorations.markings, intersections}

  \begin{document}

  \begin{tikzpicture}[
    dot/.style = {outer sep = +0pt, inner sep = +0pt, shape = circle, draw = black, label = {#1}},
    small dot/.style = {minimum size = 1pt, dot = {#1}},
    big dot/.style = {minimum size = 2pt, dot = {#1}},
    line join = round, line cap = round, >=triangle 45
    ]
    \node[ fill = black, big dot = {below: \(F\)}] (F) at (0, 0) {};
    \node[ fill = black, big dot = {below: \(P_1\)}] (P1)  at (2, 0) {};
    \node[ fill = black, big dot = {above right=.25cm:\(P_2\)}] (P2) at (-2, 2) {};    

    \begin{pgfinterruptboundingbox}                  
    \begin{scope}[decoration = {markings,
        mark = at position 0.5 with {\arrow{>}}
      }]
      \clip (2, 0) -- (-2, 0) -- (-2, 4) -- (2, 4) -- cycle;
      \draw[name path global = ellp, postaction = decorate] let
        \p0 = ($(P2) - (F)$),
        \p1 = ($(P1) - (P2)$)
      in (P2|-P1) ++ (\x1, 0) arc (0:100: \x1 and \y0);                                         
  \end{scope}
\end{pgfinterruptboundingbox}

\path[name path = aux1] (P2) circle [radius = 1bp];
\draw[name intersections = {of = ellp and aux1}, -latex] (P2) --
($(intersection-2)!.75cm!(intersection-1)$);
\draw [-latex] (P2) --
($(P2)!0.75cm!-90:($(intersection-2)!.75cm!(intersection-1)$)$);


  \end{tikzpicture}
  \end{document} 
share|improve this answer
    
You had a better trick in the trendline question with a node instead of a circle no? ;) tex.stackexchange.com/questions/57582/… –  percusse Jul 5 '13 at 21:56
    
@percusse: That approach doesn't work here, because I can't place a sloped node along the arc at the location of P2 (at least I don't know how). The circle approach is more flexible in that regard. If you can see a way of doing it with a node, by all means, add an answer, you've got my upvote for sure =) –  Jake Jul 5 '13 at 23:39

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.