Skip to content

Instantly share code, notes, and snippets.

@LastZactionHero
Created June 18, 2018 01:44
Show Gist options
  • Save LastZactionHero/85d95a358f6f8fcf297d32ec516b31d3 to your computer and use it in GitHub Desktop.
Save LastZactionHero/85d95a358f6f8fcf297d32ec516b31d3 to your computer and use it in GitHub Desktop.
function crossed_boundary(current_posn, next_position, direction, segments)
function find_boundaries_crossed(z, segments, min, direction)
boundaries_crossed = 0
current_posn = min - 1.5 * DELTA
bool checking = true
while(checking)
next_posn = current_posn + 1
if(crossed_boundary(current_posn, next_posn, direction, segments)
boundaries_crossed++
if(next_posn > z[direction])
done = true
current_posn = next_posn
z = [xz, yz]
segments = [
[x1, y1],
[x2, y2]...
]
min_vertical = find_max(segments, 'vertical')
min_horizontal = find_max(segments, 'horizontal')
boundaries_crossed = 0
in_bounds = true
# Check horizontal
boundaries_crossed = find_boundaries_crossed(z, segments, min_horizontal, 'horizontal')
if(boundaries_crossed % 2 == 0)
in_bounds = false
# Check horizontal
boundaries_crossed = find_boundaries_crossed(z, segments, min, vertical, 'vertical')
if(boundaries_crossed % 2 == 0)
in_bounds = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment