So I am making a raytracer following the very helpful online book of Gabriel GambetttaGambetta but I stumble on the rotation matrix part.
My linear algebra background is 3Blue1Brown video series "The essence of Linear Algebra".
I simulate a camera placed at the origin that's looking forward ie whose direction is the vector {0,0,1}
.
Let's say I am given another camera direction with direction {a,b,c}
.
From what I understand if I find the rotation matrix R that takes as an input {0,0,1}
and spits out a normalized {a,b,c}
as an output.
Then I can apply that rotation matrix to all my rays in order to rotate them.
I can't get my head around on how to find R. Any help/explanation/correction much welcome.
I am in a similar situation than the person aksing this questionthe person asking this question except that he seems to know already what needs be done and is just asking about if his rationale is good.
Thanks
EDIT : The answer below is valid considering how I framed my problem but note that if you were like me trying to compute a camera to world rotation matrix and expected the viewport of your camera to follow along, you need an additional step because the answer below only gives you a shear matrix. In order to get a rotation matrix you need to compute the upVector
with normalize(cross_product(rightVector, forwardVector))
(in a right hand system) and feed its coordinates into the matrix instead of {0,1,0}