@phoopio/

ray tracing

Python

trace those rays

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# x_circle = 
# y_circle = 
# x_camera = 
# y_camera = 

#circle
radius = 5
circleEQ = (sqrt(radius**2 - (x - x_circle)**2)-y_circle)

x_pixel = 0

for y_pixel  in range(-50,50){

  #line 
  m = (y_pixel - y_camera) / (x_pixel - x_camera)
  lineEQ = m * x + y1

  if (lineEQ == circleEQ){
    #color of  (x_pixel, y_pixel) = color at intersection point
  }
  ​
  #print color of pixel
}