4

How can I draw a line from the origin to the edge of circle?

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usetikzlibrary{calc, arrows, fixedpointarithmetic}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45,
scale = 1.25, fixed point arithmetic]
\coordinate (O) at (0, 0);
\coordinate (P1) at ($(O) + (-30:1.5cm and .75cm)$);

\draw[-latex] (P1) arc (-30:310:1.5cm and .75cm) coordinate (P2);
\draw[-latex] (O) -- (0, 1.75) node[above, scale = .75] {\(\mathbf{h}\)};
\draw ($(P1)!.5!(P2)$) circle (.18cm) coordinate (P3);
%\draw[blue] (O) --  How to finish this? 
\end{tikzpicture}
\end{document}

I don't know what the last coordinate should be to complete the line. I have tried:

($(P3) + (-30:1.5cm and .75cm)$)

and something else but I can't quite remember what else it was. Any ways, it didn't work.

After that, I want to draw a dashed line from the first edge of the circle to the other edge in line with the solid blue line.

  • Do you want the blue line perpendicular to the edge circle or to its centre but stopping at the edge? \draw ($(P1)!.5!(P2)$) circle (.18cm) coordinate (P3); \draw[blue] (O) -- (P3); \draw[fill=white] ($(P1)!.5!(P2)$) circle (.18cm) coordinate (P3); – Sigur Jun 26 '13 at 18:02
6

You can find the intersection of the blue line with the edge of the circle at P3 with the expression: "It is the point which lies in the line (P3)--(0), at 0.18cm from P3, which in tikz syntax is ($(P3)!.18cm!(O)$).

If you call P4 that point, you can analogously find the diametrally opposite point in the same circle with the expression "It is the point which lies in the line (P4)--(P3) at .36cm from P4, which is tikz syntax is ($(P4)!.36cm!(P3)$).

Using these expressions in your figure:

\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45,
scale = 1.25]
\coordinate (O) at (0, 0);
\coordinate (P1) at ($(O) + (-30:1.5cm and .75cm)$);

\draw[-latex] (P1) arc (-30:310:1.5cm and .75cm) coordinate (P2);
\draw[-latex] (O) -- (0, 1.75) node[above, scale = .75] {\(\mathbf{h}\)};
\draw ($(P1)!.5!(P2)$) circle (.18cm) coordinate (P3);

\draw[blue] (O) -- ($(P3)!.18cm!(O)$) coordinate (P4);
\draw[green] (P4) -- ($(P4)!.36cm!(P3)$);

\end{tikzpicture}

you get

enter image description here

5

you can use shorten

\documentclass[tikz]{standalone}

\usetikzlibrary{calc, arrows}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45]
\coordinate (O) at (0, 0);
\coordinate (P1) at ($(O) + (-30:1.5cm and .75cm)$);

\draw[-latex] (P1) arc (-30:310:1.5cm and .75cm);
\path (P1) arc (-30:320:1.5cm and .75cm) coordinate (P2);
\draw[-latex] (O) -- (0, 1.75) node[above, scale = .75] {\(\mathbf{h}\)};
\draw (P2) circle (1.8mm);
\draw[blue,shorten >=1.8mm] (O) --  (P2); 
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks for your answer but for reasons related to the rest of the picture JLDiaz's answers is more fitting. – dustin Jun 26 '13 at 18:18
  • I like the simplicity/elegance of this answer, but how would you solve this for other shapes, like ellipses? There the amount you need to shorten the line differs because the radius isn't the same from every angle. – Emiel May 14 '14 at 12:02

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.