Created
October 29, 2019 13:04
-
-
Save tansly/3eb4f97132db61bfe80bb50b662af81f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from math import pi, sin, cos | |
def generate_cameras(count=1, | |
position_start='0 5 25', | |
gaze_start='0 0 -1', | |
up_start='0 1 0', | |
near_plane='-1 1 -1 1', | |
near_distance='1', | |
near_distance_end=None, | |
image_resolution='800 800', | |
image_prefix='giraffe'): | |
cameras = [] | |
pos_start = tuple(map(float, position_start.split(' '))) | |
radius = math.sqrt(sum(map(lambda x: x**2, pos_start))) | |
gz_start = tuple(map(float, gaze_start.split(' '))) | |
U_start = tuple(map(float, up_start.split(' '))) | |
angle = 0 | |
angle_diff = 2*pi/count | |
for i in range(count): | |
id_ = i + 1 | |
angle += angle_diff | |
pos = [pos_start[0], pos_start[1]*cos(angle), pos_start[2]*sin(angle)] | |
gaze = list(map(lambda x: -x/20, pos)) | |
cameras.append({ | |
'id': str(id_), | |
'position': ' '.join((str(pos[0]), | |
str(pos[1]), | |
str(pos[2]))), | |
'gaze': ' '.join((str(gaze[0]), | |
str(gaze[1]), | |
str(gaze[1]))), | |
'up': ' '.join((str(U_start[0]), | |
str(U_start[1]), | |
str(U_start[2]))), | |
'near_plane': near_plane, | |
'near_distance': str(float(near_distance)), | |
'image_resolution': image_resolution, | |
'image_name': f'{image_prefix}_{id_:04}.ppm', | |
}) | |
return cameras |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment