proj home

Files   Classes   Functions   Hierarchy  

helix Class Reference

Helix made of lines. More...

#include <helix.h>

Inheritance diagram for helix:
Collaboration diagram for helix:

List of all members.

Public Member Functions

 helix ()
 Do nothing constructor.
 helix (doublec nturns, uintc Nspikes_)
 Partially create a helix, assign length and radius before drawing.
 helix (doublec nturns, uintc Nspikes_, doublec length_, doublec radius_)
 Create a helix.
void construct (doublec nturns, uintc Nspikes_)
 Partially create a helix, assign length and radius before drawing.
void draw ()
 Draw the helix without color.

Public Attributes

double length
 The spikes length.
double radius
 The number of turns the helix has.


Detailed Description

Helix made of lines.

The length and radius can be changed before each draw.

Definition at line 22 of file helix.h.


Constructor & Destructor Documentation

helix::helix (  ) 

Do nothing constructor.

Definition at line 5 of file helix.cpp.

References construct().

00006 {
00007   construct(0.0,0);
00008 }

helix::helix ( doublec  nturns,
uintc  Nspikes_ 
)

Partially create a helix, assign length and radius before drawing.

Definition at line 11 of file helix.cpp.

00015 {
00016   construct(nturns,Nspikes_);
00017 }

helix::helix ( doublec  nturns,
uintc  Nspikes_,
doublec  length_,
doublec  radius_ 
)

Create a helix.

Definition at line 20 of file helix.cpp.

00026 {
00027   construct(nturns,Nspikes_);
00028   length=length_;
00029   radius=radius_;
00030 }


Member Function Documentation

void helix::construct ( doublec  nturns,
uintc  Nspikes_ 
)

Partially create a helix, assign length and radius before drawing.

Definition at line 33 of file helix.cpp.

Referenced by helix().

00037 {
00038   Nspikes = Nspikes_;
00039 
00040   double dtheta = 2.0*3.14159265*nturns/(Nspikes-1.0);
00041 
00042   angles.resize(Nspikes);
00043   double theta;
00044   for (uint i=0; i<Nspikes; ++i)
00045   {
00046     theta = i*dtheta;
00047     angles[i].x = cos(theta);
00048     angles[i].y = sin(theta);
00049   }
00050 }

void helix::draw (  )  [virtual]

Draw the helix without color.

Implements gobj.

Definition at line 53 of file helix.cpp.

References length, and radius.

00054 {
00055   if (length==0.0)
00056     return;
00057 
00058   assert(length>0.0);
00059 
00060   double dx = length/(Nspikes-1.0);
00061   double x;
00062   glBegin(GL_LINES);
00063   for (uint i=0; i<Nspikes; ++i)
00064   {
00065     x = dx*i;
00066 
00067     glVertex3d(x,radius*angles[i].x,radius*angles[i].y);
00068     glVertex3d(x,0.0,0.0);
00069   }
00070   glEnd();
00071 }


Member Data Documentation

double helix::length

The spikes length.

Definition at line 30 of file helix.h.

Referenced by draw().

double helix::radius

The number of turns the helix has.

Definition at line 32 of file helix.h.

Referenced by draw().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:03 2011 for Chelton Evans Source by  doxygen 1.5.8