Kwasniok / python-nerte

non-euclidean ray tracing engine
2 stars 0 forks source link
non-euclidean-geometry python ray-tracing

Non-Euclidean Ray-Tracing Engine

unittest lint-pylint lint-mypy

Installation & Dependencies

NERTE requires Python 3.9+ with pip and the usage of a virtual environment (venv) is recommended.

Execute these commands to install the dependencies:

#! /usr/bin/bash

# create virtual environment for nerte
python -m venv .venv

# activate venv
source .venv/bin/activate

# optional: verification
which python
which pip
# both should return paths located within the .venv/bin directory

# install dependencies
pip install -r requirements.txt

For a detailed list of dependencies see this file.

Run

Example to run the script main.py:

#! /usr/bin/bash

# activate venv
source .venv/bin/activate

# execute script
cd src
python main.py

Demo

Use the following script to execute any of the demo scripts. The results can be found in the directory images.

#! /usr/bin/bash

# activate venv
source .venv/bin/activate

# ensure existence of output directory
mkdir -p images

# execute demo scripts
cd src
python demo_1.py
python demo_2.py
python demo_3.py
python demo_4.py

A similar script to demo_4.py was used to create the frames of this video:

https://user-images.githubusercontent.com/7516208/154743965-9d12a15c-f5ca-44ed-961c-6f2476496145.mp4

In this demo video, the geodesics are bend into non-straight lines. Throughout the video the strength of this bending is varied and in the middle of the video the space is flat. The algorithm operates numerically and approximates a light ray with short striaght segments. All segments are obtained via the Runge-Kutta algorithm based on the previous segment.

Run Tests

The unittests are performed by this script:

#! /usr/bin/bash

# activate venv
source .venv/bin/activate

# execute unittests
cd src
python run_tests.py