Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to plot some arcs using tikz and the package tkz-euclide. However, it seems that the arcs do not end at the points where I want them to end. For example, consider the following code:

\documentclass[tikz,10pt,border=1pt]{standalone}
\usepackage{tkz-euclide}    % create figures based on Euclidean geometry
\usetkzobj{all}             % load all objects defined by tkz-euclide


\begin{document}
\begin{tikzpicture}

% define the points
\tkzDefPoint(0,1){A}
\tkzDefPoint(1.62,0){B}
\tkzDefPoint(0,-1){C}
\tkzCircumCenter(A,B,C)\tkzGetPoint{O}


% print the points
\fill[color=gray] (A) circle [radius=0.05] node[above] {A};
\fill[color=gray] (B) circle [radius=0.05] node[left]  {B}; 
\fill[color=gray] (C) circle [radius=0.05] node[above] {C};
\fill[color=gray] (O) circle [radius=0.05] node[left]  {O};


% print the arcs
\tkzDrawArc[color=green](O,C)(A)
\tkzDrawArc[color=red](O,A)(C)
\tkzDrawArc[color=blue](B,A)(C)
\tkzDrawArc[color=orange](A,C)(B)
\tkzDrawArc[color=black](C,B)(A)


\end{tikzpicture}
\end{document}

As shown in the picture, the arcs do not meet in point A and B, (as they should), but in point C (I do not know why it works only there?). What am I doing wrong?enter image description here

share|improve this question

4 Answers 4

up vote 6 down vote accepted

You have a typo in the B-coordinate. If instead you use

\tkzDefPoint(1.732,0){B}

then your diagram becomes:

enter image description here

As ABC is an equilateral triangle the real coordinate for B is (\sqrt{3),0)\approx(1.732,0).

This said, you would be much better off letting tikz do the thinking for you by using polar coordinates:

\tkzDefPoint(120:1){A}
\tkzDefPoint(0:1){B}
\tkzDefPoint(240:1){C}
share|improve this answer
    
Shouldn't matter though, arc is an arc. –  percusse Aug 13 at 14:48
    
@percusse It does matter: the arcs drawn by the OP intersect at different points. –  Andrew Aug 13 at 21:27
    
I mean it doesn't have to be a circular arc. –  percusse Aug 13 at 21:35

Why doing manual calculations? The problem (which has been explained in other answers) can be easily solved if instead of manual calculations one uses the tools provided by the package, so instead of the error-prone manual calculation of the third vertex B:

\tkzDefPoint(0,1){A}
\tkzDefPoint(1.62,0){B}
\tkzDefPoint(0,-1){C}

you should simply use \tkzDefTriangle with the equilateral option, so the third vertex is automatically (and appropriately calculated):

\tkzDefPoint(0,1){A}
\tkzDefPoint(0,-1){C}
\tkzDefTriangle[equilateral](A,C)
\tkzGetPoint{B}

The complete code:

\documentclass[tikz,10pt,border=1pt]{standalone}
\usepackage{tkz-euclide}    % create figures based on Euclidean geometry
\usetkzobj{all}             % load all objects defined by tkz-euclide


\begin{document}
\begin{tikzpicture}

% define the points
\tkzDefPoint(0,1){A}
%\tkzDefPoint(1.62,0){B}
\tkzDefPoint(0,-1){C}
\tkzDefTriangle[equilateral](A,C)\tkzGetPoint{B}
\tkzCircumCenter(A,B,C)\tkzGetPoint{O}


% print the points
\fill[color=gray] (A) circle [radius=0.05] node[above] {A};
\fill[color=gray] (B) circle [radius=0.05] node[left]  {B}; 
\fill[color=gray] (C) circle [radius=0.05] node[above] {C};
\fill[color=gray] (O) circle [radius=0.05] node[left]  {O};


% print the arcs
\tkzDrawArc[color=green](O,C)(A)
\tkzDrawArc[color=red](O,A)(C)
\tkzDrawArc[color=blue](B,A)(C)
\tkzDrawArc[color=orange](A,C)(B)
\tkzDrawArc[color=black](C,B)(A)


\end{tikzpicture}
\end{document}

The result:

enter image description here

share|improve this answer

We have to notice that here arc is an unfortunate abbreviation because it is actually a circular arc. An elliptical arc is always possible with given two points and two semi-axes. But here the syntax is allowing for only circular ones. Just to prove a point, there is a basic level \pgpatharcto command and I quickly hacked a version of it to include in the \tkzDrawArc scenarios.

Again, it is certainly not complete!

Long story short, as it is, \tkzDrawArc only draws circular arcs between two points. If they are not at the same distance from the selected center, then first point distance wins and the circular arc is drawn based on that distance.

\documentclass[tikz,10pt,border=1pt]{standalone}
\usepackage{tkz-euclide}    % create figures based on Euclidean geometry
\usetkzobj{all}             % load all objects defined by tkz-euclide

\makeatletter
\pgfkeys{/drawarc/varying radius/.code= {\global\def\tkz@numa{5}}}
\def\tkzDrawArcV{\pgfutil@ifnextchar[{\tkz@DrawArcV}{\tkz@DrawArcV[]}}
\def\tkz@DrawArc[#1](#2,#3)(#4){% 
\begingroup%
\pgfkeys{/drawarc/.cd,towards,delta=0}% 
\pgfqkeys{/drawarc}{#1}%  
\ifcase\tkz@numa%
   \tkzDrawArcN[#1](#2,#3)(#4)%  
\or% 1
   \tkzDrawArcRotate[#1](#2,#3)(#4)%  
\or% 2
   \tkzDrawArcAngles[#1](#2,#3)(#4)% 
   \or% 3
   \tkzDrawArcRAngles[#1](#2,#3)(#4)%
 \or% 4
   \tkzDrawArcR[#1](#2,#3)(#4)%
 \or% 5
   \tkzDrawArcV[#1](#2,#3)(#4)%
\fi%    
\endgroup%
}

\def\tkz@DrawArcV[#1](#2,#3)(#4){%
\begingroup%
  \tkzCalcLength(#2,#3)\tkzGetLength{tkz@radiusa}%
  \tkzCalcLength(#2,#4)\tkzGetLength{tkz@radiusb}%
  \tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@FirstAngle}%  
  \tkzFindSlopeAngle(#2,#4)\tkzGetAngle{tkz@SecondAngle}%
  \pgfkeys{/tikz/.search also={/drawarc}}%
  \pgf@process{\pgfpointanchor{#2}{center}}%
\pgfpathmoveto{\pgfpoint{\pgf@x}{\pgf@y}}%
  \pgf@process{\pgfpointanchor{#3}{center}}%
\pgfpatharcto{\tkz@radiusa}{\tkz@radiusb}{\tkz@FirstAngle}{0}{1}%{\pgfpoint{\pgf@x}{\pgf@y}}%
\pgfusepath{draw}%
\endgroup%
} 


\begin{document}
\begin{tikzpicture}

% define the points
\tkzDefPoint(0,1){A}
\tkzDefPoint(1.62,0){B}
\tkzDefPoint(0,-1){C}
\tkzDefPoint(3,1){E}

\tkzCircumCenter(A,B,C)\tkzGetPoint{O}


% print the points
\fill[color=gray] (A) circle [radius=0.05] node[above] {A};
\fill[color=gray] (B) circle [radius=0.05] node[left]  {B}; 
\fill[color=gray] (C) circle [radius=0.05] node[above] {C};
\fill[color=gray] (O) circle [radius=0.05] node[left]  {O};
\fill[color=gray] (E) circle [radius=0.05] node[left]  {E};

% print the arcs
\tkzDrawArc[color=green](O,C)(A)
\tkzDrawArc[color=red](O,A)(C)
\tkzDrawArc[varying radius](B,A)(C)
\tkzDrawArc[varying radius](E,A)(C)
\tkzDrawArc[varying radius](C,B)(A)


\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Andrew is totally right. However to answer the questions in you last sentence directly:

(I do not know why it works only there?). What am I doing wrong?

It works for the arcs (B,A)(C) and (O,A)(C) and (O,C)(A) because B and O have the same distances to A as to C which is needed to draw an arc.

The arcs (A,C)(B) and (C,B)(A) are just not possible because there is no circle with the center A that hits both C and B as they require different radii.

share|improve this answer
1  
Thank you for pointing that out! I did not recognize the symmetry inherent in the figure. –  klopps Aug 13 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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