Files Classes Functions Hierarchy
00001 00002 #include <helix.h> 00003 00004 00005 helix::helix() 00006 { 00007 construct(0.0,0); 00008 } 00009 00010 helix::helix 00011 ( 00012 doublec nturns, 00013 uintc Nspikes_ 00014 ) 00015 { 00016 construct(nturns,Nspikes_); 00017 } 00018 00019 helix::helix 00020 ( 00021 doublec nturns, 00022 uintc Nspikes_, 00023 doublec length_, 00024 doublec radius_ 00025 ) 00026 { 00027 construct(nturns,Nspikes_); 00028 length=length_; 00029 radius=radius_; 00030 } 00031 00032 void helix::construct 00033 ( 00034 doublec nturns, 00035 uintc Nspikes_ 00036 ) 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 } 00051 00052 00053 void helix::draw() 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 } 00072
1.5.8