I want to use the example in http://www.texample.net/tikz/examples/morleys-triangle/. I changed the tkz-2d into tkz-euclide (as tkz-2d is superseeded by this package), but tkz-euclide doesn't know \tkzMathLength. How can I modify the code to get a working example?

  • If \tkzMathLength is doing what I understood, you can use veclen from calc library and customize it to make up your own length computing command. See pgf manual (v.3.10) p.537 for further details. – percusse Sep 18 '11 at 11:27
  • you are welcome. We should thank @Altermundus for that :) – percusse Sep 18 '11 at 17:18

In tkz-euclide the legth of a segment is determined via:

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

As you can see, you can also specify the unit in which you want the result. And, of course, don't forget the \ before <variableName>, when using it later in the code. :)

Edit: To avoid errors at compilation, you will need to specify the unit every time you use \<varialbleName>, e.g.:

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

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

Edit2: OK, here is the full working example, in case it doesn't work for somebody:

% 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







% 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{\B}{acos((\lb pt*\lb pt-\la pt*\la pt-\lc pt*\lc pt)/(-2*\la pt*\lc pt))};
\pgfmathsetmacro{\C}{acos((\lc pt*\lc pt-\lb pt*\lb pt-\la pt*\la pt)/(-2*\lb pt*\la pt))};

% 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

\draw (A)--(B)--(C)--cycle;
\draw[fill=orange, opacity=.4] 
\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) 
 \textbf{Morley's triangle}\newline In any triangle, trisector 
 lines intersect in 3 points that are vertices of an 
 equilateral triangle.



So, no more complaints will be accepted! All right, just kidding... ;)

  • thanks a lot. now I know how to get the length. But a new problem comes out, "Dimension too large", I change the length to cm, it doesn't work. sigh…… :) – Pig Cry Sep 18 '11 at 12:29
  • Hmmm... seems there is some extra detail that you need to take care of... and I overlooked it. Check the edit of my answer! – Count Zero Sep 18 '11 at 12:35
  • \tkzMarkAngle[mkpos=.2,size=.8,fill=blue!80](B2,B,A), without mkpos=.2, the code still has "Dimension too large" problem, but we can continue running the code and get the pdf file. Another way is to use \tkzFillAngle instead, \tkzFillAngle[size=.8,fill=blue!80](B2,B,A). – Pig Cry Sep 19 '11 at 4:33
  • @Pig Cry: That's right. It's documented in the tkz-euclide manual and is seen with small angles. The work-around I applied is also suggested by the author, @Altermundus. – Count Zero Sep 19 '11 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.