4

I want to draw a line from O to p. However, there is no line visible. Could anyone explain why this fails? I would appreciate your help with this situation.

enter image description here

\documentclass[12pt, a4paper]{article}

\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amssymb, amsmath, amsthm}
\usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}

\begin{document}

\begin{tikzpicture}
\node [below left,inner sep=1pt] {$(0,0)$};
\draw (0,-0.5) -- (0,4); %y軸
\node [circle,draw=gray] (O) at (0,1.5) [minimum size=3cm] {}; %圓
\draw [name path=x-axis] (-6,0) -- ($(-6,0)!2!(tangent cs:node=O,point={(-6,0)},solution=1)$); %x軸
\coordinate (a) at (0,3.3);
\path [name path=L] (a) -- ($(a)!8!(tangent cs:node=O,point={(a)},solution=2)$); %L
\path [name path=L'] (a) -- ($(a)!8!(tangent cs:node=O,point={(a)},solution=1)$);
\path [name intersections={of=x-axis and L, by=m}]; %(m,0)
\path [name intersections={of=x-axis and L', by=-m}]; %(-m,0)
\draw (a)--(m) node [below,inner sep=1pt] {$(m,0)$};
\draw (a)--(-m) node [below,inner sep=1pt] {$(-m,0)$};
\fill (O) circle (1pt) node [font=\scriptsize,right] at (O) {$O=(0,1)$};
\coordinate [label=above right:$p$] (p) at ($(a)!(O)!(m)$);
\fill (p) circle (1pt);
\draw (O) -- (p);
\pic [draw,angle radius=2mm] {right angle = O--p--m};
\end{tikzpicture}

\end{document}
1
  • 1
    I know it's not a real answer but if you write \draw (0,1.5)--(p); instead of \draw (O) -- (p); it works
    – Rob Tan
    Commented Jun 10, 2020 at 10:16

3 Answers 3

4

In \draw (O) -- (p), a line is drawn from the shape margin (which is the circle) of node (O) to node (coordinate) (p). Since nodes (O) and (p) are neighboring, the line degenerate to a dot, hence it looks like the line is not drawn. (You can use \draw (O) -- (m) to see the effect.)

With least changes, you can specify \draw[blue] (O.center) -- (p); to draw from the center of node (O) to (p).

3

There is a difference between coordinate and node -- one uses space the other does not --if you remove the comment from \draw (O)--(m); you will see the difference

enter image description here

\documentclass[12pt, a4paper]{article}

\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amssymb, amsmath, amsthm}
\usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}

\begin{document}

    \begin{tikzpicture}
    \node [below left,inner sep=1pt] {$(0,0)$};
    \draw (0,-0.5) -- (0,4); %y軸
    \node [circle,draw=] (O) at (0,1.5) [minimum size=3cm] {}; %圓
    \draw [name path=x-axis] (-6,0) -- ($(-6,0)!2!(tangent cs:node=O,point={(-6,0)},solution=1)$); %x軸
    \coordinate (a) at (0,3.3);
    \path [name path=L] (a) -- ($(a)!8!(tangent cs:node=O,point={(a)},solution=2)$); %L
    \path [name path=L'] (a) -- ($(a)!8!(tangent cs:node=O,point={(a)},solution=1)$);
    \path [name intersections={of=x-axis and L, by=m}]; %(m,0)
    \path [name intersections={of=x-axis and L', by=-m}]; %(-m,0)
    \draw (a)--(m) node [below,inner sep=1pt] {$(m,0)$};
    \draw (a)--(-m) node [below,inner sep=1pt] {$(-m,0)$};
    \fill (O) circle (1pt) node [font=\scriptsize,right] at (O) {$O=(0,1)$};
    \coordinate [label=above right:$p$] (p) at ($(a)!(O)!(m)$){};
    \fill (p) circle (1pt);
%   \draw (O)--(m);
    \draw (0,1.5)--(p);
    \pic [draw,angle radius=2mm] {right angle = O--p--m};
    \end{tikzpicture}

\end{document}
3

A PSTricks solution only for fun purposes.

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}
\begin{document}
\begin{pspicture}(-7,-1)(7,9)
    \pstGeonode
    [
        PointName={{(-m,0)},{(0,0)},{(m,0)},{O=(0,1)}},
        PosAngle={-90,-150,-90,0},
        PointNameSep={16pt,25pt,16pt,40pt},
    ]
    (-6,0){L}(0,0){B}(6,0){R}(0,3){O}
    \psCircleTangents(R)(O){3}
    \pstGeonode(CircleT1){P}
    \pstCircleOA{O}{B}
    \pcline[nodesep=-1](L)(R)
    \pcline[nodesepA=-1,nodesepB=-6](B)(O)
    \pstInterLL[PointName=none,PointSymbol=none]{R}{P}{B}{O}{T}
    \psline(L)(T)(R)
    \psline(O)(P)
    \pstRightAngle{R}{P}{O}
\end{pspicture}
\end{document}

enter image description here

Extended Solution

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}
\begin{document}
\foreach \i in {1.5,1.6,...,3.5}{%
\begin{pspicture}(-7,-1)(7,11)
    \pstGeonode
    [
        PointName={{(-m,0)},{(0,0)},{(m,0)},{O=(0,1)}},
        PosAngle={-90,-150,-90,0},
        PointNameSep={16pt,25pt,16pt,40pt},
    ]
    (-6,0){L}(0,0){B}(6,0){R}(0,\i){O}
    \psCircleTangents(R)(O){\i}
    \pstGeonode(CircleT1){P}
    \pstCircleOA{O}{B}
    \pcline[nodesep=-1](L)(R)
    \pcline[nodesepA=-1,nodesepB=-7](B)(O)
    \pstInterLL[PointName=none,PointSymbol=none]{R}{P}{B}{O}{T}
    \psline(L)(T)(R)
    \psline(O)(P)
    \pstRightAngle{R}{P}{O}
\end{pspicture}}
\end{document}

enter image description here

You must log in to answer this question.

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