Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

michell-raytracer-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

michell_raytracer-0.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file michell-raytracer-0.0.2.tar.gz.

File metadata

  • Download URL: michell-raytracer-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for michell-raytracer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3254a0f19aaa6a693f073e8834790909b96434f03e27e6227632fd628c6c6369
MD5 7cbf2f79d66e48660e866051fa8d779d
BLAKE2b-256 907b9ddba2f6c3d12d7c527c24388a97933cbf0bdea56eb1040fdca531c9533c

See more details on using hashes here.

File details

Details for the file michell_raytracer-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for michell_raytracer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9318408c37bc96430a55a554422700d37db8d4d38f59b35c4602634c01354bef
MD5 c3acd1f41edae05b0f46e7d239d08346
BLAKE2b-256 b26fb7913da0291a6a4fec6118a931f53b887d1c4302429d12b641444589c8d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page