## Archive for the ‘**Ray Tracer**’ Category

## Math routines

The above is an early screenshot when I had buffer overflow bug in my code.

In my last post I mentioned my top priority was to finish a 4×4 Matrix class to use for my ray tracer. Unfortunately, I have not finished it. However, I did start writing many other classes, such as Point and Transform. I also wrote transform functions for translations, Object-To-World and Camera-To-World. Of course I can’t show these things with a screenshot, so instead I included below the source code interface for my matrix class.

struct Matrix { public: double d[4][4]; Matrix(); Matrix(double initd[4][4]); Matrix(double d11, double d12, double d13, double d14, double d21, double d22, double d23, double d24, double d31, double d32, double d33, double d34, double d41, double d42, double d43, double d44); Matrix inverse() const; Matrix operator+(const Matrix& m1) const; Matrix& operator+=(const Matrix& m1); Matrix operator-(const Matrix& m1) const; Matrix& operator-=(const Matrix& m1); Matrix operator*(const Matrix& m1) const; Matrix& operator*=(const Matrix& m1); bool operator==(const Matrix& m1) const; bool operator!=(const Matrix& m1) const; };

I’m using doubles because there is some numerical instability in my ray tracer that I don’t feel like fixing just right now.

## My Ray Tracer

The above screenshot is that of my ray tracer. Currently it has only barebone features but I hope to get more stuff in as soon as possible. I’ll use this blog mostly to record my ray tracer development, but If I have time I’ll try and post about other things I find interesting.

**Features:**

Sphere and Infinite Plane Primitives

Point Light

Perspective projection

Orthographic projection

Reflections

Shadows

Supersampling (grid algorithm)

**To Do List (in descending priority):**

Complete 4x4Matrix class

Add more transformation – rotation, lookAt, scaling, etc.

Add object space, camera space, world space, screen space