2

I'm having a hard time drawing a line that is perpendicular to the radius of a circle. I do not encounter the same problem if a draw a line that is perpendicular to the same radius but at the other side of the line. I need both lines to be perpendicular to the same radius.

\documentclass[tikz,border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{angles,calc,math}

\begin{document}

\begin{tikzpicture}[>=stealth]
\coordinate (O) at (0,0);
\coordinate (P) at ($ ({2*cos(60)},{2*sin(60)}) $);
\draw[draw=black, fill opacity=0.2, text opacity=1] (O) circle (2);
\draw [black] (O) -- (P) coordinate (line2) node [midway, left] {$r$};
\draw [->,black] (P) -- ($(P)!1.5cm!-90:(line2)$) node [midway, right] {not perpendicular};
\draw [->,black] (O) -- ($(O)!1.5cm!-90:(line2)$) node [right] {perpendicular};
\end{tikzpicture}

\end{document}
  • 1
    Welcome! line2 and P coincide. Use \draw [black] (O) -- (P) coordinate[pos=0.5] (line2) node [midway, left] {$r$}; \draw [->,black] (P) -- ($(P)!1.5cm!90:(line2)$) node [midway, right] {perpendicular};, i.e. define line2 in such a way that there is distance to P (and O). – user194703 Feb 2 at 23:08
  • Thank you. All of your answers were really helpful and solved my problem. – ANoether Feb 3 at 13:01
6

Welcome! line2 and P coincide. You want to define line2 in such a way that there is a distance to P.

\documentclass[tikz,border=12pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[>=stealth]
\coordinate (O) at (0,0);
\coordinate (P) at (60:2);
\draw[draw=black, fill opacity=0.2, text opacity=1] (O) circle[radius=2cm];
\draw [black] (O) -- (P) coordinate[pos=0.5] (line2) node [midway, left] {$r$};
\draw [->,black] (P) -- ($(P)!1.5cm!90:(line2)$) node [right] {perpendicular};
\draw [->,black] (O) -- ($(O)!1.5cm!-90:(line2)$) node [right] {perpendicular};
\end{tikzpicture}
\end{document}

enter image description here

Or one may put the coordinate before (P), in which case we can drop pos=0.5, and, as @frougon kindly suggests, change the name of the coordinate.

\documentclass[tikz,border=12pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[>=stealth]
\coordinate (O) at (0,0);
\coordinate (P) at (60:2);
\draw[draw=black, fill opacity=0.2, text opacity=1] (O) circle[radius=2cm];
\draw [black] (O) -- coordinate(OP) (P)  node [midway, left] {$r$};
\draw [->,black] (P) -- ($(P)!1.5cm!90:(OP)$) node [right] {perpendicular};
\draw [->,black] (O) -- ($(O)!1.5cm!-90:(OP)$) node [right] {perpendicular};
\end{tikzpicture}
\end{document}
| improve this answer | |
6

[turn] is an other way.

PS: I like to write clean code. That's why I didn't correct from OP's code.

enter image description here

\documentclass[tikz,border=12pt]{standalone}
\begin{document}
\begin{tikzpicture}
\path 
(0,0) coordinate (O) (60:2) coordinate (P)
(O)--(P)--([turn]-90:1.5) coordinate (M) node[right] {$M$}
(P)--(O)--([turn]90:1.5) coordinate (N) node[right] {$N$};
\draw (P)--(O) node[midway,left] {$r$} circle(2); 
\draw[->] (P)--(M); \draw[->] (O)--(N);
\end{tikzpicture}
\end{document}
| improve this answer | |
4
\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 
\begin{tikzpicture}[thick]
\tkzDefPoint(0,0){A}
\tkzDefPoint({2*cosd(60)},{2*sind(60)}){P}
\tkzDrawCircle(A,P)
\tkzDefPointWith[orthogonal](A,P) 
\tkzDrawLine(A,tkzPointResult)
\tkzDefPointWith[orthogonal](P,A) 
\tkzDrawLine[add=1 and 0](P,tkzPointResult)
\tkzDrawSegment(A,P)
\end{tikzpicture}
\end{document}

enter image description here

Avec un point aléatoirement choisi

\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 
\begin{tikzpicture}
\tkzDefPoints{1/0/A}
\tkzDefRandPointOn[circle = center A radius 1 cm]
\tkzGetPoint{B}
\tkzDefPointWith[orthogonal](A,B)
\tkzDrawSegment(A,tkzPointResult)
\tkzDrawCircle(A,B)
\tkzDrawLine(A,tkzPointResult)
\tkzDefPointWith[orthogonal](B,A) \tkzGetPoint{b}
\tkzDrawLine[add=1 and 0](B,tkzPointResult)
\tkzDrawSegment(A,B)
\tkzMarkRightAngle[fill=gray!30,opacity=.6](A,B,b)
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
2

Another way

\documentclass[tikz,border=12pt]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth,declare function={R=2;k=-2;m=5/4;myangle=60;}] 
\path 
(0,0) coordinate (O)
({R*sin(myangle)},{R*cos(myangle)}) coordinate (P)
({R*sin(myangle) + k*R*cos(myangle)},{R*cos(myangle) - k*R*sin(myangle)} ) coordinate (Q);
 \draw (O)  circle[radius=R]; 
\draw[->] (P) -- (Q);
\draw[->] (O) -- ({m*R*cos(myangle)},- {m*R*sin(myangle)} );
\draw (P) -- (O) node[midway,left] {$r$}; 
\foreach \p in {O,P}
\draw[fill=black] (\p) circle (1.5pt);
\foreach \p/\g in {O/180,P/40}
\path (\p)+(\g:3mm) node{$\p$};
\end{tikzpicture}
\end{document}

enter image description here

| 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.