Qsc_curve< K > Class Template Reference

#include <qsc_approximation_fcts.hpp>

List of all members.

Public Member Functions


Detailed Description

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

Definition at line 232 of file qsc_approximation_fcts.hpp.


Constructor & Destructor Documentation

Qsc_curve (  )  [inline]

Definition at line 235 of file qsc_approximation_fcts.hpp.

00235 {};

Qsc_curve ( const K &  u,
const K &  v,
const K &  w,
const K &  a1,
const K &  a2,
const point< K > &  nn0,
const point< K > &  nn1,
const int &  pp = 1 
) [inline]

Definition at line 243 of file qsc_approximation_fcts.hpp.

References point< C, N, V >::norm().

00245     {
00246       //h=POL(u,2,0)+POL(v,2,1)+
00247       //  POL(w,1,0)*POL(1,1,1)+
00248       //  POL(a1,1,0)+POL(a2,1,1);
00249       h << u << v << w << a1 << a2;
00250 
00251       path=(pp<0 ? -1 : 1 );
00252       n0= nn0 / nn0.norm();
00253       n1= nn1 / nn1.norm();
00254     };

Qsc_curve ( const Bezier_curve< K > &  B  )  [inline]

Definition at line 257 of file qsc_approximation_fcts.hpp.

References mmx::linear::LUsolve(), Rsc_curve< K >::nend(), Rsc_curve< K >::nmiddle(), Rsc_curve< K >::nstart(), Rsc_curve< K >::orientation(), Rsc_curve< K >::sdiff(), Rsc_curve< K >::seval(), Rsc_curve< K >::sgrad(), Qsc_curve< K >::support(), and VECT.

00258     {
00259       Rsc_curve<K> Rc(B);
00260       n0= Rc.nstart();
00261       n1= Rc.nend();
00262       *this=Qsc_curve<K>(n0, Rc.seval(n0), Rc.sdiff(n0),
00263                    Rc.nmiddle(), Rc.seval(Rc.nmiddle()),
00264                    n1, Rc.seval(n1), Rc.sdiff(n1),
00265                    Rc.orientation() );
00266 
00267       return;//finished -- old version below
00268 
00269       Rsc_curve<K> R(B);
00270       path= R.orientation();
00271       n0= R.nstart();
00272       n1= R.nend();
00273 
00274       K Vh[5]; // the values of h and its derivative at the control points
00275       K Mq[25]; // the values of q and its derivative at the control points (exp
00276       VECT nn, dh;// temporary vectors
00277 
00278       // first line: value at n0
00279       nn=R.nstart(); 
00280       Vh[0]= R.seval(nn);
00281       Mq[0]= nn[0]*nn[0]; // x^2
00282       Mq[1]= nn[1]*nn[1]; // y^2
00283       Mq[2]= nn[0]*nn[1]; // x*y
00284       Mq[3]= nn[0]; // x
00285       Mq[4]= nn[1]; // y
00286 
00287       // second line: fi-derivative at n0
00288       dh= R.sgrad(nn);// fi-deriv: [h( n(fi))]' = h'(n(fi))*n'(fi)
00289       Vh[1]= -dh[0]*nn[1] + dh[1]*nn[0];
00290       Mq[5]=-2*nn[0]*nn[1]; // -2*x*y
00291       Mq[6]=2*nn[0]*nn[1]; // 2*x*y
00292       Mq[7]=(nn[0]*nn[0]-nn[1]*nn[1]); // x^2-y^2
00293       Mq[8]=-nn[1]; // -y
00294       Mq[9]=nn[0]; // x
00295 
00296       // third line: value at n1
00297       nn= R.nend(); 
00298       Vh[2]= R.seval(nn);
00299       Mq[10]= nn[0]*nn[0]; // x^2
00300       Mq[11]= nn[1]*nn[1]; // y^2
00301       Mq[12]= nn[0]*nn[1]; // x*y
00302       Mq[13]= nn[0]; // x
00303       Mq[14]= nn[1]; // y
00304 
00305       // forth line: fi-derivative at n1
00306       dh= R.sgrad(nn);// fi-deriv: [h( n(fi))]' = h'(n(fi))*n'(fi)
00307       Vh[3]= -dh[0]*nn[1] + dh[1]*nn[0];
00308       Mq[15]=-2*nn[0]*nn[1]; // -2*x*y
00309       Mq[16]=2*nn[0]*nn[1]; // 2*x*y
00310       Mq[17]=(nn[0]*nn[0]-nn[1]*nn[1]); // x^2-y^2
00311       Mq[18]=-nn[1]; // -y
00312       Mq[19]=nn[0]; // x
00313 
00314       // fifth line: value at the middle (n0+n1)/2
00315       nn=R.nmiddle();
00316       //nn=B.unormal(.5); 
00317       Vh[4]= R.seval(nn);
00318       Mq[20]= nn[0]*nn[0]; // x^2
00319       Mq[21]= nn[1]*nn[1]; // y^2
00320       Mq[22]= nn[0]*nn[1]; // x*y
00321       Mq[23]= nn[0]; // x
00322       Mq[24]= nn[1]; // y
00323 
00324       // Solve
00325       K q[5];
00326       linear::LUsolve(q,Mq,Vh,5); // Mq*q=Vh ; size 5
00327         for (int j=0; j<5; j++)
00328           h << q[j];
00329 
00330       std::cout<< support() <<"\n";
00331     };

Qsc_curve ( const point< K > &  nn0,
const K &  vn0,
const K &  dn0,
const point< K > &  nnm,
const K &  vnm,
const point< K > &  nn1,
const K &  vn1,
const K &  dn1,
const int &  pp = 1 
) [inline]

Definition at line 334 of file qsc_approximation_fcts.hpp.

References mmx::linear::LUsolve(), and Qsc_curve< K >::support().

00337     {
00338       path= pp;
00339       n0  = nn0;
00340       n1  = nn1;
00341 
00342       K Vh[5]; // the values of h and its derivative at the control points
00343       K Mq[25]; // the values of q and its derivative at the control points (exp
00344 
00345       // first line: value at n0
00346       Vh[0]= vn0;//R.seval(n0);
00347       Mq[0]= n0[0]*n0[0]; // x^2
00348       Mq[1]= n0[1]*n0[1]; // y^2
00349       Mq[2]= n0[0]*n0[1]; // x*y
00350       Mq[3]= n0[0]; // x
00351       Mq[4]= n0[1]; // y
00352 
00353       // second line: fi-derivative at n0
00354       Vh[1]= dn0;
00355       Mq[5]=-2*n0[0]*n0[1]; // -2*x*y
00356       Mq[6]=2*n0[0]*n0[1]; // 2*x*y
00357       Mq[7]=(n0[0]*n0[0]-n0[1]*n0[1]); // x^2-y^2
00358       Mq[8]=-n0[1]; // -y
00359       Mq[9]=n0[0]; // x
00360 
00361       // third line: value at n1
00362       Vh[2]= vn1; //R.seval(n1);
00363       Mq[10]= n1[0]*n1[0]; // x^2
00364       Mq[11]= n1[1]*n1[1]; // y^2
00365       Mq[12]= n1[0]*n1[1]; // x*y
00366       Mq[13]= n1[0]; // x
00367       Mq[14]= n1[1]; // y
00368 
00369       // forth line: fi-derivative at n1
00370       Vh[3]= dn1;
00371       Mq[15]=-2*n1[0]*n1[1]; // -2*x*y
00372       Mq[16]=2*n1[0]*n1[1]; // 2*x*y
00373       Mq[17]=(n1[0]*n1[0]-n1[1]*n1[1]); // x^2-y^2
00374       Mq[18]=-n1[1]; // -y
00375       Mq[19]=n1[0]; // x
00376 
00377       // fifth line: value at the middle (n0+n1)/2
00378       Vh[4]= vnm; // R.seval(nn);
00379       Mq[20]= nnm[0]*nnm[0]; // x^2
00380       Mq[21]= nnm[1]*nnm[1]; // y^2
00381       Mq[22]= nnm[0]*nnm[1]; // x*y
00382       Mq[23]= nnm[0]; // x
00383       Mq[24]= nnm[1]; // y
00384 
00385       // Solve
00386       K q[5];
00387       linear::LUsolve(q,Mq,Vh,5); // Mq*q=Vh ; size 5
00388         for (int j=0; j<5; j++)
00389           h << q[j];
00390 
00391       std::cout<< support() <<"\n";
00392     };


Member Function Documentation

int ccw (  )  const [inline]

Definition at line 430 of file qsc_approximation_fcts.hpp.

Referenced by Qsc_curve< K >::sample(), and Qsc_curve< K >::ssample().

00430                         { 
00431    //return (path==1 ? : true : false);
00432    return ( n0[0]*n1[1]- n0[1]*n1[0] <0 ? -1 : 1 );
00433   };

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

Definition at line 407 of file qsc_approximation_fcts.hpp.

References VECT.

Referenced by Qsc_curve< K >::sample().

00408     {
00409       return VECT( -h[0]*std::pow(n[0],3)
00410                    -h[2]*std::pow(n[0],2)*n[1]
00411                    -h[1]*std::pow(n[1],2)*n[0]
00412                    +h[0]*2*n[0]
00413                    +h[2]*n[1]
00414                    +h[3] , 
00415                    -h[1]*std::pow(n[1],3)
00416                    -h[2]*std::pow(n[1],2)*n[0]
00417                    -h[0]*std::pow(n[0],2)*n[1]
00418                    +h[1]*2*n[1]
00419                    +h[2]*n[0]
00420                    +h[4] ); 
00421     };

point<K>& nend (  )  [inline]

Definition at line 568 of file qsc_approximation_fcts.hpp.

00568 {return n1; };

point<K> nmiddle (  )  [inline]

Definition at line 569 of file qsc_approximation_fcts.hpp.

References point< C, N, V >::norm(), and VECT.

00569 { VECT m= n0+n1; return m/m.norm(); };

point<K>& nstart (  )  [inline]

Definition at line 567 of file qsc_approximation_fcts.hpp.

00567 {return n0; };

int orientation (  )  [inline]

Definition at line 570 of file qsc_approximation_fcts.hpp.

00570 {return path; };

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

Definition at line 514 of file qsc_approximation_fcts.hpp.

References Qsc_curve< K >::sample().

00514                                            {
00515 
00516     Seq<VECT> P;
00517     sample(P, k);
00518 
00519     //axl<<" <point>"<< P[0] << " </point>\n";
00520     //axl<<" <point>"<< P[P.size()-1] << " </point>\n";
00521 
00522   axl<<" <curve type=\"mesh\">\n<vect>\nVECT\n";
00523   axl<< k-1 <<" "
00524      <<2*k-2<<" "
00525      <<k-1<<"\n";
00526   for(int i=1; i!=k;i++) axl<<"2 ";//
00527   axl<<"\n";
00528   for(int i=1; i!=k;i++) axl<<"1 ";//
00529   axl<<"\n";
00530 
00531   for(int i=1; i!=k;i+=1)
00532     axl<< P[i-1].x()<<" "<< P[i-1].y()<< " 0 " <<
00533       P[i].x()<<" "<< P[i].y()<< " 0 \n";
00534   
00535   for(int i=1; i!=k;i++)
00536     axl<< "0.314 0.979 1 1\n";
00537   axl<<" </vect>\n </curve>\n";
00538 
00539   };

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

Definition at line 542 of file qsc_approximation_fcts.hpp.

References Qsc_curve< K >::ssample().

00542                                                       {
00543 
00544     Seq<K> P;
00545 
00546     ssample(P, k);
00547     
00548     axl<<" <curve type=\"mesh\">\n<vect>\nVECT\n";
00549     axl<< k-1 <<" "
00550        <<2*k-2<<" "
00551        <<k-1<<"\n";
00552     for(int i=1; i!=k;i++) axl<<"2 ";//
00553     axl<<"\n";
00554     for(int i=1; i!=k;i++) axl<<"1 ";//
00555     axl<<"\n";
00556     
00557     for(int i=3; i<2*k;i+=2)
00558       axl<< P[i-3]<<" "<< P[i-2]<< " 0 " <<
00559         P[i-1]<<" "<< P[ i ]<< " 0 \n";
00560     
00561     for(int i=1; i!=k;i++)
00562       axl<< "0.314 0.979 1 1\n";
00563     axl<<" </vect>\n </curve>\n";
00564   };

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

Definition at line 473 of file qsc_approximation_fcts.hpp.

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

00474     {
00475       for (unsigned i=0; i!= NN.size(); i++ )
00476         P << eval( NN[i] );
00477     };

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

Definition at line 437 of file qsc_approximation_fcts.hpp.

References Qsc_curve< K >::ccw(), mmx::shape::dot(), Qsc_curve< K >::eval(), PI, and VECT.

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

00438     {
00439       K f0,fi;
00440       f0= acos( n0[0] );
00441       if (sin(n0[1])<0) f0= 2*PI- f0;
00442 
00443       if ( path * ccw() > 0 ) 
00444       {
00445         fi =  path * acos( dot(n0,n1)) / K(k-1) ;
00446         if ( n0==n1) 
00447           fi=  2*PI / K(k-1) ;
00448       }
00449       else
00450       {
00451         fi =  path * (2*PI - acos(dot(n0,n1))) / K(k-1);
00452       }
00453       std::cout<<"f0: "<< f0  <<"\n";
00454       std::cout<<"cos : "<< cos( f0 )  <<"\n";
00455       std::cout<<"cosn: "<< cos( acos(n0[0]) )  <<"\n";
00456       std::cout<<"sin : "<< sin( f0 )  <<"\n";
00457       std::cout<<"sinn: "<< sin( asin(n0[1]) )  <<"\n";
00458 
00459       //P<< eval(n0);
00460       P << eval( VECT(cos(f0), sin(f0)) ) ;
00461       for(int i=2; i!=k; i++ )
00462       {
00463         f0+= fi;
00464         P << eval( VECT(cos(f0), sin(f0)) ) ;
00465       }
00466       //P<< eval(n1);
00467       P << eval( VECT(cos(f0+fi), sin(f0+fi)) ) ;
00468 
00469     };

K seval ( const point< K > &  n  )  const [inline]

Definition at line 396 of file qsc_approximation_fcts.hpp.

References mmx::pow().

Referenced by Qsc_curve< K >::ssample().

00397     {
00398       return 
00399         h[0]*std::pow(n[0],2)+
00400         h[1]*std::pow(n[1],2)+
00401         h[2]*n[0]*n[1]+
00402         h[3]*n[0]+
00403         h[4]*n[1];
00404     };

point<K> sgrad ( const point< K > &  n  )  const [inline]

Definition at line 424 of file qsc_approximation_fcts.hpp.

References mmx::diff(), POL, Qsc_curve< K >::support(), and VECT.

00425     {
00426       POL hh= support();
00427       return VECT( mmx::diff(hh,0), mmx::diff(hh,1) ) ;
00428     };

void ssample ( Seq< K > &  P,
const int &  k = 50 
) const [inline]

Definition at line 480 of file qsc_approximation_fcts.hpp.

References Qsc_curve< K >::ccw(), mmx::shape::dot(), PI, Qsc_curve< K >::seval(), and VECT.

Referenced by Qsc_curve< K >::print_supp_graph().

00481     {
00482       K f0,fi, fs;
00483       f0= acos( n0[0] );
00484       if (sin(n0[1])<0) f0= 2*PI- f0;
00485       //std::cout<<"ccw: "<< ccw() <<"\n";
00486 
00487       if ( path * ccw() > 0 ) 
00488       {
00489         fs= acos( dot(n0,n1));
00490         fi = path * fs / K(k-1) ;
00491 //        if ( abs(fi)<0.000001) 
00492 //          fi=  2*PI / K(k-1) ;
00493       }
00494       else
00495       {
00496         fs= (2*PI - acos(dot(n0,n1)));
00497         fi =  path * fs / K(k-1);
00498       }
00499 
00500       P<< 0.0 ;
00501       P<< seval(n0);
00502       for(int i=2; i!=k; i++ )
00503       {
00504         f0+= fi ;
00505         P<< (i-1)*fi;
00506         P << seval( VECT(cos(f0), sin(f0)) ) ;
00507       }
00508       P<< k*fi ;
00509       P<< seval(n1);
00510 
00511     };

polynomial<K,with<MonomialTensor> > support (  )  [inline]

Definition at line 577 of file qsc_approximation_fcts.hpp.

References POL.

Referenced by Qsc_curve< K >::Qsc_curve(), and Qsc_curve< K >::sgrad().

00578     {
00579       POL sf(h[0],2,0);
00580       sf += POL(h[1],2,1)+POL(h[2],1,0)*POL(1,1,1)
00581         +POL(h[3],1,0)+POL(h[4],1,1);
00582       return sf;
00583     };

K support_size (  )  [inline]

Definition at line 572 of file qsc_approximation_fcts.hpp.

References mmx::shape::dot().

00573     {
00574       return acos(dot(n0,n1));
00575     };


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

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1