Last active
September 26, 2023 11:42
-
-
Save omaraflak/2e8e7042e1b388a65bbfea6aa93658c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
width = 300 | |
height = 200 | |
camera = np.array([0, 0, 1]) | |
ratio = float(width) / height | |
screen = (-1, 1 / ratio, 1, -1 / ratio) # left, top, right, bottom | |
image = np.zeros((height, width, 3)) | |
for i, y in enumerate(np.linspace(screen[1], screen[3], height)): | |
for j, x in enumerate(np.linspace(screen[0], screen[2], width)): | |
# image[i, j] = ... | |
print("progress: %d/%d" % (i + 1, height)) | |
plt.imsave('image.png', image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, nothing is written in the image. It's part of an article:
https://medium.com/swlh/ray-tracing-from-scratch-in-python-41670e6a96f9?sk=4edf81600f5c0941aa58907bbfb2151d