Bezier_curve< K > Class Template Reference

* More...

#include <qsc_approximation_fcts.hpp>

List of all members.

Public Member Functions


Detailed Description

template<class K>
class mmx::shape::Bezier_curve< K >

*

Definition at line 68 of file qsc_approximation_fcts.hpp.


Constructor & Destructor Documentation

Bezier_curve (  )  [inline]

Definition at line 71 of file qsc_approximation_fcts.hpp.

Referenced by Bezier_curve< K >::subdiv().

00071 {};

Bezier_curve ( const point< K > &  a,
const point< K > &  b,
const point< K > &  c 
) [inline]

Definition at line 73 of file qsc_approximation_fcts.hpp.

00074     {
00075       cpoints<< a << b << c ;
00076     };

Bezier_curve ( const point< K > &  a,
const point< K > &  b,
const point< K > &  c,
const point< K > &  d 
) [inline]

Definition at line 78 of file qsc_approximation_fcts.hpp.

00079     {
00080       cpoints<< a << b << c << d;
00081     };

Bezier_curve ( int  n  )  [inline]

Definition at line 83 of file qsc_approximation_fcts.hpp.

00083 { cpoints= Seq<VECT>(n+1); };

Bezier_curve ( Seq< point< K > > &  cpts  )  [inline]

Definition at line 84 of file qsc_approximation_fcts.hpp.

00084 { cpoints=cpts; };


Member Function Documentation

bool ccw ( const int &  i = 0  )  const [inline]

Definition at line 87 of file qsc_approximation_fcts.hpp.

00087                                            {
00088 
00089     return ( cpoints[ i ].x()*cpoints[i+1].y()-cpoints[ i ].y()*cpoints[i+1].x() + 
00090              cpoints[i+1].x()*cpoints[i+2].y()-cpoints[i+1].y()*cpoints[i+2].x() + 
00091              cpoints[i+2].x()*cpoints[ i ].y()-cpoints[i+2].y()*cpoints[ i ].x() < 0 ?
00092              false : true );
00093   };

Seq< point<K> > control_points (  )  const [inline]

Definition at line 106 of file qsc_approximation_fcts.hpp.

00106 { return cpoints; };

int degree (  )  const [inline]

Definition at line 107 of file qsc_approximation_fcts.hpp.

References Seq< C, R >::size().

Referenced by Bezier_curve< K >::diff(), Bezier_curve< K >::eval(), and Bezier_curve< K >::subdiv().

00107 { return cpoints.size()-1; };

Bezier_curve diff (  )  const [inline]

Definition at line 119 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::degree().

Referenced by Bezier_curve< K >::normal().

00119                            {
00120     int n=degree();
00121     Bezier_curve D(n-1);
00122     for (int k=0; k<n ; k++ )
00123       D[k]= n* ( cpoints[k+1]-cpoints[k] );
00124     return D;
00125   }

point<K> eval ( const K &  t  )  const [inline]

Definition at line 110 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::degree().

Referenced by Bezier_curve< K >::normal(), and Bezier_curve< K >::sample().

00111     {
00112       Seq<VECT> tmp(cpoints);
00113       for (int k=degree() ; k!=0; k-- )
00114         for (int i=0; i!=k; i++ )
00115           tmp[i]= (1.0-t)*tmp[i]+t*tmp[i+1] ;
00116       return tmp[0];
00117     }

point<K> normal ( const K &  t  )  const [inline]

Definition at line 95 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::diff(), Bezier_curve< K >::eval(), and mmx::shape::orth_vect().

Referenced by Bezier_curve< K >::unormal().

00095                                { 
00096     return orth_vect( diff().eval(t) ); 
00097   };

int npoints (  )  const [inline]

Definition at line 108 of file qsc_approximation_fcts.hpp.

References Seq< C, R >::size().

00108 { return cpoints.size(); };

point<K>& operator[] ( const int &  i  )  [inline]

Definition at line 105 of file qsc_approximation_fcts.hpp.

00105 { return cpoints[i]; };

point<K> operator[] ( const int &  i  )  const [inline]

Definition at line 104 of file qsc_approximation_fcts.hpp.

00104 { return cpoints[i]; };

void print ( viewer< axel, default_env > &  axl,
const int &  k = 50 
) [inline]

Definition at line 165 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::sample().

00165                                            {
00166 
00167     Seq<VECT> P;
00168     sample(P, k);
00169 
00170   axl<<" <curve type=\"mesh\">\n<vect>\nVECT\n";
00171   axl<< k-1 <<" "
00172      <<2*k-2<<" "
00173      <<k-1<<"\n";
00174   for(int i=1; i!=k;i++) axl<<"2 ";//
00175   axl<<"\n";
00176   for(int i=1; i!=k;i++) axl<<"1 ";//
00177   axl<<"\n";
00178 
00179   for(int i=1; i!=k;i+=1)
00180     axl<< P[i-1].x()<<" "<< P[i-1].y()<< " 0 " <<
00181       P[i].x()<<" "<< P[i].y()<< " 0 \n";
00182   
00183   for(int i=1; i!=k;i++)
00184     axl<< "0.314 0.979 1 1\n";
00185   axl<<" </vect>\n </curve>\n";
00186 
00187   };

void sample ( Seq< point< K > > &  P,
const Seq< K > &  TT 
) const [inline]

Definition at line 158 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::eval(), and Seq< C, R >::size().

00159     {
00160       for (unsigned i=0; i!= TT.size(); i++ )
00161         P << eval( TT[i] );
00162     };

void sample ( Seq< point< K > > &  P,
const int &  k 
) const [inline]

Definition at line 147 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::eval().

Referenced by Bezier_curve< K >::print().

00148     {
00149       K t( 1.0/ K(k-1) );
00150 
00151       P << cpoints[0];
00152       for (int i=1; i!=k-1; i++ )
00153         P << eval(i*t);
00154       P << cpoints[ cpoints.size()-1 ];
00155     };

Seq<Bezier_curve> subdiv ( const K  t = (K)0.5  )  const [inline]

Definition at line 127 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::Bezier_curve(), and Bezier_curve< K >::degree().

00127                                                    {
00128     int n=degree();
00129     Seq<VECT> l(n+1), r(cpoints);
00130     int k,i,j=0;
00131     
00132     for (k = degree(); k!= 0; k--, j++ )
00133     {
00134       l[j] = r[0];
00135       for ( i = 0; i != k; i++ )
00136         r[i] = ((K)1.0-t)*r[i]+t*r[i+1];
00137     }
00138     l[j] = r[0];
00139     
00140     Seq<Bezier_curve> S;
00141     S<< Bezier_curve(l) <<Bezier_curve(r);
00142     return S;
00143   }

point<K> unormal ( const K &  t  )  const [inline]

Definition at line 98 of file qsc_approximation_fcts.hpp.

References Bezier_curve< K >::normal(), and VECT.

00098                                 { 
00099     VECT nn=normal(t);
00100     return nn/nn.norm(); 
00101   };


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

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1