I spawn a camera in a scene using random coordinates for
y and setting
z=0 and orient the camera so that it looks on the point (0, 0, 0). My goal is to move the camera forward using randomly-generated velocity vectors on the ground (so
0). I want to ensure that the new position of the camera is within a valid range after moving it forward, defined in degrees with respect to the current focus point/direction. More specifically, the way I determine "valid range" is by ensuring that the new position is within 45 degrees of the old camera's focus point (-45 degrees to the left and +45 degrees to the right). Can someone write a pseudocode on how I can achieve this?
Here's my attempt to do this but this doesn't seem to be the correct way to help me achieve what I want:
camera_dir = (0, 0, 0) - current_cam_pos while True: vel_vec=[uniform(-max_vel, max_vel), uniform(-max_vel, max_vel)] # generate a random velocity vector new_pos = camera_dir + vel_vec # compute a new position (and camera direction vector) for the camera if (compute_angle(new_pos, camera_dir) < 45 or compute_angle(new_pos, camera_dir) > 315): break