#compute field of view ratio = float (image.height)/float(image.width) #45 degree field of view fieldRad = math.pi * (float(45) / float(2) / float(180)) #get world dimensions width = (math.tan(fieldRad) * 2.0) height = ratio * math.tan(fieldRad) * 2.0 pixelWidth = width / (image.width - 1) pixelHeight = height / (image.height - 1) #begin ray tracing for y in range(image.height): for x in range(image.width): xOffset = cameraUP*(x * pixelWidth - (width/2)) yOffset = cameraDir*(y * pixelHeight - (height/2)) #if x is 1 and y is 1: # print xOffset.x, xOffset.y, xOffset.z # print yOffset.x, yOffset.y, yOffset.z ray = reverseRay(gaze.point, gaze.vector + xOffset + yOffset) color = world.rayColor(ray) image.load(x,y,*color) print 'All done, look in this directory for ' + image.name image.toFile()