#include <vector>
#include <realroot/Interval.hpp>
#include <realroot/Seq.hpp>
Go to the source code of this file.
#define REP poly.rep() |
Definition at line 5 of file fatarcs_fcts.hpp.
#define SIZE poly.size() |
Definition at line 6 of file fatarcs_fcts.hpp.
#define SMALL C(10e-20) |
Definition at line 4 of file fatarcs_fcts.hpp.
C abs_max_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) | [inline] |
Definition at line 248 of file fatarcs_fcts.hpp.
References C, mmx::vctops::max(), max_coeff(), mmx::vctops::min(), min_coeff(), and box_rep< C >::poly.
Referenced by box_rep< C >::max_eval().
std::vector<C> approx | ( | polynomial< C, with< Bernstein > > | poly, | |
std::vector< C > | ep1, | |||
std::vector< C > | ep2, | |||
int | MTH | |||
) | [inline] |
Definition at line 276 of file fatarcs_fcts.hpp.
References mmx::array::assign(), C, mmx::brnops::eval(), is_unit1(), mmx::mul(), pint(), box_rep< C >::poly, seq2b(), solve2(), and vec().
Referenced by median().
00276 { 00277 polynomial< C ,with<MonomialTensor> > xt, yt, res, monp, mp("x0-x0^2"); 00278 polynomial< C ,with<Bernstein> > bxt, byt; 00279 C t, I; 00280 Seq<C> sols; 00281 std::vector<C> movec; 00282 00283 if (ep2.size()==0 ){movec=ep1;} 00284 else{ 00285 tensor::assign(monp.rep(),poly.rep()); 00286 00287 Seq<C> endptsx,endptsy; 00288 00289 endptsx<<ep2[0]<<ep1[0]; 00290 endptsy<<ep2[1]<<ep1[1]; 00291 bxt=seq2b(endptsx); tensor::assign(xt.rep(),bxt.rep()); 00292 byt=seq2b(endptsy); tensor::assign(yt.rep(),byt.rep()); 00293 00294 Seq<polynomial< C ,with<MonomialTensor> > > param; param<<xt<<yt; 00295 00296 tensor::eval(res, monp.rep(), param, 1); 00297 00298 00299 00300 C c0,c1; 00301 tensor::eval(c0,res.rep(),C(0)); 00302 tensor::eval(c1,res.rep(),C(1)); 00303 mul(res,mp); 00304 00305 I=pint(res); 00306 C u=C(15)*I-C(0.75)*(c0+c1); 00307 sols=solve2(c0+c1-C(2)*u,C(2)*(u-c0),c0); 00308 00309 00310 if(is_unit1(sols[0])) 00311 {t=sols[0]; movec=vec(ep1[0]*t+ep2[0]*(C(1)-t),ep1[1]*t+ep2[1]*(C(1)-t));} 00312 else if(is_unit1(sols[1])) 00313 {t=sols[1]; movec=vec(ep1[0]*t+ep2[0]*(C(1)-t),ep1[1]*t+ep2[1]*(C(1)-t));} 00314 else{movec=std::vector<C>();} 00315 00316 } 00317 00318 return movec; 00319 }; /*approx bivar bbpoly along line*/
polynomial< C ,with<Bernstein> > bbasis | ( | C | co, | |
int | n, | |||
int | deg | |||
) | [inline] |
Definition at line 168 of file fatarcs_fcts.hpp.
References binomial(), C, and mmx::mul().
Referenced by seq2b().
int binomial | ( | int | n, | |
int | p | |||
) |
Definition at line 154 of file fatarcs_fcts.hpp.
Referenced by bbasis().
Definition at line 369 of file fatarcs_fcts.hpp.
References arc_rep< C >::arc_eq(), C, is_small(), solve2(), and vec().
Referenced by extpts().
00369 { 00370 00371 Seq<C> eh1= c1.arc_eq(), eh2= c2.arc_eq(), sx, a; 00372 C Aeh,Ceh; 00373 if(!is_small(eh1[1]) && !is_small(eh1[2]) && !is_small(eh2[1]) && !is_small(eh2[2])){ 00374 00375 if(is_small(eh1[0]) && is_small(eh2[0])){ 00376 00377 Aeh=(C(-1)*eh2[1])/(eh2[2]); 00378 Ceh=(C(-1)*eh2[3])/(eh2[2]); 00379 sx[0]=(C(-1)*eh1[2]*Ceh-eh1[3])/(eh1[2]*Aeh+eh1[1]); 00380 00381 ispts[0]=vec(sx[0],Aeh*sx[0]+Ceh); 00382 ispts[1]=vec(sx[0],Aeh*sx[0]+Ceh); 00383 } 00384 else{ 00385 if(!is_small(eh1[0]) && !is_small(eh2[0])){ 00386 eh1=eh1/eh1[0]; 00387 eh2=eh2/eh2[0]; 00388 00389 Aeh=(eh2[1]-eh1[1])/(eh1[2]-eh2[2]); 00390 Ceh=(eh2[3]-eh1[3])/(eh1[2]-eh2[2]);} 00391 else{ 00392 if(is_small(eh1[0]) && !is_small(eh2[0])){a=eh1; eh1=eh2; eh2=a;}; 00393 00394 eh1=eh1/eh1[0]; 00395 00396 Aeh=(C(-1)*eh2[1])/(eh2[2]); 00397 Ceh=(C(-1)*eh2[3])/(eh2[2]);}; 00398 00399 00400 00401 sx=solve2(C(1)+Aeh*Aeh, C(2)*Aeh*Ceh+eh1[1]+eh1[2]*Aeh, Ceh*Ceh+eh1[2]*Ceh+eh1[3]); 00402 00403 ispts[0]=vec(sx[0],Aeh*sx[0]+Ceh); 00404 ispts[1]=vec(sx[1],Aeh*sx[1]+Ceh); 00405 00406 } 00407 } 00408 else{ ispts[0]=vec(C(-1),C(-1)); 00409 ispts[1]=vec(C(-1),C(-1)); 00410 }; 00411 };/*cicrcle intersections (numerical behaviour!)*/
Definition at line 260 of file fatarcs_fcts.hpp.
References C, mmx::brnops::eval(), and vec().
std::vector<C> crossrat | ( | std::vector< C > | v1, | |
std::vector< C > | v2, | |||
std::vector< C > | v3, | |||
std::vector< C > | v4 | |||
) | [inline] |
C dot | ( | std::vector< C > | p, | |
std::vector< C > | q | |||
) | [inline] |
Definition at line 37 of file fatarcs_fcts.hpp.
References C.
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::midc(), v_length(), and arc_rep< C >::weight().
Definition at line 432 of file fatarcs_fcts.hpp.
References C, circ_is(), arc_rep< C >::critpt(), is_arc(), is_infatarc(), is_unit2(), arc_rep< C >::offset(), arc_rep< C >::pts, Seq< C, R >::size(), and vec().
Referenced by solver_mv_fatarcs< C >::box_gen().
00432 { 00433 00434 arc_rep<C> 00435 c1p=mc1.offset(r1),c1m=mc1.offset(C(-1)*r1), 00436 c2p=mc2.offset(r2),c2m=mc2.offset(C(-1)*r2); 00437 std::vector<C> p[2]; 00438 Seq< std::vector<C> > ispts; 00439 00440 if(is_arc(c1p) && is_arc(c2p)){ circ_is(p,c1p,c2p); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; 00441 if(is_arc(c1p) && is_arc(c2m)){ circ_is(p,c1p,c2m); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; 00442 if(is_arc(c1m) && is_arc(c2m)){ circ_is(p,c1m,c2m); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; 00443 if(is_arc(c1m) && is_arc(c2p)){ circ_is(p,c1m,c2p); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; 00444 00445 if(is_arc(c1p) && is_infatarc(c1p.pts[0],c2m,c2p)){ispts<<c1p.pts[0];}; 00446 if(is_arc(c1p) && is_infatarc(c1p.pts[2],c2m,c2p)){ispts<<c1p.pts[2];}; 00447 if(is_arc(c1m) && is_infatarc(c1m.pts[0],c2m,c2p)){ispts<<c1m.pts[0];}; 00448 if(is_arc(c1m) && is_infatarc(c1m.pts[2],c2m,c2p)){ispts<<c1m.pts[2];}; 00449 00450 if(is_arc(c2p) && is_infatarc(c2p.pts[0],c1m,c1p)){ispts<<c2p.pts[0];}; 00451 if(is_arc(c2p) && is_infatarc(c2p.pts[2],c1m,c1p)){ispts<<c2p.pts[2];}; 00452 if(is_arc(c2m) && is_infatarc(c2m.pts[0],c1m,c1p)){ispts<<c2m.pts[0];}; 00453 if(is_arc(c2m) && is_infatarc(c2m.pts[2],c1m,c1p)){ispts<<c2m.pts[2];}; 00454 00455 if(is_arc(c1p) && is_infatarc(c1p.critpt(0),c2m,c2p)){ispts<<c1p.critpt(0);}; 00456 if(is_arc(c1p) && is_infatarc(c1p.critpt(1),c2m,c2p)){ispts<<c1p.critpt(1);}; 00457 if(is_arc(c1m) && is_infatarc(c1m.critpt(0),c2m,c2p)){ispts<<c1m.critpt(0);}; 00458 if(is_arc(c1m) && is_infatarc(c1m.critpt(1),c2m,c2p)){ispts<<c1m.critpt(1);}; 00459 00460 if(is_arc(c2p) && is_infatarc(c2p.critpt(0),c1m,c1p)){ispts<<c2p.critpt(0);}; 00461 if(is_arc(c2p) && is_infatarc(c2p.critpt(1),c1m,c1p)){ispts<<c2p.critpt(1);}; 00462 if(is_arc(c2m) && is_infatarc(c2m.critpt(0),c1m,c1p)){ispts<<c2m.critpt(0);}; 00463 if(is_arc(c2m) && is_infatarc(c2m.critpt(1),c1m,c1p)){ispts<<c2m.critpt(1);}; 00464 00465 00466 Seq< std::vector<C> > cpts; cpts<<vec(C(0),C(0));cpts<<vec(C(0),C(1));cpts<<vec(C(1),C(0));cpts<<vec(C(1),C(1)); 00467 00468 for(unsigned i=0; i<cpts.size(); i++){ if( is_infatarc(cpts[i],c1m,c1p) && 00469 is_infatarc(cpts[i],c2m,c2p) ){ ispts<<cpts[i]; }; 00470 }; 00471 00472 return ispts; 00473 };
bool is_arc | ( | arc_rep< C > | c | ) | [inline] |
Definition at line 415 of file fatarcs_fcts.hpp.
References arc_rep< C >::pts.
Referenced by solver_mv_fatarcs< C >::box_gen(), extpts(), is_infatarc(), and arc_rep< C >::offset().
Definition at line 422 of file fatarcs_fcts.hpp.
References C, crossrat(), is_arc(), and arc_rep< C >::pts.
Referenced by extpts().
bool is_small | ( | C | p | ) | [inline] |
Definition at line 110 of file fatarcs_fcts.hpp.
References C.
Referenced by circ_is(), box_rep< C >::corner_event(), median(), and solve2().
00110 { 00111 if(p==C(0)){return true;} 00112 else{return false;} 00113 };
bool is_unit1 | ( | C | p | ) | [inline] |
Definition at line 138 of file fatarcs_fcts.hpp.
References C.
Referenced by approx(), arc_rep< C >::critpt(), is_unit2(), median(), and arc_rep< C >::offset().
bool is_unit2 | ( | std::vector< C > | p | ) | [inline] |
bool is_zero | ( | C | p | ) | [inline] |
Definition at line 104 of file fatarcs_fcts.hpp.
References C.
00104 { 00105 if(p==C(0)){return true;} 00106 else{return false;} 00107 };
std::vector<C> matrat | ( | std::vector< C > | v1, | |
std::vector< C > | v2 | |||
) | [inline] |
Definition at line 89 of file fatarcs_fcts.hpp.
References vec().
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::arc_rep(), and crossrat().
00089 { 00090 std::vector<C> mm; mm=vec(v1[0]*v2[0]+v1[1]*v2[1],v1[0]*v2[1]-v2[0]*v1[1]); 00091 return(mm); 00092 };
C max_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) | [inline] |
Definition at line 232 of file fatarcs_fcts.hpp.
References C, mmx::vctops::max(), REP, and SIZE.
Referenced by abs_max_coeff(), and box_rep< C >::not_empty().
Definition at line 323 of file fatarcs_fcts.hpp.
References approx(), C, is_small(), is_unit1(), box_rep< C >::poly, rotl(), mmx::size(), v_div(), v_minus(), v_plus(), and vec().
Referenced by solver_mv_fatarcs< C >::box_gen().
00323 { 00324 std::vector<C> endp[2], mpts[3]; 00325 int s=0; 00326 arc_rep<C> medc; 00327 for(int i=0; i<3; i++){mpts[i]=std::vector<C>();}; 00328 00329 00330 mpts[0]=approx(box.poly, list[0], list[1], MTH); 00331 mpts[1]=approx(box.poly, list[2], list[3], MTH); 00332 00333 if( mpts[0].size()!=0 && mpts[1].size()!=0 ){ 00334 00335 std::vector<C> mid, rvec, v; 00336 mid=v_div(v_plus(mpts[0],mpts[1]),C(2)); 00337 rvec=rotl(v_minus(mpts[0],mpts[1])); 00338 C bval[4]; 00339 00340 if(!is_small(rvec[0])){ 00341 bval[0]=rvec[1]*C(-1)*mid[0]/rvec[0]+mid[1]; 00342 bval[1]=rvec[1]*(C(1)-mid[0])/rvec[0]+mid[1];}else{ bval[0]=C(-1); bval[1]=C(-1);} 00343 00344 if(!is_small(rvec[1])){ 00345 bval[2]=rvec[0]*C(-1)*mid[1]/rvec[1]+mid[0]; 00346 bval[3]=rvec[0]*(C(1)-mid[1])/rvec[1]+mid[0];}else{ bval[2]=C(-1); bval[3]=C(-1);} 00347 00348 if(is_unit1(bval[0]) && s<2){endp[s]= vec(C(0),bval[0]); s++;}; 00349 if(is_unit1(bval[1]) && s<2){endp[s]= vec(C(1),bval[1]); s++;}; 00350 if(is_unit1(bval[2]) && s<2){endp[s]= vec(bval[2],C(0)); s++;}; 00351 if(is_unit1(bval[3]) && s<2){endp[s]= vec(bval[3],C(1)); s++;}; 00352 mpts[2]=mpts[1]; 00353 00354 if(s==2){ mpts[1]=approx(box.poly, endp[0], endp[1], MTH);} 00355 00356 if(mpts[1].size()!=0){ medc=arc_rep<C>(mpts);}else{medc=arc_rep<C>();} 00357 //else{ for(int i=0; i<3; i++){mpts[i]= vec(C(-1),C(-1));};} 00358 00359 }else{ medc=arc_rep<C>(); }; 00360 00361 00362 //std::cout <<"med: "<<mpts[0]<<" "<<mpts[1]<<" "<<mpts[2]<<std::endl; 00363 00364 return(medc); 00365 }; /*median arc computation*/
C min_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) | [inline] |
Definition at line 217 of file fatarcs_fcts.hpp.
References C, mmx::vctops::min(), REP, and SIZE.
Referenced by abs_max_coeff(), box_rep< C >::max_eval(), box_rep< C >::min_grad(), and box_rep< C >::not_empty().
Definition at line 476 of file fatarcs_fcts.hpp.
References C, domain< C >::delta(), and domain< C >::I.
Referenced by solver_mv_fatarcs< C >::box_gen().
00476 { 00477 domain<C> newbox=box; 00478 // C minx, maxx, miny, maxy; 00479 if(ispts.size()==0) { 00480 newbox=domain<C>(int(0)); 00481 } else { 00482 int k=0; 00483 C minx=ispts[0][0], maxx=ispts[0][0], miny=ispts[0][1], maxy=ispts[0][1]; 00484 for(unsigned i=0; i<ispts.size(); i++){ 00485 if(k==0){ minx=ispts[i][0]; maxx=ispts[i][0]; miny=ispts[i][1]; maxy=ispts[i][1]; k++;}; 00486 if(ispts[i][0]>maxx){maxx=ispts[i][0];}; 00487 if(ispts[i][0]<minx){minx=ispts[i][0];}; 00488 if(ispts[i][1]>maxy){maxy=ispts[i][1];}; 00489 if(ispts[i][1]<miny){miny=ispts[i][1];}; 00490 }; 00491 00492 Interval<C> Jx( minx, maxx), Jy( miny, maxy) ; 00493 if((maxx-minx)>C(0) && (maxy-miny)>C(0)) 00494 { newbox= domain<C>( box.I[0].m + box.delta()[0]*Jx , box.I[1].m + box.delta()[1]*Jy ); }; 00495 } 00496 return(newbox); 00497 };/*minmax box for the arc intersection points and arc end points*/
C pint | ( | polynomial< C, with< MonomialTensor > > | poly | ) | [inline] |
void pow | ( | polynomial< C, with< Bernstein > > & | poly, | |
int | n | |||
) | [inline] |
Definition at line 180 of file fatarcs_fcts.hpp.
References mmx::mul(), and box_rep< C >::poly.
Referenced by box_rep< C >::max_eval(), and solver< C, ProjRd< MTH > >::set_precision().
00181 { 00182 polynomial< C ,with<Bernstein> > t=poly; 00183 00184 for(int i=1; i<n; i++){ mul(poly, t); }; 00185 }/*nth power of a bbpoly*/
std::vector<C> rotl | ( | std::vector< C > | p | ) | [inline] |
Definition at line 32 of file fatarcs_fcts.hpp.
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
Definition at line 190 of file fatarcs_fcts.hpp.
References mmx::array::add(), bbasis(), and Seq< C, R >::size().
Referenced by approx(), arc_rep< C >::critpt(), and box_rep< C >::max_eval().
Seq<C> solve2 | ( | C | a, | |
C | b, | |||
C | c | |||
) | [inline] |
Definition at line 124 of file fatarcs_fcts.hpp.
References C, is_small(), mmx::sign(), and mmx::sqrt().
Referenced by approx(), circ_is(), and arc_rep< C >::offset().
00124 { 00125 Seq<C> r; r<<C(-1)<<C(-1); 00126 C root1,root2; 00127 if(is_small(a)){if(!is_small(b)){r[0]=C(-1)*c/b;r[1]=C(-1)*c/b;}} 00128 else{if(sign(b*b-C(4)*a*c) >= 0){ 00129 root1=(C(-1)*b+sqrt(b*b-C(4)*a*c))/(C(2)*a); 00130 root2=(C(-1)*b-sqrt(b*b-C(4)*a*c))/(C(2)*a); 00131 r[0]=root1;r[1]=root2;} 00132 } 00133 00134 return(r); 00135 };/*solve(a*x^2+b*x+c=0)*/
std::vector<C> v_div | ( | std::vector< C > | p, | |
C | q | |||
) | [inline] |
Definition at line 66 of file fatarcs_fcts.hpp.
References C.
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
C v_length | ( | std::vector< C > | p | ) | [inline] |
Definition at line 84 of file fatarcs_fcts.hpp.
References C, dot(), and mmx::sqrt().
Referenced by arc_rep< C >::offset(), and arc_rep< C >::weight().
std::vector<C> v_minus | ( | std::vector< C > | p, | |
std::vector< C > | q | |||
) | [inline] |
Definition at line 56 of file fatarcs_fcts.hpp.
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::arc_rep(), crossrat(), median(), arc_rep< C >::midc(), arc_rep< C >::offset(), and arc_rep< C >::weight().
std::vector<C> v_mul | ( | C | q, | |
std::vector< C > | p | |||
) | [inline] |
Definition at line 75 of file fatarcs_fcts.hpp.
References C.
Referenced by arc_rep< C >::midc(), and arc_rep< C >::offset().
00075 { 00076 std::vector<C> v(p.size(),C(0)); 00077 for(unsigned i=0; i<p.size(); i++){ 00078 v[i]=p[i]*q; 00079 } 00080 return(v); 00081 };
std::vector<C> v_plus | ( | std::vector< C > | p, | |
std::vector< C > | q | |||
) | [inline] |
Definition at line 46 of file fatarcs_fcts.hpp.
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
std::vector<C> vec | ( | const C | c1, | |
const C | c2 | |||
) | [inline] |
Definition at line 25 of file fatarcs_fcts.hpp.
References C.
Referenced by approx(), arc_rep< C >::arc_eq(), circ_is(), box_rep< C >::corner_event(), corner_values(), arc_rep< C >::critpt(), box_rep< C >::event_list(), extpts(), matrat(), median(), arc_rep< C >::offset(), and rotl().
00025 { 00026 std::vector<C> a(2, C(0)); 00027 a[0]= c1; a[1]= c2; 00028 return a; 00029 }