4

I'm trying to make a simple drawing in tikz consisting of:

  • An ellipse
  • Some label inside the ellipse
  • Another label near the curve
  • An outer normal vector to the ellipse, again with a label

Producing the ellipse and the first two labels is no problem. However, I can't figure out how to put a node on the boundary of the ellipse. How to do this?

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
   \filldraw[fill=black!20!white](0, 0) ellipse (100pt and 50pt);
\end{tikzpicture}
\end{document}
  • Please supply how you draw the ellipse (i.e. a MWE), is the ellipse a node, or a manual \draw command, for instance? – zeroth Feb 11 '13 at 10:31
  • @zeroth: currently I produce the ellipse with \filldraw[fill=black!20!white](0, 0) ellipse (100pt and 50pt) – Martijn Feb 11 '13 at 10:32
  • 1
    Please add that to the question (with a full \documentclass ... \usepackage it will make it a lot easier for people to supply an answer), i.e. no need to re-create an ellipse. Kind regards and thanks! :) – zeroth Feb 11 '13 at 10:38
  • @zeroth: added the info. Please note that I'm not having trouble with errors or bugs, but need help using TikZ – Martijn Feb 11 '13 at 10:54
  • I am well aware of that. :) Thanks for supplying it to the question. – zeroth Feb 11 '13 at 11:53
3

For drawing the normal vector, you can use the approach described in How to draw tangent line of an arbitrary point on a path in TikZ. It allows you to type

\filldraw[fill=black!20!white, tangent=0.1](0, 0) ellipse (100pt and 50pt);
\draw [blue, ultra thick, use tangent, -latex] (0,0) -- (0,-2) node [pos=0.5, anchor=east] {Normal vector};

to get:


\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\tikzset{
    tangent/.style={
        decoration={
            markings,% switch on 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
}

\begin{document}

\begin{tikzpicture}
\filldraw[fill=black!20!white, tangent=0.1](0, 0) ellipse (100pt and 50pt);
\draw [blue, ultra thick, use tangent, -latex] (0,0) -- (0,-2) node [pos=0.5, anchor=east] {Normal vector};
\end{tikzpicture}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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