This file contains hidden or 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 numpy as np | |
def perspective_fov(fov, aspect_ratio, near_plane, far_plane): | |
num = 1.0 / np.tan(fov / 2.0) | |
num9 = num / aspect_ratio | |
return np.array([ | |
[num9, 0.0, 0.0, 0.0], | |
[0.0, num, 0.0, 0.0], | |
[0.0, 0.0, far_plane / (near_plane - far_plane), -1.0], | |
[0.0, 0.0, (near_plane * far_plane) / (near_plane - far_plane), 0.0] |
This file contains hidden or 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
def surrounding(x, idx, radius=1, fill=0): | |
""" | |
Gets surrounding elements from a numpy array | |
Parameters: | |
x (ndarray of rank N): Input array | |
idx (N-Dimensional Index): The index at which to get surrounding elements. If None is specified for a particular axis, | |
the entire axis is returned. | |
radius (array-like of rank N or scalar): The radius across each axis. If None is specified for a particular axis, | |
the entire axis is returned. |