# Tikz. Problem creating a perpendicular line to an arbitrary line

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}

• 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

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


[turn] is an other way.

PS: I like to write clean code. That's why I didn't correct from OP's code. \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}

\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)
\tkzDrawSegment(A,P)
\end{tikzpicture}
\end{document} 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}
\tkzDrawSegment(A,B)
\tkzMarkRightAngle[fill=gray!30,opacity=.6](A,B,b)
\end{tikzpicture}
\end{document} 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 (P) -- (O) node[midway,left] {$r$};
\path (\p)+(\g:3mm) node{$\p$}; 