我创建了这幅勾股定理图,我需要在正方形中画一些线。我想从 b^2 的最左边的点开始画一条线,水平向右延伸,直到“碰到”矩形的墙。那就是红线。
我创建了一个矩形并旋转了它,所以我不知道如何找出坐标:/
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
%https://www.arndt-bruenner.de/mathe/scripts/dreiecksberechnungrw.htm%
\newcommand{\va}{3}
\newcommand{\vb}{4}
\newcommand{\vc}{5}
\newcommand{\vq}{1.8}
\newcommand{\vp}{3.2}
\newcommand{\vh}{2.4}
\newcommand{\valpha}{36.86989765}
\newcommand{\vbeta}{53.13010235}
\newcommand{\vgamma}{90}
\begin{tikzpicture}
\coordinate [label={below left:$A$}] (A) at (0, 0);
\coordinate [label={above right:$B$}] (B) at (\vp, \vh);
\coordinate [label={below right:$C$}] (C) at (\vc, 0);
\coordinate (D1) at (\vp+\va, \vb);
\draw [very thick] (A) -- node[midway, below]{$c$} (C) -- node[midway, right]{$a$} (B) -- node[midway, above]{$b$} (A) -- cycle;
\draw [dashed, rotate around={-\vbeta+90:(C)}] (C) -- ++ (0, \va) -- ++ (\va, 0) -- ++ (0, -\va) -- ++ (-\va, 0) -- cycle;
\draw [dashed, rotate around={\valpha:(A)}] (A) -- ++ (0, \vb) -- ++ (\vb, 0) -- ++ (0, -\vb) -- ++ (-\vb, 0) -- cycle;
\draw [dashed] (A) -- ++ (0, -\vc) -- ++ (\vc, 0) -- ++ (0, \vc) -- (A) -- cycle;
\newcommand{\ranglesize}{0.3}
\draw[rotate around={-\vbeta:(B)}] (B) -- ++ (0, -\ranglesize) -- ++ (\ranglesize, 0) -- ++ (0, \ranglesize) -- ++ (-\ranglesize, 0) -- cycle;
\end{tikzpicture}
\end{document}
答案1
另一种方法......
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\va}{3}
\pgfmathsetmacro{\vb}{4}
\pgfmathsetmacro{\vc}{5}
\coordinate (A) at (0,0);
\coordinate (B) at (\vc,0);
\coordinate (C) at (\vb*\vb/\vc,\va*\vb/\vc);
% or \coordinate (C) at ({atan2(\va,\vb)}:\vb);
\draw[very thick]
(A) node[below left] {A} -- node[below] {$ c $}
(B) node[below right] {B} -- node[above right] {$ a $}
(C) node[above] {C} -- node[above left] {$ b $} cycle;
\coordinate (cb) at ($(C)!0.4cm!(B)$);
\draw (cb) -- ($(cb)!1!90:(C)$) -- ($(C)!1!-90:(cb)$);
\draw[dashed] (A) -- ($(A)!1!90:(C)$) coordinate (D) -- ($(C)!1!-90:(A)$) -- (C);
\draw[dashed] (A) -- (-90:\vc) -- ++(0:\vc) -- (B);
\draw[dashed] (B) -- ($(B)!1!-90:(C)$) -- ($(C)!1!90:(B)$) -- (C);
\draw[red,very thick] (D) node[left] {D} -- ++(\vc,0) coordinate (E) node[right] {E};
\end{tikzpicture}
\end{document}