Ray casting implementation using p5js
Ray casting with reflections implementation using p5js inspired by Daniel Shiffman
Just open index.html file in browser.
Ray casting is a famous approach that aims to detect intersections between casted rays and surfaces. It is used to solve problems in Computer Graphics and Computational Geometry. An well known problem, named Ray Tracing), employs ray casting to generate images by tracing the light path in a scene. Also it is possible to provide more sophisticated images using physical phenomena such as reflection and refraction.
In this code, ray casting was implemented and extendend using simple reflection. As it is possible to see in the equation and image below, it aims to define the reflected ray (R) from the incident ray (I) through the normal of the surface (N).