So this is a classic question, I guess, but still I couldn't find an answer to my specific variation: I have an object where I select a surface with a given normal vector. I then want to rotate the object so that this normal is parallel to some target_vector. I am basing it on this code:
rot = normal.rotation_difference(target_vector) obj.rotation_quaternion += rot # Wrong. But this line is the essense of my question
I can to it when converting to Euler angles and then simply adding the rotation vectors, but I get into troubles with gimbal lock. So how do I rotate with a given quaternion? Also Will this method be robust for future target vectors and normals? I'm thinking of if any coordinates being local or global and taking the current rotation into account etc.