Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Diagram of geodesics in the Poincare Upper Half-Plane
%% --------------------------------------------------------------
%% Code for the diagram in a twitter thread about Lobachevsky.
%% Tweet: https://twitter.com/mcnees/status/1333812403218354177
%% --------------------------------------------------------------
\documentclass[crop=true, border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathrsfs}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
% A few colors
%--------------------------------------------------------------
\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4}
\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529}
\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941}
\definecolor{scarlet}{rgb}{0.8, 0, 0}
\definecolor{brick}{rgb}{0.64314, 0, 0}
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0}
\definecolor{lightblue}{rgb}{0.15,0.35,0.75}
%\pgfplotsset{width=7cm,compat=1.15}
\begin{document}
\pagestyle{empty}
%\begin{center}
\begin{tikzpicture}[scale=1.25,domain=0:13]
\tikzstyle{axisarrow} = [-{Latex[inset=0pt,length=7pt]}]
% Clip all lines that would fall outside the grid
\clip(-2,-1.25) rectangle (6,4);
% \draw[fill=plum!40,opacity=0.2] (4,-2) -- (8,-2) -- (8,13) -- (4,13) -- (4,-2);
% \draw[fill=scarlet!40,opacity=0.2] (-2,-10/4) -- (1,-10/4) -- (13.4,13) -- (10.4,13) -- (-2,-10/4);
% Draw the grid.
\draw [cornflower!30,step=0.2,thin] (-2,0) grid (6,4);
\draw [cornflower!60,step=1.0,thin] (-2,0) grid (6,4);
% \node[] at (6,-0.5) {Barn};
% \node[] at (1.25,-0.5) {Pole};
% Draw Axes
\draw[thick,axisarrow] (-1,-1) -- (-1,4);
\node[inner sep=0pt] at (-0.66,3.7) {$y$};
\draw[thick,axisarrow] (-2,0) -- (6,0);
\node[inner sep=0pt] at (5.75,+0.33) {$x$};
\draw [scarlet,thick,domain=1:3,samples=200] plot ({\x}, {sqrt(-(\x-2)^2 + 1 + (2-2)^2 )});
\draw [sunrise,thick,domain=1.3820:3.618,samples=200] plot ({\x}, {sqrt(-(\x-2.5)^2 + 1 + (2-2.5)^2 )});
\draw [chameleon,thick,domain=1.586:4.414,samples=200] plot ({\x}, {sqrt(-(\x-3)^2 + 1 + (2-3)^2 )});
\draw [plum,thick,domain=1.6973:5.303,samples=200] plot ({\x}, {sqrt(-(\x-3.5)^2 + 1 + (2-3.5)^2 )});
\node at (2,1) [circle,draw=cornflower!70,fill=cornflower!20,inner sep=1pt] {};
\node at (1.9,1.2) [] {$P$};
\node at (0.25,2.15) [] {$L$};
\draw[brick,thick] (0,0) -- (0,4);
\node at (1,-0.5) [] {$\displaystyle ds^2 = \frac{1}{y^2}\,(dx^2 + dy^2)$};
\node at (3.62,-0.5) [] {$\displaystyle x'(s) = c\,\,y(s)^2$};
\node at (4.25,-1) [] {$\displaystyle y'(s) = \sqrt{y(s)^2 - c^2\,y(s)^4}$};
\end{tikzpicture}
%\end{center}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment