how to draw an arc using \coordinate-s?

View: New views
6 Messages — Rating Filter:   Alert me  

how to draw an arc using \coordinate-s?

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

how to draw an arc using \coordinate-s?

Hi,

the following example isn't working:

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
 \coordinate (W1) at (-5:3cm) {};
 \coordinate (W2) at (5:3cm) {};
 \draw (W1) arc (W2);
\end{tikzpicture}
\end{document}

Since the \draw-line doesn't follow the syntax that's not suprising.
But how can I achieve the wanted arc?

Regards,

Juergen


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: how to draw an arc using \coordinate-s?

by André Valentin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Le 11 sept. 2009 à 15:04, Goebel, Juergen a écrit :

> Hi,
>
> the following example isn't working:
>
> \documentclass{minimal}
> \usepackage{tikz}
> \begin{document}
> \begin{tikzpicture}
>  \coordinate (W1) at (-5:3cm) {};
>  \coordinate (W2) at (5:3cm) {};
>  \draw (W1) arc (W2);
> \end{tikzpicture}
> \end{document}
>
> Since the \draw-line doesn't follow the syntax that's not suprising.
> But how can I achieve the wanted arc?

You must specify TWO angles:

  \draw (W1) arc (-5:5:3cm);




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: how to draw an arc using \coordinate-s?

by JL Diaz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 11, 2009 at 3:04 PM, Goebel, Juergen
<juergen.goebel@...> wrote:
> \begin{tikzpicture}
>  \coordinate (W1) at (-5:3cm) {};
>  \coordinate (W2) at (5:3cm) {};
>  \draw (W1) arc (W2);
> \end{tikzpicture}
>
> Since the \draw-line doesn't follow the syntax that's not suprising.
> But how can I achieve the wanted arc?

Your wanted arc is not fully specified. You gave two points and want
an arc which pass through them, but.. what is the radius?

To specify an arc three points are needed (or two plus the center, or
two plus the radius, assuming negative radios mean the center at the
other side...)

Saludos,
--JL Diaz

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: how to draw an arc using \coordinate-s?

by Alain Matthes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Le 11 sept. 2009 à 16:38, JL Diaz a écrit :

> On Fri, Sep 11, 2009 at 3:04 PM, Goebel, Juergen
> <juergen.goebel@...> wrote:
>> \begin{tikzpicture}
>> \coordinate (W1) at (-5:3cm) {};
>> \coordinate (W2) at (5:3cm) {};
>> \draw (W1) arc (W2);
>> \end{tikzpicture}
>>
>> Since the \draw-line doesn't follow the syntax that's not suprising.
>> But how can I achieve the wanted arc?

Hi

With O(0,0) I suppose you want the arc W1W2 with the center O.

The first solution is in the manual
\draw[red,thick] (W1) arc (-5:5:3 cm);

The second one is interesting but the angles
\AngleStart and \AngleEnd are not good : 355.08 and 4.91.
\tikzAngleOfLine is not correct perhaps the best solution would be
  to use fp.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}

\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (3,3);
  \coordinate (O) at (0 cm,0 cm);
  \coordinate (W1) at (-5:3cm);
  \coordinate (W2) at (5:3cm) ;
  \draw[red,thick] (W1) arc (-5:5:3 cm);
\end{tikzpicture}



\begin{tikzpicture}
\coordinate (O) at (0 cm,0 cm);
\coordinate (W1) at (-5:3cm);
\coordinate (W2) at (5:3cm) ;
\draw[->] (O)--(W1) (O)--(W2);
\tikzAngleOfLine(O)(W1){\AngleStart}
\tikzAngleOfLine(O)(W2){\AngleEnd}

\draw[red,thick] let \p1 = ($ (O) - (W1) $), \n2 = {veclen(\x1,\y1)}
    in   (W1) arc (\AngleStart-360:\AngleEnd:\n2);
\end{tikzpicture}
\end{document}

Best Regards

Alain Matthes
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Res: how to draw an arc using \coordinate-s?

by Flavio Costa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The bottomline is that one CANNOT draw an arc using only coordinates, because the first parameter to arc operation is a coordinate but the second is not. I tried myself trying to automate some arc-drawing stuff, I could make it work by using the Math Engine and macros.

Flavio Costa



----- Mensagem original ----
De: Alain Matthes <alain.matthes@...>
Para: JL Diaz <jldiaz@...>
Cc: pgf-users@...
Enviadas: Sexta-feira, 11 de Setembro de 2009 13:03:53
Assunto: Re: [Pgf-users] how to draw an arc using \coordinate-s?

With O(0,0) I suppose you want the arc W1W2 with the center O.

The first solution is in the manual
\draw[red,thick] (W1) arc (-5:5:3 cm);

The second one is interesting but the angles
\AngleStart and \AngleEnd are not good : 355.08 and 4.91.
\tikzAngleOfLine is not correct perhaps the best solution would be
  to use fp.
...



      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: how to draw an arc using \coordinate-s?

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alain Matthes wrote:

> With O(0,0) I suppose you want the arc W1W2 with the center O.

Yes, you're absolutely right.  Sorry for the incomplete question.  

> The first solution is in the manual
> \draw[red,thick] (W1) arc (-5:5:3 cm);

ACK, but I'd like to use the two coordinates without repeating
the values.

> The second one is interesting but the angles
> \AngleStart and \AngleEnd are not good : 355.08 and 4.91.
> \tikzAngleOfLine is not correct perhaps the best solution would be
>   to use fp.

I'll have to see, if this is really necessary.

> \documentclass{minimal}
> \usepackage{tikz}
> \usetikzlibrary{calc}
>
> \newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
> \def\tikz@AngleOfLine(#1)(#2)#3{%
> \pgfmathanglebetweenpoints{%
> \pgfpointanchor{#1}{center}}{%
> \pgfpointanchor{#2}{center}}
> \pgfmathsetmacro{#3}{\pgfmathresult}%
> }
>
> \begin{document}
> \begin{tikzpicture}
> \draw[help lines] (0,0) grid (3,3);
>   \coordinate (O) at (0 cm,0 cm);
>   \coordinate (W1) at (-5:3cm);
>   \coordinate (W2) at (5:3cm) ;
>   \draw[red,thick] (W1) arc (-5:5:3 cm);
> \end{tikzpicture}
>
>
>
> \begin{tikzpicture}
> \coordinate (O) at (0 cm,0 cm);
> \coordinate (W1) at (-5:3cm);
> \coordinate (W2) at (5:3cm) ;
> \draw[->] (O)--(W1) (O)--(W2);
> \tikzAngleOfLine(O)(W1){\AngleStart}
> \tikzAngleOfLine(O)(W2){\AngleEnd}
>
> \draw[red,thick] let \p1 = ($ (O) - (W1) $), \n2 = {veclen(\x1,\y1)}
>     in   (W1) arc (\AngleStart-360:\AngleEnd:\n2);
> \end{tikzpicture}
> \end{document}

Thanks a lot, that does the trick!

Juergen

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users