I'm learning how to draw diagrams with tikzpicture
and I am looking for some help to dynamically calculate some points. I've made the diagram below, but I am struggling to calculate the point U^* (0,-4)
and (6, -4)
dynamically. Along with the definition of the arcs at (0:45:2)
and at (0:-34:2)
. My initial inspiration was this diagram. MWE below
\documentclass[tikz,convert=false]{standalone}
\begin{document}
\begin{tikzpicture}[scale=0.22]
\coordinate (origo) at (0,0);
\coordinate (gs) at (12,12);
\coordinate (gi11) at (0,4);
\coordinate (gi12) at (12,8);
\coordinate (u) at (12,-8);
\scriptsize
% Draw the axis
\draw[help lines,->] (origo) -- (12,0) node (raxis) [right] {$r$};
\draw[help lines,->] (origo) -- (0,12) node (gaxis) [above] {$g$};
\draw[help lines,->] (origo) -- (0,-12) node (uaxis) [below] {$u$};
% Draw the two intersecting lines of g^s and g^i
\draw(origo) coordinate (gs_1) -- (gs) coordinate (gs_2) node[right]{$g^s$};
\draw(gi11) coordinate (gi_1) node[left, font=\tiny]{}--(gi12) coordinate (gi_2) node[above right]{$g^i$};
% Draw u
\draw(origo) coordinate (u_1)--(u) coordinate (u_1) node[above right]{$u$};
% Calculate the intersection of the lines gi_1--gi_2 and gs_1--gs_2% and store the coordinate in c.
\coordinate (c) at (intersection of gi_1--gi_2 and gs_1--gs_2);
% Draw dashed equilibrium line
\draw[gray, dashed] (0,-4) node[left] {$u^{*}$}--(6, -4) coordinate--(c |- raxis) node[below right] {$r^{*}$}--(c |- c)--(gaxis |- c) node[left]{$g^{*}$};
% Draw arc and label
\draw (0,0) ++(0:2) arc(0:45:2); % that the 45 is dynamically created
\node [right, font=\tiny] at (1.5,1.1) {$s_\pi$};
\draw (0,0) ++(0:2) arc(0:-34:2); % that the -34 is dynamically created
\node [right, font=\tiny] at (1.5,-.8) {$\frac{v}{\pi}$};
\end{tikzpicture}
\end{document}