# 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:

1. 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.
2. Automatically point the camera at the object after translation
• What is an octant? Aug 31 '18 at 15:13
• @WhatAMesh for example one of the octants is the space in which all points have positive x, positive y, and positive z values Aug 31 '18 at 15:29
• @WhatAMesh, with a cube centered at 0,0,0, cut through it along each axis and you get eight cubes, each of these is an octant. Sep 1 '18 at 5:13

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)