|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
question concerning coordinate transformationsHi,
I'm still in the process of converting old xy-pic diagrams into TikZ/PGF and ran into the following problem. Some diagrams are based on equilateral triangles being pasted together. Either I can compute the relevant coordinates explicitly: \begin{tikzpicture} [baseline=(current bounding box.east),scale=1.75] \node (00) at (0,0) {$A$}; \node (20) at (2*cos{30},-1) {$B$}; \node (01) at (cos{30},.5) {$C$}; \node (21) at (3*cos{30},-.5){$D$}; \draw[->] (00) -- node[auto]{$f$} (01); \draw[->] (01) -- node[auto]{$g$} (21); \draw[->] (00) -- node[auto]{$h$} (20); \draw[->] (20) -- node[auto,swap]{$k$} (21); \draw[->,out=-60,in=210] (00) to node[auto,swap,pos=.72]{$l$} (20); \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt} \draw[-implies] (cos{30}+.15,-.7) -- node[auto,swap]{$\tau$} (cos{30}+.15,-1); \end{tikzpicture} which is somewhat messy, or I could change to an appropriate coordinate system. Initially I tried to set the new x- and y-vectors separately, but found out that theses specifications influenced each other in unexpected ways. Actually, after setting the x-vector, the y-vector has to be specified in the already modified coordinate system. Then I tried the cm-method of specifying a matrix, which worked fine for positioning the vertices, but produced problems with the out= and in= angles for curved arrows. In particular, the target of the arrow "l" seems to be the south-east corner of "B", rather than the center of "B". Could this be a bug? Here are the examples with attempted coordinate transformations, first the cm-variant: \documentclass[a4paper,10pt]{article} \usepackage{tikz} \usetikzlibrary{arrows,calc} \begin{document} \centering \[\begin{tikzpicture} [baseline=(current bounding box.east), cm={cos{30},-.5,cos{30},.5,(0,0)},scale=1.75] \node (00) at (0,0) {$A$}; \node (20) at (2,0) {$B$}; \node (01) at (0,1) {$C$}; \node (21) at (2,1) {$D$}; \draw[->] (00) -- node[auto]{$f$} (01); \draw[->] (01) -- node[auto]{$g$} (21); \draw[->] (00) -- node[auto]{$h$} (20); \draw[->] (20) -- node[auto,swap]{$k$} (21); \draw[->,out=-30,in=-105] (00) to node[auto,swap,pos=.77]{$l$} (20); \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt} \draw[-implies] (1.25,-.1) -- node[auto,swap]{$\tau$} (1.55,-.4); \end{tikzpicture} \qquad \begin{tikzpicture} [baseline=(current bounding box.east), x={(-30:1)},y={(45:1.41)},scale=1.75] % both variants work % y={(cos{30},.5)},x={(2*cos{30},-1)},scale=1.75] \node (00) at (0,0) {$A$}; \node (20) at (2,0) {$B$}; \node (01) at (0,1) {$C$}; \node (21) at (2,1) {$D$}; \draw[->] (00) -- node[auto]{$f$} (01); \draw[->] (01) -- node[auto]{$g$} (21); \draw[->] (00) -- node[auto]{$h$} (20); \draw[->] (20) -- node[auto,swap]{$k$} (21); \draw[->,out=-60,in=-150] (00) to node[auto,swap,pos=.72]{$l$} (20); \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt} \draw[-implies] (1.25,-.1) -- node[auto,swap]{$\tau$} (1.55,-.4); \end{tikzpicture} \] \end{document} If somebody knows a better way of realizing these diagrams, please let me know. -- Jürgen |
|
|
Re: question concerning coordinate transformationsLe 3 oct. 2009 à 13:09, koslowj a écrit : > > If somebody knows a better way of realizing these diagrams, please > let me > know. Hi, (Sorry for my bad english) I don't know if my way is better ... Firstly, I think it's better to avoid the relevant coordinates explicitly. For example : \begin{tikzpicture}[ baseline=(current bounding box.east),scale=1.75] \node (00) at (0,0) {$A$}; \node (20) at (2,0) {$B$}; \node (01) at (0,1) {$C$}; \node (21) at (2,1) {$D$}; \draw[->] (00) to node[auto]{$f$} (01); \draw[->] (01) to node[auto]{$g$} (21); % (m1) \path[] (00) to node(m1){} (20); \draw[->] (00) to node[auto]{$h$} (20); \draw[->,auto] (20) to node[swap]{$k$} (21); \draw[->,out=-60,in=-120] (00) to node[label=below:$l$](m2){} (20); \draw[-implies,double distance=1.2pt] (m1) to node[auto,swap]{$\tau$} (m2); \end{tikzpicture} If I use a transformation, you are right : there is problem with the nodes and the cm transformation. Perhaps the transformation is applied to the intersection point of the curved arrows and the node. So, I used shorten >=10pt,shorten <=10pt and the anchor "center" but there is another problem (see the end of the mail) \begin{tikzpicture}[ baseline=(current bounding box.east),% scale=1.75,cm={cos{30},-.5,cos{30},.5,(0,0)}] \draw[help lines] (0,0) grid (3,2); \node (00) at (0,0) {$A$}; \node (20) at (2,0) {$B$}; \node (01) at (0,1) {$C$}; \node (21) at (2,1) {$D$}; \node (a) at ($(1,-sqrt(2)$) {$a$}; \draw[lightgray,->](00)--(a); \draw[lightgray,->](20)--(a); \draw[->] (00) to node[auto]{$f$} (01); \draw[->] (01) to node[auto]{$g$} (21); \path[] (00) to node(m1){} (20); \draw[->] (00) to node[auto]{$h$} (20); \draw[->,auto] (20) to node[swap]{$k$} (21); \draw[->,out=-60,in=-120,shorten >=10pt,shorten <=10pt]% (00.center) to node[label=below:$l$](m2){} (20.center); \draw[-implies,double distance=1.2pt] (m1) to node[auto,swap]{$\tau$} (m2); \end{tikzpicture} I don't know exactly how work x= ... and y=... with polar coordinates and options out =... and in = .... With cm, it's possible to use \draw[help lines] (0,0) grid (3,2); Perhaps you want exactly your first drawing and perhaps you want the tau curved arrow vertically. It's possible to calculate the intersection of tau with l (pgf 2 cvs) Another way is to place the first part of the drawing in a scope but it's not automatically \begin{tikzpicture}[ baseline=(current bounding box.east),scale=1.75] \begin{scope}[cm={cos{30},-.5,cos{30},.5,(0,0)}] \draw[help lines] (0,0) grid (3,2); \node (00) at (0,0) {$A$}; \node (20) at (2,0) {$B$}; \node (01) at (0,1) {$C$}; \node (21) at (2,1) {$D$}; \draw[->] (00) to node[auto]{$f$} (01); \draw[->] (01) to node[auto]{$g$} (21); \path[] (00) to node(m1){} (20); \draw[->] (00) to node[auto]{$h$} (20); \draw[->,auto] (20) to node[swap]{$k$} (21); \end{scope} \draw[reset cm,->,out=-80,in=-150,shorten >=8pt,shorten <=8pt]% (00.center) to node[pos=.60](m2){} (20.center); \draw[-implies,double distance=1.2pt] (m1) to node[auto,swap]{$\tau$} (m2) node[]{$a$}; \end{tikzpicture} but now there is another problem \draw[reset cm,->,out=-80,in=-150,red]% (00.center) to node[pos=.60](m2){} (20.center); instead of \draw[reset cm,->,out=-80,in=-150,shorten >=8pt,shorten <=8pt]% (00.center) to node[pos=.60](m2){} (20.center); gives a different arrow (perhaps it's normal) Conclusion: I prefer to avoid coordinates and to draw automatically the diagram but I seems there are some difficulties to use cm. Best Regards Alain Matthes ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |