Rotate Object in world space – Raytracing

I’m programming a C raytracing project.

I’ve been wanting to implement object rotations (square, cylinder) for several days but I can’t do it.

For each object, I have its position (x, y, z) in the world space and its 3d normalized orientation vector.

For the moment, I do nothing more than applying once of the three following functions on the 3d normalized orientation vector. I don’t know if I’m doing it right. Rotation doesn’t work well.

For example, I want to rotate my object left with the j key and right with the l key (x_rotation), up with the i key and down with the k key (y_rotation). I’m not sure how to use the z axis.

I’m starting to despair, can you please help me?

I will be very grateful for your help 🙂

t_vec       x_rotation(t_vec vec, float alpha) {     t_vec   res;      res.x = vec.x;     res.y = vec.y * cos(alpha) - vec.z * sin(alpha);     res.z = vec.y * sin(alpha) + vec.z * cos(alpha);     return (res); }  t_vec       y_rotation(t_vec vec, float alpha) {     t_vec   res;      res.x = vec.z * sin(alpha) + vec.x * cos(alpha);     res.y = vec.y;     res.z = vec.z * cos(alpha) - vec.x * sin(alpha);     return (res); }  t_vec       z_rotation(t_vec vec, float alpha) {     t_vec   res;      res.x = vec.x * cos(alpha) - vec.y * sin(alpha);     res.y = vec.x * sin(alpha) + vec.y + cos(alpha);     res.z = vec.z;     return (res); }