从 tkz-2d 迁移到 tkz-euclide

从 tkz-2d 迁移到 tkz-euclide

我想用这个例子http://www.texample.net/tikz/examples/morleys-triangle/。我把改成tkz-2dtkz-euclide(被tkz-2d这个包取代了),但tkz-euclide不知道\tkzMathLength。我该如何修改代码来获得一个可行的示例?

答案1

线段的长度tkz-euclide通过以下方式确定:

\tkzCalcLength[<unit>](<point1>,<point2>) \tkzGetLength{<variableName>}

如您所见,您还可以指定结果的单位。当然,在代码中稍后使用时,不要忘记\前面的。:)<variableName>

编辑:为了避免编译时出现错误,每次使用时都需要指定单位\<varialbleName>,例如:

\tkzCalcLength(R,Q) \tkzGetLength{dRQ}
\tkzCalcLength[cm](M,Q) \tkzGetLength{dMQ}

\tkzDrawCircle[R](O,\dRQ cm)
\tkzDrawCircle[R](P,\dMQ pt)

编辑2:好的,这是完整的工作示例,以防它对某些人不起作用:

% Morley's triangle
% Author : Arnaud Lefebvre (IREM Rouen)
% Ported to tkz-euclide : Count Zero
% Intersections of trisector lines in any triangle
% are vertices of an equilateral triangle

\documentclass{article}

\usepackage{tkz-euclide}

\usetikzlibrary{calc,intersections}
\usetkzobj{all}

\pagestyle{empty}

\begin{document}

\begin{tikzpicture}

%----------------------------------------------------
% Coordinates of A, B and C, the triangle vertices 
%----------------------------------------------------
\coordinate[label=above:$A$] (A) at (5,4);
\coordinate[label=left:$B$] (B) at (0,0);
\coordinate[label=right:$C$] (C) at (7,0);

%----------------------------------------------------
% Lengths of segments [AB], [BC], and [CA] 
%----------------------------------------------------
\tkzCalcLength(B,C) \tkzGetLength{a}
\pgfmathsetmacro{\la}{.01*\a pt}
\tkzCalcLength(A,C) \tkzGetLength{b}
\pgfmathsetmacro{\lb}{.01*\b pt}
\tkzCalcLength(A,B) \tkzGetLength{c}
\pgfmathsetmacro{\lc}{.01*\c pt}

%----------------------------------------------------
% Computing 1/3 of each angle
%----------------------------------------------------
\pgfmathsetmacro{\A}{acos((\la*\la-\lb*\lb-\lc*\lc)/(-2*\lb*\lc))};
\pgfmathsetmacro{\tA}{\A/3};
\pgfmathsetmacro{\B}{acos((\lb pt*\lb pt-\la pt*\la pt-\lc pt*\lc pt)/(-2*\la pt*\lc pt))};
\pgfmathsetmacro{\tB}{\B/3};
\pgfmathsetmacro{\C}{acos((\lc pt*\lc pt-\lb pt*\lb pt-\la pt*\la pt)/(-2*\lb pt*\la pt))};
\pgfmathsetmacro{\tC}{\C/3};

%----------------------------------------------------
% Computing intersections of trisector lines
%----------------------------------------------------
\coordinate (A1) at ($(A)!100*max(\lb pt,\lc pt)!\tA:(B)$);
\coordinate (A2) at ($(A)!100*max(\lb pt,\lc pt)!2*\tA:(B)$);
\coordinate (B1) at ($(B)!100*max(\la pt,\lc pt)!\tB:(C)$);
\coordinate (B2) at ($(B)!100*max(\la pt,\lc pt)!2*\tB:(C)$);
\coordinate (C1) at ($(C)!100*max(\la pt,\lb pt)!\tC:(A)$);
\coordinate (C2) at ($(C)!100*max(\la pt,\lb pt)!2*\tC:(A)$);

%----------------------------------------------------
% Computing coordinates of vertices O, P and Q of 
% the Morley's triangle 
%----------------------------------------------------
\coordinate (O) at (intersection of C--C1 and A--A2);
\coordinate (P) at (intersection of A--A1 and B--B2);
\coordinate (Q) at (intersection of B--B1 and C--C2);

%----------------------------------------------------
% Drawing triangles and trisectors
%----------------------------------------------------
\tkzMarkAngle[size=1,fill=green!80](B,A,A1)
\tkzMarkAngle[size=.9,fill=green!80](A1,A,A2)
\tkzMarkAngle[size=.8,fill=green!80](A2,A,C)
\tkzMarkAngle[size=1,fill=blue!80](C,B,B1)
\tkzMarkAngle[size=.9,fill=blue!80](B1,B,B2)
\tkzMarkAngle[mkpos=.2,size=.8,fill=blue!80](B2,B,A)
\tkzMarkAngle[size=1,fill=red!80](A,C,C1)
\tkzMarkAngle[size=.9,fill=red!80](C1,C,C2)
\tkzMarkAngle[size=.8,fill=red!80](C2,C,B)

\draw (A)--(B)--(C)--cycle;
\draw[fill=orange, opacity=.4] 
   (O)--node[sloped]{\tiny{//}}
   (P)--node[sloped]{\tiny{//}}
   (Q)--node[sloped]{\tiny{//}}(O);
\draw (A)--(O) (A)--(P) (B)--(P) (B)--(Q) (C)--(Q) (C)--(O);

%----------------------------------------------------
% Caption
%----------------------------------------------------
\node[rounded corners, fill=purple!20,anchor=south east] at (3,3) 
   {\begin{minipage}{5cm}
 \textbf{Morley's triangle}\newline In any triangle, trisector 
 lines intersect in 3 points that are vertices of an 
 equilateral triangle.
   \end{minipage}};

\end{tikzpicture}

\end{document}

所以,不再接受投诉!好吧,只是开个玩笑…… ;)

相关内容