org.proteinshader.graphics
Class Tube

java.lang.Object
  extended by org.proteinshader.graphics.Shape
      extended by org.proteinshader.graphics.ExtrudedShape
          extended by org.proteinshader.graphics.Tube

public class Tube
extends ExtrudedShape

Draws a segment of a three-dimensional tube by using a waist polygon that approximates a circle as the number of vertices in the waist polygon becomes large.

In the GLU library, spheres and cylinders are described as being composed of slices and stacks. A sphere could be thought of as being subdivided around the z-axis into a number of slices (similar to longitude lines) and subdivided along the z-axis into stacks (similer to latitude lines). If a cylinder was drawn with its length along the z-axis, the cylinder could be subdivided around the z-axis into slices and along the z-axis into stacks.

Tube shaped structures created by sweeping a waist polygon along a spline can also be described in terms of slices and stacks. The waist polygon is initially drawn in the xy-plane with its center at the orgin, so if the polygon was described as having n number of slices, it would have n + 1 vertices (with the first and last vertex in the same position in order to form a closed polygon). An individual slice could be thought of as a triangle composed of two adjacent vertices and a point at the center of the nearly circular polygon.

If a segment of the tube was described as having n number of stacks along its length, then it would need n + 1 number of local frames for positioning the waist polygon (so a stack can be thought of as a length of the tube inbetween two waist polygon positions).

The constructor for Tube will create a waist polygon with DEFULT_SLICES number of slices, but this value can be changed with the setSlices() method. The number of stacks a segment is composed of will be one less than the number of LocalFrames it is has (a stack must have a LocalFrame at each end).

Texture coordinates will be added to the surface of a tube segment such that the s-coordinate wraps around the circumference of the tube and the t-coordinate runs along the length of the tube. The t-coordinate will be zero at the beginning of the segment and 1 at the end of the segment. The s-coordinate will be zero where the circumference of the polygon crosses the x-axis of the local coordinate frame and it will increase to 1 as it wraps all the way around the circumference of the tube and comes back to the x-axis.


Field Summary
static double ALPHA_RADIUS
          The default radius for a Helix region waist polygon is 1.5 angstroms.
static int ALPHA_SLICES
          The default number of slices for a Helix region waist polygon is 20.
static int ALPHA_STACKS
          The default number of stacks for an alpha-helix segment is 10.
static double BETA_RADIUS
          The default radius for a BetaStrand region waist polygon is 1.5 angstroms.
static int BETA_SLICES
          The default number of slices for a BetaStrand region waist polygon is 20.
static int BETA_STACKS
          The default number of stacks for a beta-strand segment is 10.
static double LOOP_RADIUS
          The default radius for a Loop region waist polygon is 0.75 angstroms.
static int LOOP_SLICES
          The default number of slices for a Loop region waist polygon is 10.
static int LOOP_STACKS
          The default number of stacks for a loop segment is 10.
static float S_MAX
          The ending s-coordinate for texture mapping is 2.0, which will cause a texture image to wrap around the tube twice.
static float S_MIN
          The starting s-coordinate for texture mapping is 0.0.
 
Fields inherited from class org.proteinshader.graphics.ExtrudedShape
END_CAP_COLOR, START_CAP_COLOR
 
Fields inherited from class org.proteinshader.graphics.Shape
HALF_PI, PI, SPECULAR_COLOR, TWO_PI
 
Constructor Summary
Tube()
          Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.
Tube(double radius, int slices, float sCoordStart, float sCoordEnd, boolean counterclockwise)
          Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.
Tube(RegionEnum regionType)
          Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.
 
Method Summary
 void draw(GL gl, LocalFrame[] frames)
          Uses an array of LocalFrame objects to draw a segment of a tube.
 void drawEndCap(GL gl, LocalFrame frame)
          Creates a cap for the end of a segment by drawing the waist polygon.
 void drawStartCap(GL gl, LocalFrame frame)
          Creates a cap for the beginning of a segment by drawing the waist polygon.
 void setRadius(double radius)
          Sets the radius used for drawing the waist polygon, which approximates a circle as the number of vertices becomes large.
 void setSlicesAndSCoordParameters(int slices, float sCoordStart, float sCoordEnd, boolean counterclockwise)
          Sets the direction in which the s-texture coordinate increases from sCoordStart to sCoordEnd and then calls on setSlicesAndSCoordRange().
 void setSlicesAndSCoordRange(int slices, float sCoordStart, float sCoordEnd)
          Sets the number of slices that the nearly circular waist polygon would be divided into if a line was drawn from the center of the polygon to each vertex.
 
Methods inherited from class org.proteinshader.graphics.ExtrudedShape
applyEndCapColor, applyStartCapColor, createDisplayList, createDisplayLists, createEndCapDisplayList, createStartCapDisplayList
 
Methods inherited from class org.proteinshader.graphics.Shape
deleteDisplayList, executeDisplayList, executeDisplayList, setMaterial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOOP_RADIUS

public static final double LOOP_RADIUS
The default radius for a Loop region waist polygon is 0.75 angstroms.

See Also:
Constant Field Values

LOOP_SLICES

public static final int LOOP_SLICES
The default number of slices for a Loop region waist polygon is 10.

See Also:
Constant Field Values

LOOP_STACKS

public static final int LOOP_STACKS
The default number of stacks for a loop segment is 10.

See Also:
Constant Field Values

ALPHA_RADIUS

public static final double ALPHA_RADIUS
The default radius for a Helix region waist polygon is 1.5 angstroms.

See Also:
Constant Field Values

ALPHA_SLICES

public static final int ALPHA_SLICES
The default number of slices for a Helix region waist polygon is 20.

See Also:
Constant Field Values

ALPHA_STACKS

public static final int ALPHA_STACKS
The default number of stacks for an alpha-helix segment is 10.

See Also:
Constant Field Values

BETA_RADIUS

public static final double BETA_RADIUS
The default radius for a BetaStrand region waist polygon is 1.5 angstroms.

See Also:
Constant Field Values

BETA_SLICES

public static final int BETA_SLICES
The default number of slices for a BetaStrand region waist polygon is 20.

See Also:
Constant Field Values

BETA_STACKS

public static final int BETA_STACKS
The default number of stacks for a beta-strand segment is 10.

See Also:
Constant Field Values

S_MIN

public static final float S_MIN
The starting s-coordinate for texture mapping is 0.0.

See Also:
Constant Field Values

S_MAX

public static final float S_MAX
The ending s-coordinate for texture mapping is 2.0, which will cause a texture image to wrap around the tube twice.

See Also:
Constant Field Values
Constructor Detail

Tube

public Tube()
Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.

The default Region type is RegionEnum.LOOP.


Tube

public Tube(RegionEnum regionType)
Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.

The values for the radius and number of slices will be based on the Region type given as an argument.

Parameters:
regionType - the type can be HELIX, BETA_STRAND, or LOOP.

Tube

public Tube(double radius,
            int slices,
            float sCoordStart,
            float sCoordEnd,
            boolean counterclockwise)
Constructs a Tube object that can be used for rendering tubes with a circular-shaped waist polygon.

The waist polygon will have the requested radius and the number of vertices will be slices + 1 (the first and last vertex are at the same postion). If true is given as the counterclockwise argument, then the s-texture coordinate will increase from 0 to 1 in the counterclockwise direction. If false is given as an arugment, then the texture coordinates will increase in the clockwise direction (see comments for the setDirectionForTextCoordS() method.

Parameters:
radius - the radius of the circular waist polygon.
slices - determines the number of vertices in the circle.
sCoordStart - lowest s-coordinate for texture mapping.
sCoordEnd - highest s-coordinate for texture mapping.
counterclockwise - determines the direction in which the s-texture coordinate increases.
Method Detail

draw

public void draw(GL gl,
                 LocalFrame[] frames)
Uses an array of LocalFrame objects to draw a segment of a tube.

Texture coordinates are associated with each vertex.

Specified by:
draw in class ExtrudedShape
Parameters:
gl - the current GL object.
frames - array of LocalFrames for positioning a waist polygon.

drawStartCap

public void drawStartCap(GL gl,
                         LocalFrame frame)
Creates a cap for the beginning of a segment by drawing the waist polygon. The surface normal will be the negative z-axis (the tangent) of the local coordinate frame.

Specified by:
drawStartCap in class ExtrudedShape
Parameters:
gl - the current GL object.
frame - the frame for positioning the waist polygon.

drawEndCap

public void drawEndCap(GL gl,
                       LocalFrame frame)
Creates a cap for the end of a segment by drawing the waist polygon. The surface normal will be the negative z-axis (the tangent) of the local coordinate frame.

Specified by:
drawEndCap in class ExtrudedShape
Parameters:
gl - the current GL object.
frame - the frame for positioning the waist polygon.

setRadius

public void setRadius(double radius)
Sets the radius used for drawing the waist polygon, which approximates a circle as the number of vertices becomes large.

Parameters:
radius - the radius of the circular waist polygon.

setSlicesAndSCoordParameters

public void setSlicesAndSCoordParameters(int slices,
                                         float sCoordStart,
                                         float sCoordEnd,
                                         boolean counterclockwise)
Sets the direction in which the s-texture coordinate increases from sCoordStart to sCoordEnd and then calls on setSlicesAndSCoordRange().

The waist polygon (which approximates a circle) will be drawn in the xy-plane of a local coordinate frame. The vertices are drawn in a counterclockwise direction, starting at (1, 0, 0). By default, the s-texture coordinate increases in the same direction, so the first vertex of the waist polygon has an s-texture coordinate of sCoordStart and the last vertex has an s-texture coordinate of sCoordEnd. If the boolean argument given this method is false, then the order will be switched so that the s-texture coordinate increases from sCoordStart to sCoordEnd in the clockwise direction. If the arugment is true, then the direction will be set back to the default of counterclockwise.

Parameters:
slices - determines the number of vertices in the circle.
sCoordStart - lowest s-coordinate for texture mapping.
sCoordEnd - highest s-coordinate for texture mapping.
counterclockwise - determines the direction in which the s-texture coordinate increases.

setSlicesAndSCoordRange

public void setSlicesAndSCoordRange(int slices,
                                    float sCoordStart,
                                    float sCoordEnd)
Sets the number of slices that the nearly circular waist polygon would be divided into if a line was drawn from the center of the polygon to each vertex.

The number of vertices in the waist polygon is (slices + 1). If the number of slices is n, then the first vertex would have index 0 and the last vertex would have index n. The first and last vertex are in the same postion so that a closed polygon is formed.

The waist polygon is drawn in the xy-plane using the equation

point(i) = (x, y, z) = ( cosTheta, sinTheta, 0 )

where theta = i * (2*PI / slices), 0 <= i <= slices

The waist polygon is initially drawn using a unit circle (radius = 1) so that the xyz-coordinates could be used to define a surface normal of length 1. The xyz-position will later be scaled by the radius to give a polygon of a desired size.

Parameters:
slices - the number of slices the circle is divided into.
sCoordStart - lowest s-coordinate for texture mapping.
sCoordEnd - highest s-coordinate for texture mapping.


Copyright © 2007-2008