Skip to content
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

Error in Fork.insert #1

Open
xiongtx opened this issue Sep 12, 2016 · 0 comments
Open

Error in Fork.insert #1

xiongtx opened this issue Sep 12, 2016 · 0 comments

Comments

@xiongtx
Copy link

xiongtx commented Sep 12, 2016

I believe there is an error in the insert method of the Fork class. The insertions into quadrants appear to be wrong:

def insert(b: Body): Fork = {
  if (b.x < centerX && b.y < centerY) Fork(nw.insert(b), ne, sw, se)
  else if (b.x < centerX && b.y >= centerY) Fork(nw, ne.insert(b), sw, se)
  else if (b.x >= centerX && b.y < centerY) Fork(nw, ne, sw.insert(b), se)
  else Fork(nw, ne, sw, se.insert(b))
}

In particular, b.x < centerX && b.y >= centerY should correspond to sw, not ne. Similarly, b.x >= centerX && b.y < centerY should correspond to ne, not sw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant