Relativistic non-linear raytracer for Schwarzschild's metric.
Project description
Michell's Raytracer
Simple relativistic nonlinear raytracer named after John Michell, the first man to think about existence of black holes (he called them "dark stars").
It uses Schwarzschild's metric to implement calculations of rays paths near black hole.
Here are example of how to use this package:
import matplotlib.pyplot as plt
import numpy as np
from michell.raytracer import Raytracer
from michell.scene import Camera, Sphere, Ring, Scene
from michell.textures import ColorTexture, ImageTexture
blackhole_texture = ColorTexture(np.array([0, 0, 0]))
background_texture = ImageTexture("space.jpg")
ring_texture = ImageTexture("rings.jpeg")
blackhole = Sphere(np.array([0, 0, 0]), 1, blackhole_texture)
background = Sphere(np.array([0, 0, 0]), 8, background_texture, inverse=True)
ring = Ring(np.array([0, 0, 0]), (1.5, 4), np.array([0, 1, 0]), ring_texture)
camera = Camera(np.array([-7,0.5,0]), np.array([0, 0, 0]), np.array([0, 1, 0]), np.pi / 3)
scene = Scene(camera)
scene.push_entity(blackhole)
scene.push_entity(ring)
scene.push_entity(background)
raytracer = Raytracer(scene, (300, 200), (0.16, 8), curvature=3)
plt.imsave('output.png', raytracer.render())
Firstly we create textures for scene entities. Then we create scene entities. Next step is to create camera and scene. The last one before making raytracer is to push entities created earlier to scene's list of entities. And finally we create raytracer for rendering the scene we created few lines ago.
REMEMBER to put sphere in <0, 0, 0> to correctly render black hole.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file michell-raytracer-0.0.3.tar.gz
.
File metadata
- Download URL: michell-raytracer-0.0.3.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aeee99a1d59665d617a7f47b892604f40bf6323cc0a1d2dbd6ce1b70dd807802 |
|
MD5 | f459c5b564c38772178227ebf6fb748a |
|
BLAKE2b-256 | 156c10fb2f6284803a43c3cbfb5f5d5e6ee37904815eb1ea2113e0f9b448c170 |
File details
Details for the file michell_raytracer-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: michell_raytracer-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85695aaca5acca7ff49067bd7a8ab52dbdf06226367c5a4e24023d1521582c49 |
|
MD5 | e37d6500477d5f00e69d97796cd62855 |
|
BLAKE2b-256 | 785e61b32abb479165fa7458f886bd49ad986868a889bbba169dd405fbb895a4 |