New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero size areas/volumes do not overlap and are not contained #14

Closed
io7m opened this Issue May 8, 2017 · 3 comments

Comments

Projects
None yet
1 participant
@io7m
Owner

io7m commented May 8, 2017

This is a serious issue:

  @Test
  public void testBugOverlapsL()
  {
    final AreaL area0 =
      AreaL.of(0L, 10L, 0L, 10L);
    final AreaL area1 =
      AreasL.create(0L, 0L, 0L, 0L);
    Assert.assertTrue(AreasL.overlaps(area1, area0));
  }

... fails!

@io7m io7m added the bug label May 8, 2017

@io7m io7m added this to the 1.1.0 milestone May 8, 2017

@io7m io7m self-assigned this May 8, 2017

@io7m

This comment has been minimized.

Show comment
Hide comment
@io7m

io7m May 8, 2017

Owner

Actually containment seems to work correctly:

  @Test
  public void testBugContainsL()
  {
    final AreaL area0 =
      AreaL.of(0L, 10L, 0L, 10L);
    final AreaL area1 =
      AreasL.create(0L, 0L, 0L, 0L);
    Assert.assertTrue(AreasL.contains(area0, area1));
  }
Owner

io7m commented May 8, 2017

Actually containment seems to work correctly:

  @Test
  public void testBugContainsL()
  {
    final AreaL area0 =
      AreaL.of(0L, 10L, 0L, 10L);
    final AreaL area1 =
      AreasL.create(0L, 0L, 0L, 0L);
    Assert.assertTrue(AreasL.contains(area0, area1));
  }
@io7m

This comment has been minimized.

Show comment
Hide comment
@io7m

io7m May 8, 2017

Owner

This is a little philosophical. Can an area of zero height and/or width be said to overlap anything? By definition, it has zero size...

If the assumption is that an area of zero size cannot overlap, however, then ∀a. overlaps(a, a) doesn't necessarily hold. Might it make sense to treat an area of zero size as a point?

Owner

io7m commented May 8, 2017

This is a little philosophical. Can an area of zero height and/or width be said to overlap anything? By definition, it has zero size...

If the assumption is that an area of zero size cannot overlap, however, then ∀a. overlaps(a, a) doesn't necessarily hold. Might it make sense to treat an area of zero size as a point?

@io7m

This comment has been minimized.

Show comment
Hide comment
@io7m

io7m May 9, 2017

Owner

It seems like the easiest way to handle this is to make the width and height of the boxes at least 1 when performing the overlap checks. I can't see anything obviously wrong with doing this, it makes the mathematics work, and it doesn't seem to violate any of the existing theorems.

Owner

io7m commented May 9, 2017

It seems like the easiest way to handle this is to make the width and height of the boxes at least 1 when performing the overlap checks. I can't see anything obviously wrong with doing this, it makes the mathematics work, and it doesn't seem to violate any of the existing theorems.

@io7m io7m closed this in e0d8275 May 9, 2017

io7m added a commit that referenced this issue May 9, 2017

Merge branch 'release/1.1.0'
Release: com.io7m.jregions 1.1.0
Code new: Add splitAlongXY method for dividing areas into quadrants.
Code new: Stop using terms such as "horizontally", "vertically", "width", "height", etc. Deprecate methods and add replacements. (tickets: #11)
Code new: Add volume types. (tickets: #9)
Code fix: Fix overlaps() for areas and volumes. (tickets: #12, #14)
Code fix: Fix contains() for areas and volumes. (tickets: #13)

io7m added a commit that referenced this issue May 9, 2017

Merge tag 'com.io7m.jregions-1.1.0' into develop
Release: com.io7m.jregions 1.1.0

Code new: Add splitAlongXY method for dividing areas into quadrants.
Code new: Stop using terms such as "horizontally", "vertically", "width", "height", etc. Deprecate methods and add replacements. (tickets: #11)
Code new: Add volume types. (tickets: #9)
Code fix: Fix overlaps() for areas and volumes. (tickets: #12, #14)
Code fix: Fix contains() for areas and volumes. (tickets: #13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment