proj home

Files   Classes   Functions   Hierarchy  

plotpolar.cpp

Go to the documentation of this file.
00001 #include <cmath>
00002 using namespace std;
00003 
00004 #include <plotpolar.h>
00005 
00006 #define PI 3.14159265359
00007 
00008 void plotpolar::adddatapointsinPolarRadians
00009 ( 
00010   vector< point2<double> > const & p 
00011 )
00012 {
00013   pts.clear();
00014 
00015   uintc sz = p.size();
00016   for (uint i=0; i<sz; ++i)
00017   {
00018     point2<double> const & z(p[i]);
00019     // Convert the polar coordinates to cartesian coordinates.
00020     pts.push_back( point2<double>(z.x*cos(z.y), z.x*sin(z.y)) );
00021   }
00022 }
00023 
00024 
00025 void plotpolar::adddatapointsinPolarDegrees
00026 ( 
00027   vector< point2<double> > const & p 
00028 )
00029 {
00030   pts.clear();
00031 
00032   double t;
00033   uintc sz = p.size();
00034   for (uint i=0; i<sz; ++i)
00035   {
00036     point2<double> const & z(p[i]);
00037     // Convert degrees to polar coordinates.
00038     t = z.y * PI / 180.0;
00039     // Convert polar to cartesian coordinates.
00040     pts.push_back( point2<double>(z.x*cos(t), z.x*sin(t)) );
00041   }
00042 }
00043 
00044 
00045 
00046 void plotpolar::addpoints
00047 (
00048   uintc r, 
00049   uintc g, 
00050   uintc b
00051 )
00052 {
00053   gobjContainer * c = new gobjContainer();
00054 
00055   c->push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00056   c->push( new gobjglPushAttrib(GL_LIGHTING_BIT) );
00057   c->push( new gobjglDisable(GL_LIGHTING) );
00058 
00059   c->push( new gobjglColor3ub(r,g,b) );
00060 
00061 
00062   uintc sz = pts.size();
00063  
00064   c->push( new gobjglBegin(GL_POINTS) );
00065   for (uint i=0; i<sz; ++i)
00066   {
00067     c->push( new gobjglVertex2f(pts[i]) );
00068   }
00069 
00070   c->push(new gobjglEnd());
00071 
00072   c->push( new gobjglPopAttrib() );
00073   c->push( new gobjglPopAttrib() );
00074 
00075   push(c);
00076 }
00077 
00078 void plotpolar::addcrosses
00079 (
00080   uintc r,  
00081   uintc g, 
00082   uintc b,
00083   doublec crosshairlength
00084 )
00085 {
00086   gobjContainer * c = new gobjContainer();
00087 
00088   c->push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00089   c->push( new gobjglPushAttrib(GL_LIGHTING_BIT) );
00090   c->push( new gobjglDisable(GL_LIGHTING) );
00091 
00092   c->push( new gobjglColor3ub(r,g,b) );
00093 
00094   uintc sz = pts.size();
00095 
00096   doublec h = crosshairlength / 2.0;
00097  
00098   c->push( new gobjglBegin(GL_LINES) );
00099   for (uint i=0; i<sz; ++i)
00100   {
00101     point2<double> const & x(pts[i]);
00102     c->push( new gobjglVertex2f(x.x,x.y+h) );
00103     c->push( new gobjglVertex2f(x.x,x.y-h) );
00104     c->push( new gobjglVertex2f(x.x+h,x.y) );
00105     c->push( new gobjglVertex2f(x.x-h,x.y) );
00106   }
00107 
00108   c->push(new gobjglEnd());
00109 
00110   c->push( new gobjglPopAttrib() );
00111   c->push( new gobjglPopAttrib() );
00112 
00113   push(c);
00114 }
00115 
00116 
00117 
00118 
00119 
00120 
00121     
00122 
00123 

Generated on Fri Mar 4 00:49:30 2011 for Chelton Evans Source by  doxygen 1.5.8