54 double len2, newX, newY;
70 return theta -
M_PI / 2.0;
77 mindist2 =
LEN2(newX, newY);
87 len2 =
LEN2(newX, newY);
88 if (len2 < mindist2) {
95 double rho = sn->
rad0;
96 double r = sn->
radius - rho;
99 const double R = hypot(x, y);
101 double phi = atan2(n_y, n_x + r);
102 double l = r - rho / cos(phi);
104 theta +=
M_PI / 2.0 - phi - asin(l / R * cos(phi));
108 if (theta > 2 *
M_PI)
129 const double tmpX =
ND_pos(n)[0];
130 const double tmpY =
ND_pos(n)[1];
131 const double cosR = cos(
rotate);
132 const double sinR = sin(
rotate);
134 const double X = tmpX * cosR - tmpY * sinR;
135 const double Y = tmpX * sinR + tmpY * cosR;
183 double maxRadius = 0;
187 for (child = stp->
cp; child; child = child->
next) {
190 maxRadius = fmax(maxRadius, child->
radius);
191 diameter += 2 * child->
radius + min_dist;
218 double childAngle, childRadius, incidentAngle;
219 double mindistAngle, rotateAngle, midAngle = 0.0;
220 int midChild,
cnt = 0;
224 double d, deltaX, deltaY;
226 childRadius =
info->scale *
info->minRadius;
230 childRadius = fmax(childRadius, d);
231 d = 2 *
M_PI * childRadius -
info->diameter;
233 min_dist += d /
info->childCount;
236 childAngle =
info->theta -
info->diameter / (2 * childRadius);
238 snRadius = fmax(snRadius, childRadius +
info->maxRadius);
240 mindistAngle = min_dist / childRadius;
242 midChild = (
info->childCount + 1) / 2;
243 for (child = stp->
cp; child; child = child->
next) {
249 incidentAngle = child->
radius / childRadius;
251 if (childAngle != 0) {
252 if (
info->childCount == 2)
255 childAngle += incidentAngle;
259 firstAngle = childAngle;
261 lastAngle = childAngle;
263 if (
info->childCount == 1) {
264 childAngle =
info->theta;
266 childAngle += incidentAngle + mindistAngle / 2;
270 deltaX = childRadius * cos(childAngle);
271 deltaY = childRadius * sin(childAngle);
278 rotateAngle =
getRotation(child, deltaX, deltaY, childAngle);
279 applyDelta(child, deltaX, deltaY, rotateAngle);
282 childAngle += incidentAngle + mindistAngle;
284 childAngle += incidentAngle + mindistAngle / 2;
288 midAngle = childAngle;
313 double maxRadius = 0.0;
337 parents[num_parents].
n = n;
338 parents[num_parents].
theta = theta;
339 maxRadius =
getInfo (parents+num_parents, &state, min_dist);
344 if (num_parents == 1)
345 parents->
scale = 1.0;
346 else if (num_parents == 2) {
356 for (i = 0; i < num_parents; i++) {
357 if (i+1 == num_parents) {
370 for (i = 0; i < num_parents; i++) {
382 if (childCount == 1) {
383 applyDelta(sn, -(maxRadius + min_dist / 2), 0, 0);
384 sn->
radius += min_dist / 2 + maxRadius;
399 double centerAngle =
M_PI;
402 size_t childCount = 0;
404 doBlock(g, child, min_dist, state);
409 nodelist_t longest_path =
layout_block(g, sn, min_dist, state);
415 centerAngle =
position(childCount,
length, &longest_path, sn, min_dist);
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
nodelist_t layout_block(Agraph_t *g, block_t *sn, double min_dist, circ_state *state)
static void applyDelta(block_t *sn, double x, double y, double rotate)
static void doBlock(Agraph_t *g, block_t *sn, double min_dist, circ_state *state)
static void setInfo(posinfo_t *p0, posinfo_t *p1, double delta)
static void positionChildren(posinfo_t *info, posstate *stp, size_t length, double min_dist)
static double getRotation(block_t *sn, double x, double y, double theta)
static double getInfo(posinfo_t *pi, posstate *stp, double min_dist)
get size info for blocks attached to the given node.
void circPos(Agraph_t *g, block_t *sn, circ_state *state)
static Extype_t length(Exid_t *rhs, Exdisc_t *disc)
#define X(prefix, name, str, type, subtype,...)
static int cnt(Dict_t *d, Dtlink_t **set)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
type-generic dynamically expanding list
#define LIST_IS_EMPTY(list)
#define LIST_GET(list, index)
#define neighbor(t, i, edim, elist)
static void rotate(int n, int dim, double *x, double angle)