- #1
Dustinsfl
- 2,281
- 5
So I am trying to get this code to do something else for the past few days and I am not making any head way. I don't have a question. I am just sharing code that anyone can play with to create there own transfers in TikZ.
You can change any of the pgfmathsetmacros to create your own ellipses. They should be self explanatory: \as and \bs are the semi-major and minor axis of the small ellipse and \c would be its focus. So \al and \bl are the larger ellipse. Don't mess with \xs or the definitions of \c and \cl.
You can change the angles in this code: (60 and 150 degrees)
You can change the doubleA here. However, to small will cause errors since there would be no transfer ellipse for that 2a value.
With the current setup, you will produce
View attachment 983
Code:
\documentclass[convert=false]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,backgrounds,decorations.markings,arrows}\begin{document}
\begin{tikzpicture}[>=triangle 45,every label/.append style={font=\scriptsize},
dot/.style={inner sep=0pt,shape=circle,draw=black,label={#1}},small dot/.style={minimum size=.05cm,dot={#1}},big dot/.style={minimum size=.1cm,dot={#1}}]
\tikzset{circle with radius/.style={shape=circle, inner sep=0pt,outer sep=0pt,minimum size={2*(#1)}}}
\coordinate (O) at (0, 0);
\pgfmathsetmacro{\as}{3}
\pgfmathsetmacro{\bs}{2.25}
\pgfmathsetmacro{\c}{sqrt(\as^2 - \bs^2)}
\pgfmathsetmacro{\al}{3.75}
\pgfmathsetmacro{\bl}{2.9}
\pgfmathsetmacro{\cl}{sqrt(\al^2 - \bl^2)}
\pgfmathsetmacro{\xs}{abs(\c - \cl)}
\coordinate (O) at (0, 0);
\node[fill=black,big dot={below left: \(F\)}] (F) at (\c, 0) {};
\path[name path global=line1] (\c, 0) -- ++(60:{\as} and \bs);
\path[name path global=line2] (\c, 0) -- ++(150:6cm);
\begin{scope}[decoration={markings,
mark=at position 0.25 with {\arrow{>}},
mark=at position 0.375 with {\node[draw,shape=circle,inner sep=.04cm,fill=white,font=\tiny] {\(1\)};},
mark=at position 0.75 with {\arrow{>}},}]
\draw[postaction=decorate,name path global=ell1,blue] (O) ellipse (\as cm and \bs cm);
\end{scope}
\begin{scope}[decoration={markings,
mark=at position 0.25 with {\arrow{>}},
mark=at position 0.6 with {\node[draw,shape=circle,inner sep=.04cm,fill=white,font=\tiny] {\(2\)};},
mark=at position 0.75 with {\arrow{>}},},
on background layer]
\draw[postaction = decorate, name path global = ell2, red] (-\xs, 0) ellipse (\al cm and \bl cm);
\end{scope}
\path[name intersections={of=line1 and ell1,by=P1}];
\node[fill=black,big dot={right: \(A\)}] (A) at (P1) {};
\path[name intersections={of=line2 and ell2, by=P2}];
\node[fill=black,big dot={above: \(B\)}] (B) at (P2) {};
\draw[blue] (F) -- (A);
\draw[red] (F) -- (B) node[font=\scriptsize,fill=white,inner sep=0cm,pos=.5] {\(r_B\)};
\begin{scope}[on background layer]
\draw[dashed,-latex] ($(-\al , 0) - (1, 0)$) -- ($(\al, 0) + (.5, 0)$) coordinate (P3);
\draw[dashed,-latex] ($(F) - (0, 3)$) -- ($(F) + (0, 3)$);
\end{scope}
\begin{scope}[declare function={doubleA=5.8cm;},decoration={markings,
mark=at position 0.175 with {\arrow{>}},
mark=at position 0.225 with {\node[draw,shape=circle,inner sep=.04cm,fill=white,font=\tiny] {\(3\)};}}]
\begin{pgfinterruptboundingbox}
\path let
\p1=($(A) - (F)$),
\p2=($(B) - (F)$),
\n1={veclen(\x1, \y1)},
\n2 = {veclen(\x2, \y2)}
in (A) node[name path global = aCircle, circle with radius = doubleA-\n1] {}
(B) node[name path global=bCircle,circle with radius=doubleA-\n2] {}
(F) node[name path global=fCircle,circle with radius=.5*doubleA] {};
\tikzset{name intersections={of=aCircle and bCircle,name=F'}}
\foreach \solA in {1,2} {
\path ($(F)!.5!(F'-\solA)$) coordinate (C'-\solA)
($(C'-\solA)!doubleA/2!(F)$) coordinate (xDir-\solA)
(F'-\solA) node[name path global/.expanded=f'Circle-\solA,circle with radius=.5*doubleA] {};} %!?
\foreach \solA in {1,2} { %!?
\path[name intersections={of=fCircle and f'Circle-\solA,by={yDir-\solA}}]
($(xDir-\solA)-(C'-\solA)$) coordinate (xDir'-\solA)
($(yDir-\solA)-(C'-\solA)$) coordinate (yDir'-\solA);}
\end{pgfinterruptboundingbox}
\foreach \solA in {1,2}
\draw[x=(xDir'-\solA),y=(yDir'-\solA),postaction=decorate,name path global=traj]
(C'-\solA) circle [radius = 1];
\end{scope}
\draw[on background layer,red] let
\p0 = (F),
\p1 = (B),
\p2 = (P3),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {.75cm},
\n4 = {(\n2 + \n1) / 2}
in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
node[font = \tiny, fill = white, inner sep = 0cm] at ([shift = (F)] \n4:\n3) {\(\nu_B\)};
\draw[blue] let
\p0 = (F),
\p1 = (A),
\p2 = (P3),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {.5cm},
\n4 = {(\n2 + \n1) / 2}
in (F) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2] node[font = \tiny, fill = white, inner sep = 0cm] at ([shift = (F)] \n4:.75cm) {\(\nu_A\)};
\end{tikzpicture}
\end{document}
You can change any of the pgfmathsetmacros to create your own ellipses. They should be self explanatory: \as and \bs are the semi-major and minor axis of the small ellipse and \c would be its focus. So \al and \bl are the larger ellipse. Don't mess with \xs or the definitions of \c and \cl.
You can change the angles in this code: (60 and 150 degrees)
Code:
\path[name path global=line1] (\c, 0) -- ++(60:{\as} and \bs); \path[name path global=line2] (\c, 0) -- ++(150:6cm);
You can change the doubleA here. However, to small will cause errors since there would be no transfer ellipse for that 2a value.
Code:
\begin{scope}[declare function={doubleA=5.8cm;},decoration={markings,
With the current setup, you will produce
View attachment 983