~ubuntu-branches/ubuntu/lucid/graphviz/lucid-updates

« back to all changes in this revision

Viewing changes to lib/circogen/circpos.c

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2008-06-19 20:23:23 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619202323-ls23h96ntj9ny94m
Tags: 2.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build depend on liblualib50-dev instead of liblua5.1-0-dev.
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev or python2.5-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: circpos.c,v 1.2 2007/11/03 17:51:22 ellson Exp $ $Revision: 1.2 $ */
 
1
/* $Id: circpos.c,v 1.3 2008/03/03 23:01:51 ellson Exp $ $Revision: 1.3 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
48
48
 * actual block. Then, the angle to rotate the coalesced block to
49
49
 * that the edge from the parent is tangent to the neighbor on the
50
50
 * actual child block circle is
51
 
 *    alpha = theta + PI/2 - phi - arcsin((l/R)*(sin B))
52
 
 * where l = r - rho/(cos phi) and beta = PI/2 + phi.
 
51
 *    alpha = theta + M_PI/2 - phi - arcsin((l/R)*(sin B))
 
52
 * where l = r - rho/(cos phi) and beta = M_PI/2 + phi.
53
53
 * Thus, 
54
 
 *    alpha = theta + PI/2 - phi - arcsin((l/R)*(cos phi))
 
54
 *    alpha = theta + M_PI/2 - phi - arcsin((l/R)*(cos phi))
55
55
 */
56
56
static double
57
57
getRotation(block_t * sn, Agraph_t * g, double x, double y, double theta)
72
72
    list = sn->circle_list;
73
73
 
74
74
    if (sn->parent_pos >= 0) {
75
 
        theta += PI - sn->parent_pos;
 
75
        theta += M_PI - sn->parent_pos;
76
76
        if (theta < 0)
77
 
            theta += 2 * PI;
 
77
            theta += 2 * M_PI;
78
78
 
79
79
        return theta;
80
80
    }
81
81
 
82
82
    count = sizeNodelist(list);
83
83
    if (count == 2) {
84
 
        return (theta - PI / 2.0);
 
84
        return (theta - M_PI / 2.0);
85
85
    }
86
86
 
87
87
    /* Find node in block connected to block's parent */
128
128
            double phi = atan2(n_y, n_x + r);
129
129
            double l = r - rho / (cos(phi));
130
130
 
131
 
            theta += PI / 2.0 - phi - asin((l / R) * (cos(phi)));
 
131
            theta += M_PI / 2.0 - phi - asin((l / R) * (cos(phi)));
132
132
        } else {                /* Origin still at center of this block */
133
133
            double phi = atan2(ND_pos(neighbor)[1], ND_pos(neighbor)[0]);
134
 
            theta += PI - phi - PSI(neighbor);
135
 
            if (theta > 2 * PI)
136
 
                theta -= 2 * PI;
 
134
            theta += M_PI - phi - PSI(neighbor);
 
135
            if (theta > 2 * M_PI)
 
136
                theta -= 2 * M_PI;
137
137
        }
138
138
    } else
139
139
        theta = 0;
247
247
    else
248
248
        childAngle = theta - stp->nodeAngle / 2;
249
249
 
250
 
    childRadius = length * diameter / (2 * PI);
 
250
    childRadius = length * diameter / (2 * M_PI);
251
251
 
252
252
    /* FIX: If the parent block stp has only 1 child, we should probably
253
253
     * also set childRadius to mindistance. In this case, can 1 prove that
338
338
    state.subtreeR = sn->radius;
339
339
    state.radius = sn->radius;
340
340
    state.neighbor = CHILD(sn);
341
 
    state.nodeAngle = 2 * PI / length;
 
341
    state.nodeAngle = 2 * M_PI / length;
342
342
    state.firstAngle = -1;
343
343
    state.lastAngle = -1;
344
344
 
367
367
    } else
368
368
        sn->radius = state.subtreeR;
369
369
 
370
 
    angle = (state.firstAngle + state.lastAngle) / 2.0 - PI;
 
370
    angle = (state.firstAngle + state.lastAngle) / 2.0 - M_PI;
371
371
    return angle;
372
372
}
373
373
 
379
379
    block_t *child;
380
380
    nodelist_t *longest_path;
381
381
    int childCount, length;
382
 
    double centerAngle = PI;
 
382
    double centerAngle = M_PI;
383
383
 
384
384
    /* layout child subtrees */
385
385
    childCount = 0;
401
401
    if ((length == 1) && (BLK_PARENT(sn))) {
402
402
        sn->parent_pos = centerAngle;
403
403
        if (sn->parent_pos < 0)
404
 
            sn->parent_pos += 2 * PI;
 
404
            sn->parent_pos += 2 * M_PI;
405
405
    }
406
406
}
407
407