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 want to create two angled lines in my free-body diagram, but one of them jumps around the page when I give it an angle. Why is that and how can I solve it? Here is the MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\title{42}
\author{Jane Doe}
\date{June 2011}

\begin{document}

\begin{tikzpicture}
  \draw(0,0) circle (0.25cm);
  \draw(4,0) circle (0.25cm);
  \draw[->] (0,0) -- (-1,0) node[above,near end] {$\vec{F_{21}}$};
  \draw[->] (4,0) -- (5,0) node[above,near end] {$\vec{F_{12}}$};
  \draw[->] (0,0) -- (0,-0.5) node[right,near end] {$\vec{W}$};
  \draw[->] (4,0) -- (4,-0.5) node[left,near end] {$\vec{W}$};
  \draw[->,rotate=70] (0,0) -- (1,0) node[right,near end] {$\vec{T}$};
  \draw[->,rotate=-70] (4,0) -- (3,0) node[left,near end] {$\vec{T}$};
\end{tikzpicture}

\end{document}
share|improve this question
1  
Welcome to TeX.sx! To highlight code in posts here, simply select it and click the button marked {}. This indents blocks of code by four spaces, or puts backticks around words. –  Torbjørn T. Feb 5 '13 at 20:08

2 Answers 2

up vote 7 down vote accepted

You rotate that line around (0,0). You could use rotate around={-70:(4,0)}, but it is easier to use

  • relative and
  • polar

coordinates.

The the example below I named (0,0) cleft and the point 4 units to its right cright. Then I places all line end relative (++) to them. The syntax (<angle>:<length>) denotes polar coordinates.

Code

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw (0,0) coordinate (cleft) circle (0.25cm);
  \draw ([xshift=4] cleft) coordinate (cright) circle (0.25cm);
  \draw[->] (cleft)  -- ++(180:1) node[above,near end] {$\vec{F_{21}}$};% or ++(-1,0)
  \draw[->] (cright) -- ++(0:1) node[above,near end] {$\vec{F_{12}}$};  % or ++(1,0)
  \draw[->] (cleft)  -- ++(0,-0.5) node[right,near end] {$\vec{W}$};    % or ++(270:1)
  \draw[->] (cright) -- ++(0,-0.5) node[left,near end] {$\vec{W}$};     % or ++(90:-1)
  \draw[->] (cleft)  -- ++(70:1) node[right,near end] {$\vec{T}$};
  \draw[->] (cright) -- ++(180-70:1) node[left,near end] {$\vec{T}$};   % or ++(110:1)
                                                                        % or ++(-70:-1)
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer

There is another possibility. First the only problem in the original code is the rotation and the solution is the simple rotate around ={-70:(4,0)} but if I like the use of the polar and relative coordinates in some cases you need to transform xy coordinates in polar coordinates. It's possible but you need to make some calculations. You can use a scope. You can make all your drawings with origin (0,0) and then you use a shift

\documentclass{article}
\usepackage{tikz}

\begin{document}    
\begin{tikzpicture}
  \draw(0,0) circle (0.25cm);
  \draw[->] (0,0) -- (-1,0) node[above,near end] {$\vec{F_{21}}$};
  \draw[->] (0,0) -- (0,-0.5) node[right,near end] {$\vec{W}$};
  \draw[->] (0,0) -- (70:1) node[right,near end] {$\vec{T}$};

\begin{scope}[xshift=4cm]
  \draw(0,0) circle (0.25cm);
  \draw[->] (0,0) -- (1,0) node[above,near end] {$\vec{F_{21}}$};
  \draw[->] (0,0) -- (0,-0.5) node[left,near end] {$\vec{W}$};
  \draw[->] (0,0) -- (110:1) node[left,near end] {$\vec{T}$};
\end{scope}     
\end{tikzpicture}    
\end{document}
share|improve this answer

Your Answer

 
discard

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