50 getRotation(
block_t * sn,
Agraph_t * g,
double x,
double y,
double theta)
55 Agnode_t *n, *closest_node, *neighbor;
57 double len2, newX, newY;
77 return (theta -
M_PI / 2.0);
94 newX =
ND_pos(neighbor)[0] + x;
95 newY =
ND_pos(neighbor)[1] + y;
96 mindist2 =
LEN2(newX, newY);
97 closest_node = neighbor;
106 len2 =
LEN2(newX, newY);
107 if (len2 < mindist2) {
114 if (neighbor != closest_node) {
115 double rho = sn->
rad0;
116 double r = sn->
radius - rho;
117 double n_x =
ND_pos(neighbor)[0];
119 double R =
LEN(x, y);
120 double n_y =
ND_pos(neighbor)[1];
121 double phi = atan2(n_y, n_x + r);
122 double l = r - rho / (cos(phi));
124 theta +=
M_PI / 2.0 - phi - asin((l / R) * (cos(phi)));
126 double phi = atan2(
ND_pos(neighbor)[1],
ND_pos(neighbor)[0]);
127 theta +=
M_PI - phi -
PSI(neighbor);
128 if (theta > 2 *
M_PI)
141 static void applyDelta(
block_t * sn,
double x,
double y,
double rotate)
161 X = tmpX * cosR - tmpY * sinR;
162 Y = tmpX * sinR + tmpY * cosR;
174 applyDelta(child, x, y, rotate);
216 double maxRadius = 0;
220 for (child = stp->
cp; child; child = child->
next) {
223 if (maxRadius < child->radius) {
224 maxRadius = child->
radius;
226 diameter += 2 * child->
radius + min_dist;
261 double childAngle, childRadius, incidentAngle;
262 double mindistAngle, rotateAngle, midAngle = 0.0;
263 int midChild, cnt = 0;
267 double d, deltaX, deltaY;
273 childRadius =
MAX(childRadius, d);
281 if ((childRadius + pi->
maxRadius) > snRadius)
284 mindistAngle = min_dist / childRadius;
287 for (child = stp->
cp; child; child = child->
next) {
293 incidentAngle = child->
radius / childRadius;
295 if (childAngle != 0) {
299 childAngle += incidentAngle;
303 firstAngle = childAngle;
305 lastAngle = childAngle;
308 childAngle = pi->
theta;
310 childAngle += incidentAngle + mindistAngle / 2;
314 deltaX = childRadius * cos(childAngle);
315 deltaY = childRadius * sin(childAngle);
322 rotateAngle = getRotation(child, g, deltaX, deltaY, childAngle);
323 applyDelta(child, deltaX, deltaY, rotateAngle);
326 childAngle += incidentAngle + mindistAngle;
328 childAngle += incidentAngle + mindistAngle / 2;
332 midAngle = childAngle;
335 if ((length > 1) && (pi->
n == stp->
neighbor)) {
336 PSI(pi->
n) = midAngle;
361 double maxRadius = 0.0;
378 for (item = path->
first; item; item = item->
next) {
385 parents[num_parents].
n = n;
386 parents[num_parents].
theta = theta;
387 maxRadius = getInfo (parents+num_parents, &state, min_dist);
392 if (num_parents == 1)
393 parents->
scale = 1.0;
394 else if (num_parents == 2) {
399 delta = 2*
M_PI - delta;
400 setInfo (curr, next, delta);
404 for (i = 0; i < num_parents; i++) {
405 if (i+1 == num_parents) {
413 setInfo (curr, next, delta);
418 for (i = 0; i < num_parents; i++) {
419 positionChildren (g, parents + i, &state, length, min_dist);
430 if (childCount == 1) {
431 applyDelta(sn, -(maxRadius + min_dist / 2), 0, 0);
432 sn->
radius += min_dist / 2 + maxRadius;
448 int childCount, length;
449 double centerAngle =
M_PI;
454 doBlock(g, child, min_dist);
466 position(g, childCount, length, longest_path, sn, min_dist);
void circPos(Agraph_t *g, block_t *sn, circ_state *state)
CGRAPH_API Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
int sizeNodelist(nodelist_t *list)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
nodelist_t * layout_block(Agraph_t *g, block_t *sn, double min_dist)
CGRAPH_API Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)