交点(圆与三角形) Tikz

交点(圆与三角形) Tikz

我正在尝试将圆和三角形相交。我是 tikz 新手,代码可能不起作用,从数学上讲,我可以直接计算交点,但我想知道一种更简单的方法。我想将圆与线段 OP 相交

\documentclass[border=10pt,tikz]{exam}
\usepackage{tkz-euclide}
\usepackage{amsfonts,amsmath,amssymb,tikz}
\usepackage{multicol}
\usepackage{pgfplots}
\usepackage{tcolorbox}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}

\pgfplotsset{every x tick label/.append style={font=\footnotesize, yshift=0.5ex}}
\pgfplotsset{every y tick label/.append style={font=\footnotesize, xshift=0.5ex}}
 \usepgfplotslibrary{polar}
\pagestyle{empty}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.16}
    \usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}[scale=1.5]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefPoint(4,3){C}
\tkzDrawSegment[color=blue,thick](A,B)
\tkzDrawSegment[color=blue,thick](B,C)
\tkzDrawSegment[color=blue,thick](A,C)
\tkzLabelSegment[right](B,C){$y$}
\tkzLabelSegment[swap](A,B){$x$}
\tkzLabelSegment[above](A,C){$r$}
\tkzMarkRightAngle(A,B,C)
\node at (5,0) [anchor=north]{$x$};
\node at (0,5)[anchor=west]{$y$};
\tkzLabelAngle[pos=.5](B,A,C){\footnotesize{\color{red}{$\theta$}}}
\tkzMarkAngle[size=0.35,mark=](B,A,C)
\draw[-latex,thin](-3,0)--(5,0);
\draw[-latex,thin](0,-1.5)--(0,5);
\node at (0,0) [anchor=east]{$O$};
\node at (4,3) [anchor=south]{$P(x,y)$};
\tkzDrawPoint(C)
\draw[color=red,thick](0,0) circle (1.5);
\end{tikzpicture}

\end{document}

答案1

因此,这是对您的代码的一个小补充,让您可以找到并绘制圆和三角形之间的交点。我没有修改任何其他内容,因为您对此没有异议。请参阅代码结尾。

tkz-euclide InterLC

\documentclass[border=10pt,tikz]{exam}
\usepackage{tkz-euclide}
\usepackage{amsfonts,amsmath,amssymb,tikz}
\usepackage{multicol}
\usepackage{pgfplots}
\usepackage{tcolorbox}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}

\pgfplotsset{every x tick label/.append style={font=\footnotesize, yshift=0.5ex}}
\pgfplotsset{every y tick label/.append style={font=\footnotesize, xshift=0.5ex}}
 \usepgfplotslibrary{polar}
\pagestyle{empty}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.16}
    \usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}[scale=1.5]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefPoint(4,3){C}
\tkzDrawSegment[color=blue,thick](A,B)
\tkzDrawSegment[color=blue,thick](B,C)
\tkzDrawSegment[color=blue,thick](A,C)
\tkzLabelSegment[right](B,C){$y$}
\tkzLabelSegment[swap](A,B){$x$}
\tkzLabelSegment[above](A,C){$r$}
\tkzMarkRightAngle(A,B,C)
\node at (5,0) [anchor=north]{$x$};
\node at (0,5)[anchor=west]{$y$};
\tkzLabelAngle[pos=.5](B,A,C){\footnotesize{\color{red}{$\theta$}}}
\tkzMarkAngle[size=0.35,mark=](B,A,C)
\draw[-latex,thin](-3,0)--(5,0);
\draw[-latex,thin](0,-1.5)--(0,5);
\node[above left] at (A) {$O$};
\node at (4,3) [anchor=south]{$P(x,y)$};
\tkzDrawPoint(C)

\tkzDrawCircle[R,thick,color=red](A,1.5cm)
\tkzInterLC[R](A,B)(A,1.5cm) \tkzGetPoints{K'}{K}
\tkzInterLC[R](A,C)(A,1.5cm) \tkzGetPoints{L'}{L}
\tkzDrawPoints(K,L)
\tkzLabelPoints[above right](K)
\tkzLabelPoints[above=2pt](L)

\end{tikzpicture}

\end{document}

答案2

纯粹为了比较,这里有一个替代方案元帖子,包裹在luamplib。用 编译它lualatex

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
numeric u; u = 42;
path xx, yy, t, c;
numeric theta;

z0 = (4,3) scaled u; theta = angle z0;

t = origin -- (x0, 0) -- z0 -- cycle;
c = fullcircle scaled y0;

xx = (2 left -- 5 right) scaled u;
yy = (2 down -- 4 up) scaled u;

drawoptions(withpen pencircle scaled 1/4);
drawarrow xx; 
drawarrow yy;

drawoptions(withpen pencircle scaled 1/4 withcolor 1/2 red);
draw unitsquare rotated 90 scaled 8 shifted point 1 of t;
draw (right {up} .. dir theta) scaled 13;
label("$\theta$", 18 dir 1/2 theta);

drawoptions(withcolor 2/3 red);
draw c;

drawoptions(withcolor 2/3 blue);
draw t;
label.bot ("$x$", point 1/2 of t);
label.rt  ("$y$", point 3/2 of t);
label.ulft("$r$", point 5/2 of t);

drawoptions();
label.rt  ("$x$", point 1 of xx);
label.top ("$y$", point 1 of yy);

dotlabel.top ("$P(x, y)$", z0);
dotlabel.ulft("$O$", origin);
dotlabel.urt ("$K$", point 0 of c);
dotlabel.top ("\strut $L$", point 0 of c rotated theta);

endfig;
\end{mplibcode}
\end{document}

对于点L,我认为在这个特定的绘图中最简单的做法就是将点旋转Ktheta因为它是已知的。但一般来说,你可以用

c intersectionpoint (origin -- z0)

答案3

直接使用 tik 命令绘制图表通常更简单

\documentclass[border=10pt,tikz]{article}

\usepackage{amsfonts,amsmath,amssymb,tikz}

\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=1.5]

\draw[name path=triangle] (0,0) coordinate(A) -- node[below]{x} (4,0) coordinate(B) -- node[right]{y}(4,3) coordinate(C) --  node[above left]{r}(A);

\draw[color=red,thick,name path=cercle](0,0) node[above left,black]{O} circle (1.5);

\path[name intersections={of=triangle and cercle,by={I1,I2} }];

\node[below right=0em of I1]{K};
\node[above right=0.5em and 0em of I2]{L};

\draw[-latex] (A) -- ++(5,0);
\draw[-latex] (A) --++ (0,3);

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案4

使用tzplot包裹:

在此处输入图片描述

\documentclass[tikz,border=1mm]{standalone}
    
\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}
\tzaxes(-2,-2)(5,4){$x$}{$y$}
\tzshoworigin*{$O$}
\tzcoors(0,0)(A)(4,0)(B)(4,3)(C);
\tzpolygon[blue,thick]"ABC"(A){$x$}[b](B){$y$}[r](C){$r$}[a](A);
\tzdot*(C){$P(x,y)$}
\tzcircle[red,thick]"circ"(A)(1.5cm)
\tzXpoint{ABC}{circ}(X)
\tzdots*(X){$K$}[45](X-2){$L$}[90];
\tzanglemark[thin](B)(A)(C){$\theta$}
\end{tikzpicture}

\end{document}

相关内容