Rotate a path around a point: Double Pendulum Case

A double pendulum is a simple physical system which consists of two pendula, one of which hangs off of the second. We find it interesting to show how one could rotate a path around a specific point (end of the first pendulim in this case) in LaTeX using TikZ package. In this tutorial, we will redraw the next illustration, a simple version brought from Wikipedia.

  

1. Choose the origine for your illustration...

Choosing the starting point of your illustration is crucial as it makes your coding journey easy or taugh. For rotating objects, it is better to use polar coordinates (r,\theta) instead of cartesian coordinates (x,y). From the above illustration, the best choice of the origin is the rotation center of the first pendulum and from there we could easily draw the following parts: 

  • Two small circles; 
  • Two rectangles filled with red color; 
  • Two weight arrows with labels
  • Horizontal line; 
  • Two states of the pendulum with transparency effect. 

2. Equilibrum position of the Pendulum

To make it easy, we will draw the pendulum at the stable equilibrium position and we can rotate each part later. Next figure hilights different elements with dimensions. Let's start with the simplest path:

a. Draw a straight line in LaTeX using Tikz:

We use the draw command to draw athe horizontal line which starts from (-1,0) and ends at (1,0) as follows:

\draw (-1,0) -- (1,0);

b. Draw a rectangle in LaTeX using Tikz:

We need to draw two rectangles with 0.4cm width and 3.5cm height. A rectangle can be drawn in LaTeX using the coordinates of a corner and its opposite as follows:

Compound Pendulum Tikz Latex

Equilibrium Position of the Pendulum

\draw[fill=red] (-0.2,0) rectangle (0.2,-3.5);
\draw[fill=red] (-0.2,-3.5) rectangle (0.2,-7);

c. Add a node at the center of a rectangle in LaTeX using TikZ:

In this part, we will draw two small circles filled with black at the center of each rectangle. These two circles can be considered as bullet points which can be obtained using the command \verb|$\bullet$| as a node text as below: 

\draw[fill=red] (-0.2,0) rectangle (0.2,-3.5) node[midway](a){$\bullet$};
\draw[fill=red] (-0.2,-3.5) rectangle (0.2,-7)node[midway](b){$\bullet$};

The node is positioned in the middle of the rectangle's diagonal using the option \verb|midway|. Besides, we have saved the coordinates of both bullets in (a) and (b) to be used later to draw weight vectors.

d. Draw a circle in LaTeX using TikZ

Circles can be draw in TikZ by the mean of a center coordinates and a radius. We need to draw two small circles (0.1cm radius) at the points (0,0) and (0,-3.5) with white filling as follows:

\draw[fill=white] (0,-3.5) circle(0.1);
\draw[fill=white] (0,0) circle(0.1);

3. How rotation works in TikZ

The double pendulum has two rotation angles, one that affects the two pendula, let's called it \alpha and one that affects only the lower pendulum, let's called it \beta.

a. Rotate a block of paths:

By varying the angle \alpha, we rotate both rectangles and the small circle drawn at the position (0,-3.5). To apply the same rotation to these elements, we put them inside a scope environment with a \verb|rotate| option as below:

\begin{scope}[rotate=20]

\draw[fill=red] (-0.2,0) rectangle (0.2,-3.5) node[midway](a){$\bullet$};
\draw[fill=red] (-0.2,-3.5) rectangle (0.2,-7)node[midway](b){$\bullet$};
\draw[fill=white] (0,-3.5) circle(0.1);

\end{scope}


b. Rotate a path around a point:

The above solution can be adopted for a simple Pendulum. However, for the double pendulum, we need to rotate the second around the link point. In this case, it corresponds to a rotation around the point with coordinates (0,-3.5). To this end, we modify slightly the above line codes

Rotation around a point

\begin{scope}[rotate=20]

\draw[fill=red] (-0.2,0) rectangle (0.2,-3.5) node[midway](a){$\bullet$};
\draw[fill=red,rotate around={20:(0,-3.5)}] (-0.2,-3.5) rectangle (0.2,-7)node[midway](b){$\bullet$};
\draw[fill=white] (0,-3.5) circle(0.1);

\end{scope}

We used \verb|rotate around={angle:(point)}| which has two parameters: the rotation angle and the center of rotation.

4. Draw a line with relative coordinates

To draw a line which ends with an arrow, we use [-latex]. As the weight vector is not affected by the Pendulum rotation angles, then it has to be drawn outside the scope environment. The starting points are already defined ((a) and (b)) but the end points are not. As the Pendulum is rotating, we can not use absolute coordinates. For that, we use a relative coordinates by saying draw a vector that starts from point (a) and ends at a point with 0 increase in x and 1cm decrease in y.


\draw[-latex,very thick] (a.center) -- ++(0,-1.5) node[midway,left]{$mg$};
\draw[-latex,very thick] (b.center) -- ++(0,-1.5) node[midway,left]{$mg$};

We have added a label to the weight vector using a node with the options: midway (middle of the vector), left (left position).  

The transparent two states of the double pendulum are only copy and paste of the scope environment and by changing the satruation of colours from black and red to black!3 and red!3 respectively. Here is the full latex code of Today's illustration: 

\documentclass[border=0.1cm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[thick]

\begin{scope}[rotate=-10,black!3]
\draw[fill=red!3] (-0.2,0) rectangle (0.2,-3.5);
\draw[fill=red!3,rotate around={-30:(0,-3.5)}] (-0.2,-3.5) rectangle (0.2,-7);
\draw[fill=white] (0,-3.5) circle(0.1);
\end{scope}

\begin{scope}[rotate=5,black!3]
\draw[fill=red!3] (-0.2,0) rectangle (0.2,-3.5);
\draw[fill=red!3,rotate around={-20:(0,-3.5)}] (-0.2,-3.5) rectangle (0.2,-7);
\draw[fill=white] (0,-3.5) circle(0.1);
\end{scope}

\draw (-1,0) -- (1,0);

\begin{scope}[rotate=20]
\draw[fill=red] (-0.2,0) rectangle (0.2,-3.5) node[midway](a){$\bullet$};
\draw[fill=red,rotate around={20:(0,-3.5)}] (-0.2,-3.5) rectangle (0.2,-7)node[midway](b){$\bullet$};;
\draw[fill=white] (0,-3.5) circle(0.1);
\end{scope}

\draw[-latex,very thick] (a.center) -- ++(0,-1.5) node[midway,left]{$mg$};
\draw[-latex,very thick] (b.center) -- ++(0,-1.5) node[midway,left]{$mg$};

\draw[fill=white] (0,0) circle(0.1);

\end{tikzpicture}

\end{document}

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu