XForms: hoe to display information nodes in cone shape

c5666305 (c5666305@comp.polyu.edu.hk)
Sun, 22 Feb 1998 20:30:05 +0800 (HKT)

# To subscribers of the xforms list from "c5666305" <c5666305@comp.polyu.edu.hk> :

Hello,

I have a question on how to display a structure of a information tree in
a cone shape. However, my code doesn't seem to work correctly. I have
tried to solve for a few days without success. Is there some algorithm
to calculate the position of the nodes (a,b,c,d,a1,....). If so, please
show me the direction. Thanks.

A
/|\
/ | \
/ | \
/ a1 \
a b
c d

Here is my code fragment.

Clarence

===================================================================

const double omega = 1.0;
const double initial_angle = -1.0;
const double cord_length = 0.5;

const double tic = 0.025;
static double time = 0.0;
const int N = 5;

static void draw_tree( void )
{
static double radius = 0.05;
const double delta_theta = pi2/20;
double xcenter , ycenter;
double x, y;
double theta = 0.0;

double current_angle = cos(omega * time);

int i = 0;

glColor3f(0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);

for ( i = 0; i < N; i++ ) {

/* Draw pendulum cord */
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex2f(0.0, 0.0);

xcenter = -cord_length * sin(current_angle);
ycenter = -cord_length * cos(current_angle);

glVertex2f(xcenter, ycenter);
glEnd();

/* Draw pendulum dish */
glColor3f(1.0, 0.0, 0.0);

x = xcenter + radius * sin(theta);
y = ycenter + radius * cos(theta);

glPushMatrix();
glTranslatef(x,y,0);
glutWireSphere(0.04, 20, 20);
glPopMatrix();

time = time + 1.5;
current_angle = cos(omega * time);

}
}
===================================================================
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/