Question: My camera towards the target object located at (0,0,0). I know the current camera location (camx, camy, camz), camera rotation eulers. How can I calculate the new camera rotation eulers so that my camera can rotate any angles a long the camera z axis.
Following is the detailed description: My camera is located at [camx,camy,camz] and the target object is located at [0,0,0]. In order to ensure the camera can correctly facing the object center, the following code is used to calculate the camera rotation eulers:
Vector = (0-camx,0-camy,0-camz) direction = mathutils.Vector(Vector) rot_quat = direction.to_track_quat('-Z', 'Y') myeulers = rot_quat.to_euler() cam.rotation_euler = myeulers
Everything works fine and the object is located in the center of the rendered image.
Now, I would like to rotate the camera like e.g. 45,90,180,360 degrees along the camera z axis so that the object in the rendered images is also rotated. Thus, I directly change the camera Z euler angle. However, after rendering, the object is not located in the rendered image center. In some images the object is missing. I guess the main reason is that the camera is rotated according to the world coordinate, the the local camera coordinate.
Do some of you know how to calculate the camera euler angles so that it can rotate only around the camera z axis? I need to use Python since those euler angles and the rendered images will be used for CNN training. Thank you very much!