flare help

5 views
Skip to first unread message

barnaby

unread,
Mar 7, 2012, 11:18:30 AM3/7/12
to Bristol Flash User Group
Hi

Can anyone want to help with a project based on prefuse flare
visualisation library?

Any thought or tips welcome. Tough to find good examples.

I'm using the radial layout (RadialTreeLayout) layout operator

http://flare.prefuse.org/api/flare/vis/operator/layout/RadialTreeLayout.html

I have the following problem.

Maths problem
===========

position nodes in a circle around a center point so that you
can't draw a line through the center point of the circle to another
node.

I've got the solution to the Maths bit (or a solution)

Solution
======

I got this from a friend with a strong maths background (see below).

Short version:
"if you have an even number of nodes, add a dummy node with no
connections to make the number of nodes odd and the problem should
sort itself out."

Long version:
"The basic problem, as you know, is that when there are an even number
of nodes and they're all evenly spaced, then there are at least two
nodes that are 180 degrees or pi radians apart, i.e. on opposite sides
of the circle. This happens because the even spacing requirement means
that the sum of all the spacing angles adds up to 360 degrees (2pi
radians). Because there are an even number of nodes, say 2N, then the
spacing angles between N nodes add up to 180 degrees (pi radians).
This is because
spacing between adjacent nodes = S = (2pi) / (2N) = pi / N
spacing between nodes that are N apart = S * N = pi

All you need is an odd number of nodes. In this case, there will be 2N
+1 nodes, and the spacing between them in radians will be (2pi) / (2N
+1). It is then not possible to pick a whole number of nodes such that
the spacing between them adds up to pi radians, and therefore no nodes
are opposite each other.

Implementation
============

Not sure where best place is to implement this.

e.g.

I could add dummy nodes to graphml and then make them invisible

or

could try and alter or extend RadialTreeLayout.as

any pointers welcome.

Best

Barnaby
Reply all
Reply to author
Forward
0 new messages