[Xy-pic] arrow head direction

Ross Moore ross at ics.mq.edu.au
Tue Sep 6 03:58:20 CEST 2005

Hello Frank,

On 06/09/2005, at 1:54 AM, r8yjke202 at sneakemail.com wrote:

> Hello,
> my way to draw automata is to define the state positions and then  
> to draw the transitions, p.ex.:
> \[
> \xy
> %states
> (0,30)*{q_0}*\xycircle(3.5,3.5){-}="q0";
> (30,30)*{q_1}*\xycircle(3.5,3.5){-}="q1";
> (30,0)*{q_2}*\xycircle(3.5,3.5){-}="q2";
> %final state
> (0,0)*{q_3}*\xycircle(3.0,3.0){-}*\xycircle(3.5,3.5){-}="q3";
> %initial
> (-5,30)*+{} = "i";
> \ar @( l, r) "i"; "q0" <2pt>
> %transitions
> \ar @( r, l) "q0"; "q1" <2pt> ^{\txt{$a$}}
> \ar @(dr,ul) "q0"; "q2" <2pt>
> \ar @( d, u) "q1"; "q2" <2pt> ^{\txt{$b$}}
> \ar @(dl,ur) "q1"; "q3" <2pt>
> \ar @( l, r) "q2"; "q3" <2pt> ^{\txt{$c$}}
> \ar @(ul,dr) "q2"; "q0" <2pt>
> \ar @( d, u) "q3"; "q0" <2pt> ^{\txt{$d$}}
> \ar @(ur,dl) "q3"; "q1" <2pt>
> \endxy
> \]
> The problem is, that in three cases the arrow head points to the  
> wrong direction (q1->q3, q2->q0, q3->q1):

This problem is triggered by your use of modifiers such as  @(dl,ur)
which redundantly specify the in/out directions of the arrows.
These are redundant with straight arrows, since the direction that
you specify are the natural directions deducible from the source and  
of the arrows.
However, by specifying these directions, you are also requesting that  
draws a *curve* rather than using its straight-line methods. This  
in a nicely drawn curve with hundreds/thousands of individual points  
In you case they all happen to lie on a straight line, so Xy-pic does  
of extra calculations over what would normally be required for placing
straight line segments; this results in taking a longer time and more  

Nevertheless, getting the direction wrong for the arrow-head is must  
be a bug
(of sorts) in Xy-pic's curve coding, which seems to become apparent  
only in
this special case of a curve which is really straight.

By leaving out those  @(...) modifiers, the following code gives a  

\ar  "q0"; "q1" <2pt> ^{\txt{$a$}}
\ar  "q0"; "q2" <2pt>
\ar  "q1"; "q2" <2pt> ^{\txt{$b$}}
\ar  "q1"; "q3" <2pt>
\ar  "q2"; "q3" <2pt> ^{\txt{$c$}}
\ar  "q2"; "q0" <4pt>
\ar  "q3"; "q0" <2pt> ^{\txt{$d$}}
\ar  "q3"; "q1" <2pt>

But if you really do want to use curves, then try putting in a
small amount of real curvature; viz,

\ar @/^5pt/  "q0"; "q1" <2pt> ^{\txt{$a$}}
\ar  @/^5pt/  "q0"; "q2" <2pt>
\ar @/^5pt/  "q1"; "q2" <2pt> ^{\txt{$b$}}
\ar  @/^5pt/  "q1"; "q3" <2pt>
\ar @/^5pt/  "q2"; "q3" <2pt> ^{\txt{$c$}}
\ar  @/^5pt/ "q2"; "q0" <4pt>
\ar @/^5pt/  "q3"; "q0" <2pt> ^{\txt{$d$}}
\ar  @/^5pt/ "q3"; "q1" <2pt>

> http://img197.imageshack.us/img197/1327/wrong7wl.png
> Changing the position of q1 and q2 slightly (+1pt to the right)  
> leads to the right behaviour:
> http://img277.imageshack.us/img277/6443/right2sb.png
> So, is this a bug or a failure in my code?

The coding is awkward, but it does show up a possible bug in a situation
that normally isn't needed.

Thanks for the report,

     Ross Moore

> Greetings,
> Frank.
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic

Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the xy-pic mailing list