The reflection of mirrored surfaces aka specular reflection (See: https://en.wikipedia.org/wiki/Specular_reflection) is one of the simpler aspects of raytracing. Calculating a corresponding ray for a given incoming ray boils down to mirroring the directional vector of the incoming ray on the surface normal.
Given an incoming ray R_0 with an angle theta_i to the surface normal N, the new ray will have a corresponding angle theta_o with theta_i = theta_o. To find such a ray, we can use the Householder matrix like this:
(Image taken directly from https://en.wikipedia.org/wiki/Specular_reflection)
Where d_s is our outgoing vector S, d_i is our incoming vector R_0 and R is the mentioned Householder matrix. However, as we do not have a matrix implementation in this project, we need to find an equivalent. Luckily the equation above is mathematically equivalent to the expression: