원의 반지름에 수직인 선을 그리는 데 어려움을 겪고 있습니다. 동일한 반경에 수직이지만 선의 반대편에 선을 그리는 경우 동일한 문제가 발생하지 않습니다. 두 선이 모두 동일한 반경에 수직이어야 합니다.
\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
환영! line2
그리고 P
일치합니다. line2
까지의 거리가 있도록 정의하고 싶습니다 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}
또는 좌표를 앞에 배치할 수도 있습니다 (P)
. 이 경우에는 삭제 pos=0.5
하고 @frougon이 친절하게 제안한 대로 좌표 이름을 변경할 수 있습니다.
\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}
답변2
[turn]
다른 방법입니다.
추신 : 나는 글쓰기를 좋아합니다깨끗한 코드. 그래서 OP 코드를 수정하지 않았습니다.
\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}
답변3
\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}
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}
답변4
또 다른 방법
\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}