-static void
-tube (GLfloat x1, GLfloat y1, GLfloat z1,
- GLfloat x2, GLfloat y2, GLfloat z2,
- GLfloat diameter, GLfloat cap_size,
- Bool wire)
-{
- GLfloat length, angle, a, b, c;
-
- if (diameter <= 0) abort();
-
- a = (x2 - x1);
- b = (y2 - y1);
- c = (z2 - z1);
-
- length = sqrt (a*a + b*b + c*c);
- angle = acos (a / length);
-
- glPushMatrix();
- glTranslatef(x1, y1, z1);
- glScalef (length, length, length);
-
- if (c == 0 && b == 0)
- glRotatef (angle / (M_PI / 180), 0, 1, 0);
- else
- glRotatef (angle / (M_PI / 180), 0, -c, b);
-
- glRotatef (-90, 0, 0, 1);
- glScalef (diameter/length, 1, diameter/length);
-
- /* extend the endpoints of the tube by the cap size in both directions */
- if (cap_size != 0)
- {
- GLfloat c = cap_size/length;
- glTranslatef (0, -c, 0);
- glScalef (1, 1+c+c, 1);
- }