None Euclidean_and_Lobachevsky_lines

Euclidean and Lobachevsky line: introducing MoebInv library

Installing required software

First we need to install require packages from the dedicated APT repository.

In [1]:
%%bash

DISTRO=` grep -e "^ID=" /etc/os-release | cut -d= -f2 `
# Execute this cell on Ubuntu only
if echo "ubuntu debian" | grep -qw "$DISTRO" ; then \
    echo "Continue on $DISTRO " ; \
else \
    echo 'Does not look like an Ubuntu/Debian box, exiting' ; \
    exit ; \
fi

# Check if the software is already installed
if dpkg -l python3-pymoebinv > /dev/null ; then \
    echo 'The package is already installed, exiting' ; \
    exit ; \
fi

# Install signature key of the Ubuntu/Debian repository
## apt-key is now obsolete
curl -L https://sourceforge.net/projects/moebinv/files/binary/$DISTRO/moebinv.gpg.key | \
gpg --dearmor > /etc/apt/trusted.gpg.d/moebinv-archive-keyring.gpg

## An alternative installation with a keyring package.
#cd /tmp;\
#wget --backups=1 https://sourceforge.net/projects/moebinv/files/binary/$DISTRO/moebinv-archive-keyring_0.2_all.deb && \
#dpkg -i moebinv-archive-keyring_0.2_all.deb

# Add Ubuntu/Debian repository to known sources
CODENAME=`grep -e "VERSION_CODENAME" /etc/os-release | cut -d= -f2`
echo "deb https://sourceforge.net/projects/moebinv/files/binary/$DISTRO $CODENAME main" > \
     /etc/apt/sources.list.d/moebinv.list 

# Update the contents of the repository
apt update 

# Install required packages and their dependencies
apt-get -q -y install asymptote python3-pymoebinv

# Copy useful initialisation file to the current directory
zcat /usr/share/doc/python3-pymoebinv/EPAL-v1/init_cycle.py.gz > init_cycle.py
Continue on debian 
The package is already installed, exiting

If you are going to use examples from EPAL-v1 folder you will need also Python file which initialises many common variables which is copied in the last line of the above script.

The same command will install MoebInv library on your Ubuntu-18.04/Debian-10/etc desktop Linux-x86-64 (amd64) box.

You can cleanly uninstall the above software at any time as explained in the section Uninstallation below.

Using the library

Once everything is installed we can use MoebInv. To start, we need to load and initialise respective libraries.

In [2]:
from IPython.display import Image
from figure import *
show_asy_off()
            Python wrappers for MoibInv Library
     ---------------------------------------------
Please cite this software as
V.V. Kisil, MoebInv: C++ libraries for manipulations in non-Euclidean geometry, SoftwareX, 11(2020),100385. doi:10.1016/j.softx.2019.100385.
     ---------------------------------------------

Now we initialise the figure $F$ with a default Euclidean metric.

In [3]:
F=figure()

We add two points $A$ and $B$ to the figure providing their explicit coordinates.

In [4]:
A=F.add_point([-.25,.7],"A")
B=F.add_point([1,1],"B")

We add the Euclidean line $e$ passing $A$ and $B$: it is orthogonal to these to points as well as the infinity $\infty$.

In [5]:
e=F.add_cycle_rel([is_orthogonal(A),is_orthogonal(B),is_orthogonal(F.get_infinity())],"e")

The Lobachevsky line $l$ is similarly defined, but it is orthogonal to the real line $\mathbb{R}$ rather than $\infty$.

In [6]:
l=F.add_cycle_rel([is_orthogonal(A),is_orthogonal(B),is_orthogonal(F.get_real_line())],"l")

Now we draw the picture.

In [7]:
F.asy_write(300,-.7,2,-2,2,"euclid_and_lobachevsky","png")
Image("euclid_and_lobachevsky.png")
Out[7]:
No description has been provided for this image

The same effect can be achived in one line with IPython Magic. On Google CoLab an additional one-off per notebook initialisation of magics is required:

In [8]:
%load_ext figure.figure_ipython

Now we can use the magic shortcut:

In [9]:
%asy_write F, 300, -.7, 2, -2,2, "euclid_and_lobachevsky"
Out[9]:
No description has been provided for this image

Uninstalation

If you do not need MoebInv anymore and want to uninstall it then execute the following cell. For this switch the type of the next cell to code and execute it.

!apt-get -qq remove -y python3-pymoebinv asymptote