Camera translation and rotation for rendering I have an object at the origin of the global coordinate system. I want to render images of the object from many different randomly chosen viewpoints. How can I randomize the camera position by following these 2 steps:


Pick an octant (e.g. one of the octants is the space in which all points have positive x, positive y, and positive z values) in the 3D coordinate system, then randomize the camera location in that octant, given that the object is at a distance from the object within a pre-defined range.
Automatically point the camera at the object after translation
I am not quite sure that I have understand what an Octant is, but you may try this:

first create a camera and an empty, then add to your camera a "TrackTo" constraint and set its Target to be the empty.



This is how it should look if you move you camera along the Y axis 



after finishing your setup this code will pick random points in positive space, you have only to set min and max values so it can avoid overlaps and define the maximum length of your octant as you wish.

import bpy
import random

#pick random point in Octant
def Octant(minX, maxX, minY, maxY, minZ, maxZ):
    rndX = random.uniform(minX, maxX)
    rndY = random.uniform(minY, maxY)
    rndZ = random.uniform(minZ, maxZ)
    return (rndX, rndY, rndZ)

#select your main camera
camera = bpy.context.scene.objects["Camera"]
#set camera random position
camera.location = Octant(1,5, 1,4, 1,8)


it can be also enriched by the same logic so you may have small differences on the focal length and the empty's position too.