Last active
July 23, 2020 14:24
-
-
Save omaraflak/40947c628bc94ce6306431ae17a71bb7 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
def nearest_intersected_object(objects, ray_origin, ray_direction): | |
distances = [sphere_intersect(obj['center'], obj['radius'], ray_origin, ray_direction) for obj in objects] | |
nearest_object = None | |
min_distance = np.inf | |
for index, distance in enumerate(distances): | |
if distance and distance < min_distance: | |
min_distance = distance | |
nearest_object = objects[index] | |
return nearest_object, min_distance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment