我看到以下代码用于绘制分成两个直角三角形的三角形,该代码用于演示勾股定理。代码\tkzDefPointWith[orthogonal normed,K=7](C,A)
指示 TikZ 排版什么?如何在 C 的(虚线)线段与线段 AB 相交的点处将“P”添加到图片中?我想我使用命令\tkzLabelPoint
。position 的可选参数是什么P
?标记此点后,我想我可以让 TikZ 使用类似这样的命令在此交叉点处绘制一个直角\tkzMarkRightAngle(C,P,B)
。
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,1){A}
\tkzDefPoint(2,4){C}
\tkzDefPointWith[orthogonal normed,K=7](C,A)
\tkzGetPoint{B}
\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[above](C){$C$}
\tkzMarkRightAngle(A,C,B)
\tkzDrawSegment[green!60!black](A,C)
\tkzDrawSegment[green!60!black](C,B)
\tkzDrawSegment[green!60!black](B,A)
\tkzLabelSegment[auto](B,A){$c$}
\tkzLabelSegment[auto,swap](B,C){$a$}
\tkzLabelSegment[auto,swap](C,A){$b$}
\tkzDrawAltitude[dashed,color=magenta](A,B)(C)
\tkzGetPoint{P}
\tkzMarkAngle[size=1cm,color=cyan,mark=|](C,B,A)
\tkzMarkAngle[size=1cm,color=cyan,mark=|](A,C,P)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](P,C,B)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](B,A,C)
\end{tikzpicture}
\end{document}
答案1
代码“\tkzDefPointWithorthogonal normed,K=7”指示 TikZ 排版什么
假设你有这个命令:
\tkzDefPointWith[orthogonal normed,K=7](C,A)
它指示tikz
在 C 处绘制一条与线 CA 垂直的线,垂直线的长度为 K=7。从手册中,您可以找到以下代码:
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\verb|\tkzDefPointWith[orthogonal normed,K=2](A,B)|
Here, $AB \perp AC$ and $K = 2$ means $AC = 2$
\begin{tikzpicture}[scale=1.2]
\tkzInit[ymin=1,xmax=5,ymax=5] \tkzGrid
\tkzDefPoint(2,3){A} \tkzDefPoint(4,2){B}
\tkzDefPointWith[orthogonal normed,K=2](A,B)
\tkzGetPoint{C}
\tkzDrawPoints[color=red](A,B,C)
\tkzLabelPoints[above right=3pt](A,B,C)
\end{tikzpicture}
\end{document}
如何在 C 的(虚线)线段与线段 AB 的交点处将“P”添加到图片中?我猜我使用命令“\tkzLabelPoint”。位置“P”的可选参数是什么?
你的猜测是正确的。你可以给出与、等tikz
一起使用的常规位置说明符作为可选参数。因此这是一种可能性:above
below
above right
\tkzLabelPoint[below](P){$P$} %% This added to put the label P below
标记此点后,我想我可以让 TikZ 使用“\tkzMarkRightAngle(C,P,B)”之类的命令在此交叉点处绘制一个直角。
你猜对了:-)
现在你的代码:
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,1){A}
\tkzDefPoint(2,4){C}
\tkzDefPointWith[orthogonal normed,K=7](C,A)
\tkzGetPoint{B}
\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[above](C){$C$}
\tkzMarkRightAngle(A,C,B)
\tkzDrawSegment[green!60!black](A,C)
\tkzDrawSegment[green!60!black](C,B)
\tkzDrawSegment[green!60!black](B,A)
\tkzLabelSegment[auto](B,A){$c$}
\tkzLabelSegment[auto,swap](B,C){$a$}
\tkzLabelSegment[auto,swap](C,A){$b$}
\tkzDrawAltitude[dashed,color=magenta](A,B)(C)
\tkzGetPoint{P}
\tkzLabelPoint[below](P){$P$} %% This added to put the label P below
\tkzMarkAngle[size=1cm,color=cyan,mark=|](C,B,A)
\tkzMarkAngle[size=1cm,color=cyan,mark=|](A,C,P)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](P,C,B)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](B,A,C)
\tkzMarkRightAngle(C,P,B) %% This added
\end{tikzpicture}
\end{document}
答案2
仅用于使用 PSTricks 进行打字练习。
\documentclass[pstricks,border=12pt,12pt,dvipsnames]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}[PointSymbol=none,RightAngleSize=.2,MarkAngle=90](9,5)
\pstGeonode[PosAngle={180,90,0},CurveType=polygon,linecolor=ForestGreen](1,1){A}(3,4){C}([offset=6]{A}C){B}
\pstProjection{A}{B}{C}[P]
\pstRightAngle{B}{C}{A}
\pstRightAngle{C}{P}{B}
\psset{MarkAngleRadius=.7,Mark=MarkHashh,linecolor=Cyan}
\pstMarkAngle{B}{A}{C}{}
\pstMarkAngle{P}{C}{B}{}
\psset{MarkAngleRadius=.9,Mark=MarkHash,linecolor=Magenta}
\pstMarkAngle{A}{C}{P}{}
\pstMarkAngle{C}{B}{P}{}
\psline[linestyle=dashed,linecolor=Maroon](C)(P)
\psset{linestyle=none,shortput=nab}
\pcline(A)(B)_{$c$}
\pcline(C)(B)^{$a$}
\pcline(A)(C)^{$b$}
\end{pspicture}
\end{document}