6
\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usepackage{float}
\usetikzlibrary{calc, arrows}
\begin{document}
\begin{figure*}
\begin{tikzpicture}[fixed point arithmetic]
\pgfmathsetmacro{\d}{1.87529 * 4}
\pgfmathsetmacro{\Ly}{sqrt(3) * 2}
\pgfmathsetmacro{\Lx}{\d / 2}
\pgfmathsetmacro{\per}{1707 / 6378 * 4}

\coordinate (E) at (0, 0);
\coordinate (M) at (\d, 0);
\coordinate (L4) at (\Lx, \Ly);

\draw (E) -- (M);
\draw (E) -- (L4);
\draw (M) -- (L4) node[font = \scriptsize, above] {\(L_4\)};;
\draw[-latex] (E) -- (-45:2cm) node[below = .1cm, font = \scriptsize]
{\(v_r\)} coordinate (P1);
\filldraw[blue, opacity = .7] (E) circle (1cm);
\filldraw[gray, opacity = .7] (M) circle (.3cm);
\filldraw[green] (.7 * \per, 0) circle (.075cm);
\node[font = \scriptsize] at (\Lx + 2, \Ly)
{\((187529, 332900.1652, 0)\)};
\draw[dashed, thick] (E) circle (1.2cm);
\draw[dashed, thick, red] ([shift = (E)] -45:1.2cm) .. controls (3, 1)
and (-4, 5) .. (L4);

\draw let
  \p0 = (E),
  \p1 = (P1),
  \p2 = (M),
  \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
  \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
  \n3 = {2cm},
  \n4 = {(\n1 + \n2) / 2}
in (E) + (\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[fill = white, inner sep = 0cm, font = \scriptsize] at ([shift = (E)]
\n4:\n3) {\(\nu = -\frac{\pi}{4}\)};
\end{tikzpicture}
\end{figure*}
\end{document}

I have tried constructing this curve by using controls in draw but it didn't quite work out. Maybe there is a better way than this but I don't know.

So the flight path would start at the dotted circle and vector v_r and end at the location L_4. In the Python code, I plotted the solution longer than needed.

enter image description here

Here is the current image but the curve I would like to add is picture below:

enter image description here


Edit 2:

So I have constructed a somewhat decent curve but I am hoping someone can help it look a little better still. Also, I have changed the screen shot. Why is the figure not centering and is skewed to the right?

5
  • Do you have a mathematical description of the curve, or do you just want something that looks like it?
    – Jake
    Jun 28, 2013 at 18:09
  • I meant how precisely do you want to reproduce that within the TikZ picture?
    – Jake
    Jun 28, 2013 at 18:14
  • 1
    It can't solve them (at least not as far as I know), but seeing you've solved them in Python, you could export a list of coordinates and plot those in your tikzpicture.
    – Jake
    Jun 28, 2013 at 18:18
  • So you just want to draw a curved path that looks roughly like the second picture in your post, right?
    – Jake
    Jun 28, 2013 at 18:24
  • 1
    I'm not entirely sure how the two pictures are related: I guess the blue circle is the same in both, but how does the red path from the second picture fit into the first picture? Does it have to end at a particular place? Does the path have to start out in a particular direction (in line with the arrow, perhaps)? Maybe you could include a mock-up of the final picture?
    – Jake
    Jun 28, 2013 at 18:28

1 Answer 1

5

If you draw the bounding box for your tikzpicture (after adding \centering and a test caption):

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usepackage{float}
\usetikzlibrary{calc, arrows}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}%[fixed point arithmetic]
\pgfmathsetmacro{\d}{1.87529 * 4}
\pgfmathsetmacro{\Ly}{sqrt(3) * 2}
\pgfmathsetmacro{\Lx}{\d / 2}
\pgfmathsetmacro{\per}{1707 / 6378 * 4}

\coordinate (E) at (0, 0);
\coordinate (M) at (\d, 0);
\coordinate (L4) at (\Lx, \Ly);

\draw (E) -- (M);
\draw (E) -- (L4);
\draw (M) -- (L4) node[font = \scriptsize, above] {\(L_4\)};;
\draw[-latex] (E) -- (-45:2cm) node[below = .1cm, font = \scriptsize]
{\(v_r\)} coordinate (P1);
\filldraw[blue, opacity = .7] (E) circle (1cm);
\filldraw[gray, opacity = .7] (M) circle (.3cm);
\filldraw[green] (.7 * \per, 0) circle (.075cm);
\node[font = \scriptsize] at (\Lx + 2, \Ly)
{\((187529, 332900.1652, 0)\)};
\draw[dashed, thick] (E) circle (1.2cm);
\draw[dashed, thick, red] ([shift = (E)] -45:1.2cm) .. controls (3, 1)
and (-4, 5) .. (L4);

\draw let
  \p0 = (E),
  \p1 = (P1),
  \p2 = (M),
  \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
  \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
  \n3 = {2cm},
  \n4 = {(\n1 + \n2) / 2}
in (E) + (\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[fill = white, inner sep = 0cm, font = \scriptsize] at ([shift = (E)]
\n4:\n3) {\(\nu = -\frac{\pi}{4}\)};
\draw 
  (current bounding box.north west) 
  rectangle 
  (current bounding box.south east) ;
\end{tikzpicture}
\caption{A test caption}
\end{figure*}
\end{document}

you get:

enter image description here

which shows that the bounding box is centered, but something is contributing to it, besides what actually appears in the drawing. Where does this contribution come from? The answer is: from one of your control points (simply place two visible elements at the coordinates used as control points and you'll see this clearly).

You could interrupt the bounding box:

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usepackage{float}
\usetikzlibrary{calc, arrows}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}%[fixed point arithmetic]
\pgfmathsetmacro{\d}{1.87529 * 4}
\pgfmathsetmacro{\Ly}{sqrt(3) * 2}
\pgfmathsetmacro{\Lx}{\d / 2}
\pgfmathsetmacro{\per}{1707 / 6378 * 4}

\coordinate (E) at (0, 0);
\coordinate (M) at (\d, 0);
\coordinate (L4) at (\Lx, \Ly);

\draw (E) -- (M);
\draw (E) -- (L4);
\draw (M) -- (L4) node[font = \scriptsize, above] {\(L_4\)};;
\draw[-latex] (E) -- (-45:2cm) node[below = .1cm, font = \scriptsize]
{\(v_r\)} coordinate (P1);
\filldraw[blue, opacity = .7] (E) circle (1cm);
\filldraw[gray, opacity = .7] (M) circle (.3cm);
\filldraw[green] (.7 * \per, 0) circle (.075cm);
\node[font = \scriptsize] at (\Lx + 2, \Ly)
{\((187529, 332900.1652, 0)\)};
\draw[dashed, thick] (E) circle (1.2cm);
\begin{pgfinterruptboundingbox}
\draw[dashed, thick, red] ([shift = (E)] -45:1.2cm) .. controls (3, 1)
and (-4, 5) .. (L4);
\end{pgfinterruptboundingbox}

\draw let
  \p0 = (E),
  \p1 = (P1),
  \p2 = (M),
  \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
  \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
  \n3 = {2cm},
  \n4 = {(\n1 + \n2) / 2}
in (E) + (\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[fill = white, inner sep = 0cm, font = \scriptsize] at ([shift = (E)]
\n4:\n3) {\(\nu = -\frac{\pi}{4}\)};
\draw 
  (current bounding box.north west) 
  rectangle 
  (current bounding box.south east) ;
\end{tikzpicture}
\caption{A test caption}
\end{figure*}
\end{document}

enter image description here

or choose different control points inside the bounding box; for example:

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usepackage{float}
\usetikzlibrary{calc, arrows}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}%[fixed point arithmetic]
\pgfmathsetmacro{\d}{1.87529 * 4}
\pgfmathsetmacro{\Ly}{sqrt(3) * 2}
\pgfmathsetmacro{\Lx}{\d / 2}
\pgfmathsetmacro{\per}{1707 / 6378 * 4}

\coordinate (E) at (0, 0);
\coordinate (M) at (\d, 0);
\coordinate (L4) at (\Lx, \Ly);

\draw (E) -- (M);
\draw (E) -- (L4);
\draw (M) -- (L4) node[font = \scriptsize, above] {\(L_4\)};;
\draw[-latex] (E) -- (-45:2cm) node[below = .1cm, font = \scriptsize]
{\(v_r\)} coordinate (P1);
\filldraw[blue, opacity = .7] (E) circle (1cm);
\filldraw[gray, opacity = .7] (M) circle (.3cm);
\filldraw[green] (.7 * \per, 0) circle (.075cm);
\node[font = \scriptsize] at (\Lx + 2, \Ly)
{\((187529, 332900.1652, 0)\)};
\draw[dashed, thick] (E) circle (1.2cm);
\draw[dashed, thick, red] ([shift = (E)] -45:1.2cm) .. controls (3, 1)
and (-1, 5) .. (L4);

\draw let
  \p0 = (E),
  \p1 = (P1),
  \p2 = (M),
  \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
  \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
  \n3 = {2cm},
  \n4 = {(\n1 + \n2) / 2}
in (E) + (\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[fill = white, inner sep = 0cm, font = \scriptsize] at ([shift = (E)]
\n4:\n3) {\(\nu = -\frac{\pi}{4}\)};

\draw 
  (current bounding box.north west) 
  rectangle 
  (current bounding box.south east) ;
\end{tikzpicture}
\caption{A test caption}
\end{figure*}
\end{document}

enter image description here

Here's another possibility with a modification for the curved path:

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usepackage{float}
\usetikzlibrary{calc, arrows}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}%[fixed point arithmetic]
\pgfmathsetmacro{\d}{1.87529 * 4}
\pgfmathsetmacro{\Ly}{sqrt(3) * 2}
\pgfmathsetmacro{\Lx}{\d / 2}
\pgfmathsetmacro{\per}{1707 / 6378 * 4}

\coordinate (E) at (0, 0);
\coordinate (M) at (\d, 0);
\coordinate (L4) at (\Lx, \Ly);

\draw (E) -- (M);
\draw (E) -- (L4);
\draw (M) -- (L4) node[font = \scriptsize, above] {\(L_4\)};;
\draw[-latex] (E) -- (-45:2cm) node[below = .1cm, font = \scriptsize]
{\(v_r\)} coordinate (P1);
\filldraw[blue, opacity = .7] (E) circle (1cm);
\filldraw[gray, opacity = .7] (M) circle (.3cm);
\filldraw[green] (.7 * \per, 0) circle (.075cm);
\node[font = \scriptsize] at (\Lx + 2, \Ly)
{\((187529, 332900.1652, 0)\)};
\draw[dashed, thick] (E) circle (1.2cm);

\begin{pgfinterruptboundingbox}
\draw[dashed, thick, red] 
  ([shift = (E)] -45:1.2cm) to[out=60,in=-60] (1.3,1.4) 
  .. controls (0.3,2.5) and (1.2,4.8) ..  
  (L4);
\end{pgfinterruptboundingbox}

\draw let
  \p0 = (E),
  \p1 = (P1),
  \p2 = (M),
  \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
  \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
  \n3 = {2cm},
  \n4 = {(\n1 + \n2) / 2}
in (E) + (\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[fill = white, inner sep = 0cm, font = \scriptsize] at ([shift = (E)]
\n4:\n3) {\(\nu = -\frac{\pi}{4}\)};

%\draw 
%  (current bounding box.north west) 
%  rectangle 
%  (current bounding box.south east) ;
\end{tikzpicture}
\caption{A test caption}
\end{figure*}
\end{document}

enter image description here

2
  • Also do you know to better fit my curve to the simulated curve?
    – dustin
    Jul 10, 2013 at 22:53
  • @dustin I added another option to my answer. You still can play with different combinations of controls and/or the to[in=,out=] syntax. However, I think I more sensible approach would be to let an external program (Geogebra, for example) calculate some coordinates for the path you want, and then use those coordinates. Jul 10, 2013 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .