如何用 Tikz 绘制一条通过一点并平行于 AC 的弦?

如何用 Tikz 绘制一条通过一点并平行于 AC 的弦?

我用 Tikz 绘制了下图: 电流输出

使用的代码:

\documentclass{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{babel,calc,arrows,shapes.geometric,intersections,through,backgrounds}

\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45, x=5.0cm, y=5.0cm]
% point O
\coordinate (O) at (0,0);
% ABC triangle
\node[name = t, name path = tri, regular polygon, regular polygon sides=3, minimum size=4.5cm, fill=lightgray!50, draw] at (O) {};
\coordinate [label=above:$A$] (A) at (t.corner 1);
\coordinate [label=left:$B$]  (B) at (t.corner 2);
\coordinate [label=right:$C$] (C) at (t.corner 3);
% O's label
\node [above left] at (O) {$O$};
% circle with 2.25cm radius and centre at O
\draw (O) circle (2.25cm);
% point D: the point in the circumference whose angle is 50° with OC
\coordinate [label=above right:$D$] (D) at ($(O)!1!50:(C)$);
% radius OD
\draw [name path=OD] (O) -- (D);
% point E: intersection between radius OD and the triangle
\path [name intersections={of=OD and tri,by=E}];
\node [below] at (E) {$E$};
% point F: point 33% the way from O to E
\coordinate [label=above:$F$] (F) at ($(O)!.33!(E)$);
% draw bullets at each point
\foreach \point in {A,B,C,O,D,E,F}
  \fill [black] (\point) circle (1.5pt);
\end{tikzpicture}
\end{document}

关于我当前的代码:

  • 我知道tkz-euclide并且我认为它可以在这里帮助我,但我在 CTAN 上能找到的唯一文档是法语的,我看不懂这种语言。
  • 根据pgf文档,该arrows库已被弃用,取而代之的是arrows.meta。我之所以使用,只是arrows因为此代码改编自 Geogebra,而且我还没有改变代码的那个特定方面。

我想在圆内放置 2 个点GH,使得弦GH

  • 穿过F
  • 与 AC 平行

从而得到类似这样的结果(下面是用 Geogebra 绘制的): 期望输出

我找到了有关绘制平行线的答案,但在这种情况下它不仅仅是平行,它还需要从圆开始和结束,所以我自己找不到一个好的答案。

答案1

定义一条(overlay使得它不会增加边界框)路径,该路径具有与 相同的斜率A--C(这就是let \p1=($(C)-(A)$),\n1={atan2(\y1,\x1)} in所做的,它计算线的角度)并穿过F,并计算它与圆的交点。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows,calc,shapes.geometric,intersections}
\begin{document}
\begin{tikzpicture}[line cap = round, line join = round, >=triangle 45, x=5.0cm, y=5.0cm]
 % point O
 \coordinate (O) at (0,0);
 % ABC triangle
 \node[name = t, name path = tri, regular polygon, regular polygon sides=3, minimum size=4.5cm, fill=lightgray!50, draw] at (O) {};
 \coordinate [label=above:$A$] (A) at (t.corner 1);
 \coordinate [label=left:$B$]  (B) at (t.corner 2);
 \coordinate [label=right:$C$] (C) at (t.corner 3);
 % O's label
 \node [above left] at (O) {$O$};
 % circle with 2.25cm radius and centre at O
 \draw[name path=circle] (O) circle (2.25cm);
 % point D: the point in the circumference whose angle is 50° with OC
 \coordinate [label=above right:$D$] (D) at ($(O)!1!50:(C)$);
 % radius OD
 \draw [name path=OD] (O) -- (D);
 % point E: intersection between radius OD and the triangle
 \path [name intersections={of=OD and tri,by=E}];
 \node [below] at (E) {$E$};
 % point F: point 33% the way from O to E
 \coordinate [label=above:$F$] (F) at ($(O)!.33!(E)$);
 \path[overlay,name path=line] let \p1=($(C)-(A)$),\n1={atan2(\y1,\x1)} in % computes the slope of A--C
 ($(F)+(\n1:2*2.25cm)$) -- ($(F)+(180+\n1:2*2.25cm)$);
 \draw[name intersections={of=line and circle,by={G,H}}] (G) node[above left]{$G$}
  -- (H) node[below right]{$H$};
 % draw bullets at each point
 \foreach \point in {A,...,H}
   \fill [black] (\point) circle (1.5pt);
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者,您也可以“并行传输”路径A--C,这会产生相同的结果并且不涉及任何内容atan2

 \path[overlay,name path=line]
 ($(F)+($(C)-(A)$)$) -- ($(F)+($(A)-(C)$)$);

答案2

只是为了完整性。你提到tkz-euclide而且我也不会说法语。但是,如果您只搜索诸如“中点”、“平行”等关键字,文档就很容易使用。此外,以下包含来自 tkz-euclide 的命令的速查表非常有用

tkz-euclid-cheatsheet.en.md

要回答你的问题如何定义一条F平行线AC,很简单

\tkzDefLine[parallel=through F](A,C) \tkzGetPoint{f}

tkz-euclide。假设点已经定义。类似地,可以通过以下方式找到与圆的交点

\tkzInterLC(F,f)(O,A) \tkzGetPoints{G}{H}

其中tkzInterLC可以读作 线Ff与以 为中心O、 为半径 的圆的交点r = |OA|

在此处输入图片描述

请参阅下面的完整代码=)

\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all} % on charge tous les objets

\usepackage[utf8]{inputenc}

\begin{document}

\begin{tikzpicture}
    \tkzInit[xmin=-0.5,xmax=4.5,ymin=-1.4,ymax=4]
    \tkzClip
    % Defines where F is placed on the segment OE.
    % 0 = O and 1 = E
    \edef\OF{0.5}

    \tkzDefPoint(0,0){B} \tkzDefPoint(4,0){C}

    \tkzDefEquilateral(B,C)\tkzGetPoint{A};
    \tkzDefBarycentricPoint(A=1,B=1,C=1) \tkzGetPoint{O}
    \tkzDefMidPoint(A,C) \tkzGetPoint{E}

    % Finds the intersection between the line OE and the
    % circle with center O, and radius r = |OA|.
    \tkzInterLC(O,E)(O,A) \tkzGetPoints{D2}{D}

    % Calculates the length |OE| multiplies it with scaling
    \tkzCalcLength[cm](O,E)\tkzGetLength{rOE}
    \pgfmathsetmacro{\pointF}{\OF*\rOE}

    \tkzInterLC[R](O,D)(O,\pointF cm) \tkzGetPoints{F2}{F}

    % Calculates the line parallell to AC through F
    \tkzDefLine[parallel=through F](A,C) \tkzGetPoint{f}
    \tkzInterLC(F,f)(O,A) \tkzGetPoints{G}{H}

    \tkzDrawPolygon[fill=black!10](A,B,C)
    \tkzDrawSegments(G,H O,D)
    \tkzDrawPoints[fill=black,size=10](A,B,C,O,E,D,F,G,H)
    \tkzDrawCircle(O,A)

    \tkzLabelPoint[above](A){$A$}
    \tkzLabelPoint[below left](B){$B$}
    \tkzLabelPoint[below right](C){$C$}
    \tkzLabelPoint[right](D){$D$}
    \tkzLabelPoints[above](E,F,O)

    \tkzLabelPoint[above left](G){$G$}
    \tkzLabelPoint[below](H){$H$}
\end{tikzpicture}

\end{document}

答案3

PSTricks 解决方案仅用于娱乐目的。

在此处输入图片描述

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
    \pstTriangle[fillcolor=lightgray,fillstyle=solid](4;90){A}(4;-150){B}(4;-30){C}
    \pstTriangleOC{A}{B}{C}
    \pstGeonode(0,0){O}(4;30){D}
    \pstInterLL{A}{C}{O}{D}{E}
    \pstOIJGeonode[PointName={default,none},PointSymbol={*,none}]
            (-.5,0){F}{E}{D}{A}(-.5,1){T}
    \pstInterLC[PosAngleA=-45,PosAngleB=135]{F}{T}{O}{D}{H}{G}
    \psline(O)(D)
    \psline(G)(H)
\end{pspicture}
\end{document}

相关内容