![使用 CalcLength 标记使用 tkz-euclide 的线段上的点](https://linux22.com/image/474088/%E4%BD%BF%E7%94%A8%20CalcLength%20%E6%A0%87%E8%AE%B0%E4%BD%BF%E7%94%A8%20tkz-euclide%20%E7%9A%84%E7%BA%BF%E6%AE%B5%E4%B8%8A%E7%9A%84%E7%82%B9.png)
我有以下内容:
\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){X}
\tkzDefPoint(2.5,-2){Y}
\tkzDefPoint(2,1.5){Z}
\tkzDrawPolygon(X,Y,Z)
\tkzDefPoint(0,-5){A}
\tkzDefPoint(10,-5){B}
\tkzDrawSegment(A,B)
\tkzCalcLength[cm](X,Y) \tkzGetLength{XY}
\tkzCalcLength[cm](X,Z) \tkzGetLength{XZ}
\tkzCalcLength[cm](Y,Z) \tkzGetLength{YZ}
\tkzLabelPoints(A,B,X,Y,Z)
\tkzDrawPoints(A,B,X,Y,Z)
\begin{scope}[dim style/.style={dashed,sloped,teal}]
\tkzDrawSegment[dim={\pgfmathprintnumber\XY,6pt,text=red}](X,Y)
\tkzDrawSegment[dim={\pgfmathprintnumber\XZ,6pt,text=red}](X,Z)
\tkzDrawSegment[dim={\pgfmathprintnumber\YZ,6pt,text=red}](Y,Z)
\end{scope}
\end{tikzpicture}
\end{document}
我想用这个来给出相同的结果,如果我要包含以下代码:G = XY,H = XZ 和 I = YZ,则不必计算距离并必须自己输入坐标。
\tkzDefPoint(3.54,-5){G}
\tkzDefPoint(6.04,-5){H}
\tkzDefPoint(9.24,-5){I}
\tkzLabelPoints(G,H,I)
\tkzDrawPoints(G,H,I)
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){X}
\tkzDefPoint(2.5,-2){Y}
\tkzDefPoint(2,1.5){Z}
\tkzDrawPolygon(X,Y,Z)
\tkzDefPoint(0,-5){A}
\tkzDefPoint(10,-5){B}
\tkzDrawSegment(A,B)
\tkzCalcLength[cm](X,Y) \tkzGetLength{XY}
\tkzCalcLength[cm](X,Z) \tkzGetLength{XZ}
\tkzCalcLength[cm](Y,Z) \tkzGetLength{YZ}
\tkzLabelPoints(A,B,X,Y,Z)
\tkzDrawPoints(A,B,X,Y,Z)
\begin{scope}[dim style/.style={dashed, sloped, teal}]
\tkzDrawSegment[dim={\pgfmathprintnumber\XY, 6pt, text=red}](X,Y)
\tkzDrawSegment[dim={\pgfmathprintnumber\XZ, 6pt, text=red}](X,Z)
\tkzDrawSegment[dim={\pgfmathprintnumber\YZ, 6pt, text=red}](Y,Z)
\end{scope}
\tkzDefShiftPoint[A](0:\YZ){G}
\tkzDefShiftPoint[G](0:\XZ){H}
\tkzDefShiftPoint[H](0:\XY){I}
%\tkzDefPoint(3.54,-5){G}
%\tkzDefPoint(6.04,-5){H}
%\tkzDefPoint(9.24,-5){I}
\tkzLabelPoints(G,H,I)
\tkzDrawPoints(G,H,I)
\end{tikzpicture}
\end{document}
编辑:这里的点位于 AB 上,与角度无关
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){X}
\tkzDefPoint(2.5,-2){Y}
\tkzDefPoint(2,1.5){Z}
\tkzDrawPolygon(X,Y,Z)
\tkzDefPoint(0,-5){A}
\tkzDefPoint(10,-5){B}
\tkzDrawSegment(A,B)
\tkzCalcLength[cm](X,Y) \tkzGetLength{XY}
\tkzCalcLength[cm](X,Z) \tkzGetLength{XZ}
\tkzCalcLength[cm](Y,Z) \tkzGetLength{YZ}
\tkzLabelPoints(A,B,X,Y,Z)
\tkzDrawPoints(A,B,X,Y,Z)
\begin{scope}[dim style/.style={dashed, sloped, teal}]
\tkzDrawSegment[dim={\pgfmathprintnumber\XY, 6pt, text=red}](X,Y)
\tkzDrawSegment[dim={\pgfmathprintnumber\XZ, 6pt, text=red}](X,Z)
\tkzDrawSegment[dim={\pgfmathprintnumber\YZ, 6pt, text=red}](Y,Z)
\end{scope}
\tkzDefPointWith[linear normed,K=\YZ](A,B) \tkzGetPoint{G}
\tkzDefPointWith[linear normed,K=\XZ](G,B) \tkzGetPoint{H}
\tkzDefPointWith[linear normed,K=\XY](H,B) \tkzGetPoint{I}
\tkzLabelPoints(G,H,I)
\tkzDrawPoints(G,H,I)
\end{tikzpicture}
\end{document}
答案2
I)对hpekristiansen的解决方案稍作修改,这是正确的方法。
该cm
选项无用\tkzCalcLength
,因为 cm 现在是默认单位。
我删除了,\tkzDrawPolygon(X,Y,Z)
因为片段是用选项绘制的dim
。如果你使用,tkzDrawPolygon
那么你可以传递draw=none
以dim
避免跟踪片段。
我改变了显示方式,但我不知道是否遵循了要点的顺序。
我重新排列了宏的顺序 (def、calc、draw、label)
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
% def
\tkzDefPoint(0,0){X}
\tkzDefPoint(2.5,-2){Y}
\tkzDefPoint(2,1.5){Z}
\tkzDefPoint(0,-5){A}
\tkzDefPoint(10,-5){B}
% calc
\tkzCalcLength(X,Y) \tkzGetLength{XY}
\tkzCalcLength(X,Z) \tkzGetLength{XZ}
\tkzCalcLength(Y,Z) \tkzGetLength{YZ}
\tkzDefPointWith[linear normed,K=\YZ](A,B) \tkzGetPoint{G}
\tkzDefPointWith[linear normed,K=\XZ](G,B) \tkzGetPoint{H}
\tkzDefPointWith[linear normed,K=\XY](H,B) \tkzGetPoint{I}
% draw
\tkzDrawSegment(A,B)
\tkzDrawPoints(A,B,X,Y,Z,G,H,I)
\begin{scope}[dim style/.style={dashed, sloped, teal}]
\tkzDrawSegment[dim={\pgfmathprintnumber\XY, -6pt, text=red}](X,Y)
\tkzDrawSegment[dim={\pgfmathprintnumber\XZ, 6pt, text=red}](X,Z)
\tkzDrawSegment[dim={\pgfmathprintnumber\YZ, -6pt, text=red}](Y,Z) \end{scope}
% lab
\tkzLabelPoints(A,B,Y)
\tkzLabelPoints[left](X)
\tkzLabelPoints[above](Z)
\tkzLabelPoints(G,H,I)
\end{tikzpicture}
\end{document}
II)版本lualatex and tkz-elements
它很有趣,因为它非常适合这种图形。点定义很简单。接下来,我们定义 XYZ 三角形,其定义导致属性的创建。这里有趣的是边长。所以T.XYZ.a
是第一个顶点 X 对边的长度,所以a
对应于YZ
,b
到XZ
等等。
该report
方法从一点沿直线定义的方向传递长度。因此z.H = L.AB : report (T.XYZ.a,z.G)
定义一个点H,使得GH= T.XYZ.a = YZ
和GH || AB
。由于z.G = L.AB : report (T.XYZ.c)
起点被省略,因此选择点A,即AG= T.XYZ.c = XY
和AG || AB
。
% !TEX TS-program = lualatex
\documentclass{standalone}
\usepackage{tkz-euclide}
\usepackage{tkz-elements}
\begin{document}
\begin{tkzelements}
z.X = point : new ( 0 , 0 )
z.Y = point : new ( 2.5 , -2 )
z.Z = point : new ( 2 , 1.5 )
z.A = point : new ( 0 , -3 )
z.B = point : new ( 10 , -3 )
T.XYZ = triangle : new ( z.X , z.Y , z.Z )
L.AB = line : new ( z.A , z.B )
z.G = L.AB : report (T.XYZ.c)
z.H = L.AB : report (T.XYZ.a,z.G)
z.I = L.AB : report (T.XYZ.b,z.H)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
% draw
\tkzDrawSegment(A,B)
\tkzDrawPoints(A,B,X,Y,Z,G,H,I)
\begin{scope}[dim style/.style={dashed, sloped, teal}]
\tkzDrawSegment[dim={\tkzDN{\tkzUseLua{T.XYZ.c}}, -6pt, text=red}](X,Y)
\tkzDrawSegment[dim={\tkzDN{\tkzUseLua{T.XYZ.b}}, 6pt, text=red}](X,Z)
\tkzDrawSegment[dim={\tkzDN{\tkzUseLua{T.XYZ.a}}, -6pt, text=red}](Y,Z)
\end{scope}
% lab
\tkzLabelPoints(A,B,Y)
\tkzLabelPoints[left](X)
\tkzLabelPoints[above](Z)
\tkzLabelPoints(G,H,I)
\end{tikzpicture}
\end{document}
III) 带有一些附加想法的版本。a、b、c 是三角形的属性,但 alpha、beta 和 gamma 也是三角形的属性。我还展示了该report
方法的其他可能性。
% !TEX TS-program = lualatex
\documentclass{standalone}
\usepackage{tkz-euclide}
\usepackage{tkz-elements,amsmath}
\begin{document}
\begin{tkzelements}
z.X = point : new ( 0 , 0 )
z.Y = point : new ( 2.5 , -2 )
z.Z = point : new ( 2 , 1.5 )
z.A = point : new ( 0 , -3 )
z.B = point : new ( 10 , -3 )
T.XYZ = triangle : new ( z.X , z.Y , z.Z )
L.AB = line : new ( z.A , z.B )
z.G = L.AB : report (T.XYZ.c)
z.H = L.AB : report (T.XYZ.a,z.G)
z.I = L.AB : report (T.XYZ.b,z.H)
z.M = point : new ( 0 , -4 )
z.N = point : new ( 0 , -5 )
z.O = point : new ( 0 , -6 )
z.m = L.AB : report ( T.XYZ.c , z.M )
z.n = L.AB : report ( T.XYZ.a , z.N )
z.o = L.AB : report ( T.XYZ.b , z.O )
z.w = point : new ( 6 , 0 )
z.x = point : new ( 6+T.XYZ.b , 0)
t = z.w : rotation (T.XYZ.alpha,z.x)
a = z.w : rotation (T.XYZ.alpha,z.x).argument
z.y = z.w + point : polar (T.XYZ.c, T.XYZ.alpha)
z.z = z.w + point : polar (T.XYZ.a, T.XYZ.alpha+T.XYZ.beta)
z.t = z.w + point : polar (T.XYZ.b, T.XYZ.alpha+T.XYZ.beta+T.XYZ.gamma)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
% draw
\tkzDrawSegments(A,B w,x w,t)
\tkzDrawSegments[blue](M,m w,y)
\tkzDrawSegments[red](N,n w,z)
\tkzDrawSegments[green](O,o w,x w,t)
\tkzDrawPoints(A,B,X,Y,Z,G,H,I,M,N,O,m,n,o,w,x,y,z,t)
\begin{scope}[dim style/.style={dashed, sloped, teal}]
\tkzDrawSegment[blue,dim={\tkzDN{\tkzUseLua{T.XYZ.c}}, -6pt, text=red}](X,Y)
\tkzDrawSegment[green,dim={\tkzDN{\tkzUseLua{T.XYZ.b}}, 6pt, text=red}](X,Z)
\tkzDrawSegment[red,dim={\tkzDN{\tkzUseLua{T.XYZ.a}}, -6pt, text=red}](Y,Z)
\end{scope}
% lab
\tkzLabelPoints(A,B,Y)
\tkzLabelPoints[left](X)
\tkzLabelPoints[above](Z)
\tkzLabelPoints(G,H,I)
\begin{scope}[st/.style ={above,font=\scriptsize}]
\tkzLabelSegment[st](M,m){\tkzDN{\tkzUseLua{T.XYZ.c}}}
\tkzLabelSegment[st](N,n){\tkzDN{\tkzUseLua{T.XYZ.a}}}
\tkzLabelSegment[st](O,o){\tkzDN{\tkzUseLua{T.XYZ.b}}}
\end{scope}
\tkzLabelAngle[pos= 1.3](x,w,y){$\widehat{X}$}
\tkzLabelAngle[pos= 1.3](y,w,z){$\widehat{Y}$}
\tkzLabelAngle[pos= 1.3](z,w,t){$\widehat{Z}$}
\end{tikzpicture}
\end{document}