Skip to content

Instantly share code, notes, and snippets.

@waseem
Created October 25, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waseem/5070f7cd5b1823dd957f36d8b205faa4 to your computer and use it in GitHub Desktop.
Save waseem/5070f7cd5b1823dd957f36d8b205faa4 to your computer and use it in GitHub Desktop.
for v in range(height):
for u in range(width):
# Get end of ray and round to sdf array coordinate...
pos = start[v,u,:] + travel[v,u] * norm[v,u,:]
pos += 0.5 * numpy.array(sdf.shape) # Center of sdf to 3D origin
sdf_coordinate = (pos+0.5).astype(int)
# Loop the 3 dimensions and check each is not out of bounds...
for d in range(3):
if sdf_coordinate[d]<0:
sdf_coordinate[d] = 0
if sdf_coordinate[d]>=sdf.shape[d]:
sdf_coordinate[d] = sdf.shape[d] - 1
# Evaluate function...
ret[v,u] = sdf[sdf_coordinate]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment