proj home

Files   Classes   Functions   Hierarchy  

arcsconnected Class Reference

A container of arcs that can have vector of arcs saved and restored. More...

#include <arcsconnected.h>

Collaboration diagram for arcsconnected:

List of all members.

Public Member Functions

 arcsconnected (uintc nstates, uintc N_)
 Hold n states, each of which have N arcs.
void sumdisttoarc (double &sum, vector< pt2 > const &qi) const
 A sum of the distance squared from a control point to the nearest arc.
void constructR0 (doublec r0, vector< pt2 > const &pts)
 From a starting radius construct arcs through consecutive points.
void constructR0 (doublec r0, doublec *pts)
 Assumes pts is a (N+1)*2 array of doubles.
void constructPhi0 (doublec phi0, vector< pt2 > const &pts)
 From a starting angle(radians) construct arcs through consecutive points.
void arcwriter (stringc filename) const
 Write vi out to a file.

Public Attributes

uintc N
 The number of arcs.
cirbuffarr< arccb
 Circular buffer used to store previous states.
vector< arcvi
 The current state.


Detailed Description

A container of arcs that can have vector of arcs saved and restored.

Support for constructing connected arcs from initial points is provided. The arcs are connected with C1 continuity if both sides of the point are arcs.

Definition at line 20 of file arcsconnected.h.


Constructor & Destructor Documentation

arcsconnected::arcsconnected ( uintc  nstates,
uintc  N_ 
)

Hold n states, each of which have N arcs.

Definition at line 89 of file arcsconnected.cpp.

References N, and vi.

00090   : N(_N), cb(nstates,_N)
00091 {
00092   vi.resize(N);
00093   constructR0Vec.resize(N+1);
00094 }


Member Function Documentation

void arcsconnected::arcwriter ( stringc  filename  )  const

Write vi out to a file.

Definition at line 97 of file arcsconnected.cpp.

References N, and vi.

Referenced by test07().

00098 {
00099   ofstream targ(filename.c_str(),ios::trunc);
00100 
00101   assert(targ.good()==true);
00102   if (targ.good()==false)
00103     return;
00104 
00105   targ << N+1 << endl;
00106   for (uint i=0; i<N; ++i)
00107     targ << vi[i].p0 << endl;
00108   targ << vi[N-1].p1 << endl;
00109 
00110   targ << N << endl;
00111   for (uint i=0; i<N ; ++i)
00112     targ << i << " " << i+1 << " " << vi[i].radius << endl;
00113 
00114 }

void arcsconnected::constructPhi0 ( doublec  phi0,
vector< pt2 > const &  pts 
)

From a starting angle(radians) construct arcs through consecutive points.

Definition at line 9 of file arcsconnected.cpp.

References arc::constructPhi0TwoPoints(), and arc::radius.

Referenced by arcprob::solveInitialCondition().

00013 {
00014   assert(pts.size()==N+1);
00015   assert(pts.size()>=2);
00016   if (pts.size()<2)
00017     return;
00018 
00019   arc a;
00020   a.constructPhi0TwoPoints(phi0,pts[0],pts[1]);
00021   double r0 = a.radius;
00022 
00023   constructR0(r0,pts);
00024 }

void arcsconnected::constructR0 ( doublec  r0,
doublec pts 
)

Assumes pts is a (N+1)*2 array of doubles.

Definition at line 27 of file arcsconnected.cpp.

References point2< T >::x.

00031 {
00032   pt2 * v = & constructR0Vec[0];
00033   pt2 * const vend = v + N + 1;
00034   doublec *p = pts;
00035   for ( ; v!=vend; )
00036   {
00037     (*v).x = *p;
00038     ++p;
00039     (*v).y = *p;
00040     ++p;
00041     ++v;
00042   }
00043 
00044   constructR0(r0,constructR0Vec);
00045 
00046   //assert(false) // UNTESTED ROUTINE<TODO>
00047 }

void arcsconnected::constructR0 ( doublec  r0,
vector< pt2 > const &  pts 
)

From a starting radius construct arcs through consecutive points.

Definition at line 50 of file arcsconnected.cpp.

00054 {
00055   assert(pts.size()==N+1);
00056   assert(pts.size()>=2);
00057   if (pts.size()<2)
00058     return;
00059 
00060   vi[0].constructRadiusTwoPoints(r0,pts[0],pts[1]);
00061 
00062   double theta;
00063   for (uint i=1; i<N; ++i)
00064   {
00065     pt2c & p0(pts[i]);
00066     pt2c & p1(pts[i+1]);
00067     pt2c & c0(vi[i-1].center);
00068 
00069     theta = vi[i-1].phi1;
00070 
00071 //cout << SHOW(theta*radtodeg) << endl;
00072 
00073     // Is the new point above the tangent?
00074     // This is a halfspace test.
00075     if ( (p0-c0).dot(p1-p0) > 0.0 )
00076     {
00077       theta += PI;
00078       if (theta >= PI*2.0)
00079         theta -= PI*2.0;
00080     }
00081 
00082 //cout << SHOW(theta*radtodeg) << endl;
00083       
00084     vi[i].constructPhi0TwoPoints(theta,pts[i],pts[i+1]);
00085   }
00086 }

void arcsconnected::sumdisttoarc ( double &  sum,
vector< pt2 > const &  qi 
) const

A sum of the distance squared from a control point to the nearest arc.

Definition at line 117 of file arcsconnected.cpp.

References arc::distanceSquared().

00121 {
00122   uintc W = qi.size();
00123 
00124   sum=0.0;
00125   double val;
00126   double val2;
00127   for (uint i=0; i<N; ++i)
00128   {
00129     arc const & a(vi[i]);
00130     a.distanceSquared(val,qi[0]);
00131 
00132     for (uint k=0; k<W; ++k)
00133     {
00134       a.distanceSquared(val2,qi[k]);
00135       if (val2<val)
00136         val=val2;
00137     }
00138 
00139     sum += val;
00140   }
00141 }


Member Data Documentation

Circular buffer used to store previous states.

Definition at line 30 of file arcsconnected.h.

The number of arcs.

Definition at line 27 of file arcsconnected.h.

Referenced by arcsconnected(), arcwriter(), and arcprob::solveInitialCondition().

The current state.

Definition at line 36 of file arcsconnected.h.

Referenced by arcsconnected(), arcwriter(), and test07().


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

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