Monday, 20 June 2011

Just keep on driving...

Regular readers can probably guess my next few words - "I'm continuing with the Barnes Hut work this week".

The work is going slow and much of the time is trying to understand some of the behaviour exhibited by my code. For a brief explanation of what I am attempting to do, see below, but the issue remains the forces are not being applied (or in some cases, calculated) correctly. As far as can be seen, the tree structure itself is correct (printing out the tree shows that each vertex has a region of its own as opposed to two vertices per region), and the problem remains in calculating the forces whilst climbing the tree.

Barnes Hut quad tree idea (simple version) (octree for 3D)

Set up structure
  • split the plane into 4quadrants
  • determine which vertices belong in which quadrant
  • if a quadrant has more than 1 vertex, split into 4 and continue until each vertex occupies one quadrant
  • ensure to calculate the weights and coordinates of each quadrant after
Use in force directed placement
  • Get the parent quadrant of the current vertex
  • check if any siblings in parent (in the other 3 quadrants)
  • if any, calculate forces between vertex and that quadrant
  • move to the parents' parent
  • check if any siblings and calculate forces as before, repeat until the root is reached
The rest
  • calculate the spring (edge) forces
  • calculate and apply displacement
The theory is pretty air tight from my perspective, apparently I am limited by my coding abilities. If a reader can see anything wrong with this, please let me know, thanks.

Errors

As I mentioned before I have been having some issues with this technique, the biggest being StackOverflow exceptions caused by the recursion when making the tree; in some cases the tree is too deep and causes this exception, the cause being two vertices are initially extremely close together.

Currently I am attempting to get output at all, it appears that some forces are being calculated incorrectly which cripples the rest of the graph. Ambiguous I know but when I know more I will update (just writing about it helps me think about the problem and what the causes could be).

I will update when i gather some more useful information, until then, have a nice day.

No comments:

Post a Comment