Ray Tracer in Python (Part 3) - Show Notes of "3D Balls in 2D Space"

2 min read · Posted on: Dec 4, 2019 · Print this page

Graphics is what made Mathematics enjoyable for me. I first heard of trigonometric functions like sine and cosine when I read GW-BASIC manual. Geometry was easy to visualize with the rudimentary graphics of LINE and CIRCLE statements. While I could see many struggle with Mathematics, I always found it interesting.

So my challenge was to make this math-heavy episode interesting so that you see how I see it. I needed to give personalities to Ray and Sphere before I could show their intersection formula. This needed a lot of illustration and animation work. But I believe the end result was worth it.

This time there is a lot of furious typing and less talking because of the number of lines entered in this part. I did not want to fast forward code writing segments because it doesn’t help the learners. In any case, YouTube can speed up videos if you choose to.

These are the topics we will cover in this episode:

  • Introduction
    • Why meshes in movies and spheres in raytracers
    • Simplified ray-tracing
    • Ray-sphere intersection
    • Aspect Ratio Corrections
  • First sub-problem: 3D Balls in 2D Space
  • Coding the solution
    • Hex colors
    • Classes for Engine, Ray, Sphere, etc.
    • Rendering Algorithm

Here is the video:

Code for part three is tagged on the Puray Github project

Bonus (Traffic Lights) Code is available for download.

Show Notes

Books and articles that can help understand this part:

Note: References may contain affiliate links

Arun Ravindran profile pic

Arun Ravindran

Arun is the author of "Django Design Patterns and Best Practices". Works as a Product Manager at Google. Avid open source enthusiast. Keen on Python. Loves to help people learn technology. Find out more about Arun on the about page.

Don't miss any future posts!

Comments →

Next: ▶   A Guide to ASGI in Django 3.0 and its Performance

Prev: ◀   Ray Tracer in Python (Part 2) - Show Notes of "Revealing the True Colors"

Up: ▲   Blog

Featured Posts

Frequent Tags

banner ad for Django book


powered by Disqus