Skip to content

Abs weighted average in manyBody barnes-hut coords#98

Merged
mbostock merged 1 commit intod3:masterfrom
vasturiano:barnes-hut-coords
Sep 23, 2017
Merged

Abs weighted average in manyBody barnes-hut coords#98
mbostock merged 1 commit intod3:masterfrom
vasturiano:barnes-hut-coords

Conversation

@vasturiano
Copy link
Copy Markdown
Contributor

The quadrant coordinates for the Barnes-Hut approx in forceManyBody are calculated using a weighted average according to the child strengths. However, the current calc is not accounting for negative strengths which may throw off the quad.x/quad.y coords. Furthermore the issue is aggravated when combining positive and negative strengths, which will result in a reduced aggregated strength (due to cancellation), leading to very high values of x and y.

I came across the issue when noticing combined nodes with positive and negative strengths having a much lower force intensity, due to the quadrant centers being much more distant.

This patch abs the weights in the average to fix the issue.

@mbostock mbostock merged commit 258b35d into d3:master Sep 23, 2017
@mbostock
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants