From: <pa...@us...> - 2010-03-15 14:04:34
|
Revision: 775 http://xcas.svn.sourceforge.net/xcas/?rev=775&view=rev Author: parisse Date: 2010-03-15 14:04:21 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Modified Paths: -------------- trunk/giac-xcas/giac/src/Graph.cc trunk/giac-xcas/giac/src/plot.cc trunk/giac-xcas/giac/src/plot.h trunk/giac-xcas/giac/src/subst.cc trunk/giac-xcas/giac/src/threaded.cc Modified: trunk/giac-xcas/giac/src/Graph.cc =================================================================== --- trunk/giac-xcas/giac/src/Graph.cc 2010-03-12 10:30:24 UTC (rev 774) +++ trunk/giac-xcas/giac/src/Graph.cc 2010-03-15 14:04:21 UTC (rev 775) @@ -3057,7 +3057,7 @@ round3(newy,window_ymin,window_ymax); if (gr3d) round3(newz,window_zmin,window_zmax); - tmp=geometry_round(newx,newy,newz,eps,tmp2,pos,mode==0); + tmp=geometry_round(newx,newy,newz,eps,tmp2,pos,mode==0 || (args_tmp.size()==mode && function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr))); if (tmp.type==_VECT && tmp._VECTptr->size()==3){ tmp.subtype=_SEQ__VECT; tmp=symbolic(at_point,tmp); @@ -3363,7 +3363,23 @@ objname=gen(autoname(hp->contextptr),hp->contextptr); } } - tmp_plot=symbolic(*ptr,gen( (*ptr==(gr3d?at_sphere:at_cercle) && !args_tmp.back().is_symb_of_sommet(at_extract_measure)) ?makevecteur(args_tmp.front(),args_tmp.back()-args_tmp.front()):args_tmp,_SEQ__VECT)); + vecteur argv=args_tmp; + if (*ptr==(gr3d?at_sphere:at_cercle)){ + gen argv1; + try { + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); + } + catch (std::runtime_error & e){ + argv1=undef; + } + if (argv1.is_symb_of_sommet(at_pnt) ||argv1.type==_IDNT){ + argv1=remove_at_pnt(argv1); + if ( (argv1.type==_VECT && argv1.subtype==_POINT__VECT) || argv1.type==_CPLX || argv1.type==_IDNT) + argv.back()=args_tmp.back()-args_tmp.front(); + } + } + tmp_plot=symbolic(*ptr,gen(argv,_SEQ__VECT)); try { res=evalf(tmp_plot,1,hp->contextptr); } @@ -3381,15 +3397,35 @@ vecteur l; if (res._VECTptr->back()==res._VECTptr->front()) --ns; - if (ns>=mode) - ns=mode; - for (int i=1;i<=ns;++i){ - tmp_plot=symbolic(at_segment,makevecteur(args_tmp[i-1],args_tmp[i%ns])); - hp->set_gen_value(hp_pos,symbolic(at_sto,makevecteur(add_attributs(tmp_plot,couleur),gen(autoname(hp->contextptr)+print_INT_(ns+i),hp->contextptr))),false); - hp->add_entry(hp_pos+1); - ++hp_pos; + if (function_final.type==_FUNC && equalposcomp(transformation_functions,*function_final._FUNCptr)){ + vecteur argv; + gen objn,som=symbolic(at_sommets,objname); + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_at,gen(makevecteur(som,i-1),_SEQ__VECT)); + objn=gen(autoname(hp->contextptr)+print_INT_(i),hp->contextptr); + argv.push_back(objn); + hp->set_gen_value(hp_pos,symbolic(at_sto,gen(makevecteur(tmp_plot,objn),_SEQ__VECT)),false); + hp->add_entry(hp_pos+1); + ++hp_pos; + } + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_segment,makevecteur(argv[i-1],argv[i%ns])); + hp->set_gen_value(hp_pos,symbolic(at_sto,makevecteur(add_attributs(tmp_plot,couleur),gen(autoname(hp->contextptr)+print_INT_(ns+i),hp->contextptr))),false); + hp->add_entry(hp_pos+1); + ++hp_pos; + } } - } + else { + if (ns>=mode) + ns=mode; + for (int i=1;i<=ns;++i){ + tmp_plot=symbolic(at_segment,makevecteur(args_tmp[i-1],args_tmp[i%ns])); + hp->set_gen_value(hp_pos,symbolic(at_sto,makevecteur(add_attributs(tmp_plot,couleur),gen(autoname(hp->contextptr)+print_INT_(ns+i),hp->contextptr))),false); + hp->add_entry(hp_pos+1); + ++hp_pos; + } + } + } // if res.type==_VECT } autoname_plus_plus(); hp->update(pos0); @@ -4495,8 +4531,21 @@ if (function.type==_FUNC){ bool dim2=dynamic_cast<Graph2d *>(this); vecteur args2=args_tmp; - if ( *function._FUNCptr==(dim2?at_cercle:at_sphere) && !args_tmp.back().is_symb_of_sommet(at_extract_measure)) - args2=makevecteur(args_tmp.front(),args_tmp.back()-args_tmp.front()); + if ( *function._FUNCptr==(dim2?at_cercle:at_sphere)){ + gen argv1; + try { + argv1=evalf(args_tmp.back(),1,contextptr); + argv1=evalf_double(argv1,1,contextptr); + } + catch (std::runtime_error & e){ + argv1=undef; + } + if (argv1.is_symb_of_sommet(at_pnt) ||argv1.type==_IDNT){ + argv1=remove_at_pnt(argv1); + if ( (argv1.type==_VECT && argv1.subtype==_POINT__VECT) || argv1.type==_CPLX || argv1.type==_IDNT) + args2.back()=args_tmp.back()-args_tmp.front(); + } + } if (function==at_ellipse) ; title_tmp=gen(args2,_SEQ__VECT); @@ -5748,6 +5797,10 @@ cb_set_mode(m,at_segment,at_inter,2,gettext("Curve1,Curve2")); } + static void cb_Tangent(Fl_Widget * m , void*) { + cb_set_mode(m,at_segment,at_tangent,2,gettext("Curve,Point")); + } + static void cb_Segment(Fl_Widget * m , void*) { cb_set_mode(m,0,at_point,1,gettext("Segment")); } @@ -5987,16 +6040,16 @@ {gettext("sphere"), 0, (Fl_Callback *) cb_sphere, 0, 0, 0, 0, 14, 56}, {0}, // end Surfaces {gettext("Measures"), 0, 0, 0, 64, 0, 0, 14, 56}, - {gettext("distance"), 0, (Fl_Callback *) cb_DistanceAB, 0, 0, 0, 0, 14, 56}, - {gettext("angle"), 0, (Fl_Callback *) cb_AngleABC, 0, 0, 0, 0, 14, 56}, - {gettext("area"), 0, (Fl_Callback *) cb_Area, 0, 0, 0, 0, 14, 56}, - {gettext("perimeter"), 0, (Fl_Callback *) cb_Perimeter, 0, 0, 0, 0, 14, 56}, - {gettext("slope"), 0, (Fl_Callback *) cb_Slope, 0, 0, 0, 0, 14, 56}, - {gettext("distance (raw)"), 0, (Fl_Callback *) cb_DistanceABraw, 0, 0, 0, 0, 14, 56}, - {gettext("angle (raw)"), 0, (Fl_Callback *) cb_AngleABCraw, 0, 0, 0, 0, 14, 56}, - {gettext("area (raw)"), 0, (Fl_Callback *) cb_Arearaw, 0, 0, 0, 0, 14, 56}, - {gettext("perimeter (raw)"), 0, (Fl_Callback *) cb_Perimeterraw, 0, 0, 0, 0, 14, 56}, - {gettext("slope (raw)"), 0, (Fl_Callback *) cb_Sloperaw, 0, 0, 0, 0, 14, 56}, + {gettext("distanceat"), 0, (Fl_Callback *) cb_DistanceAB, 0, 0, 0, 0, 14, 56}, + {gettext("angleat"), 0, (Fl_Callback *) cb_AngleABC, 0, 0, 0, 0, 14, 56}, + {gettext("areaat"), 0, (Fl_Callback *) cb_Area, 0, 0, 0, 0, 14, 56}, + {gettext("perimeterat"), 0, (Fl_Callback *) cb_Perimeter, 0, 0, 0, 0, 14, 56}, + {gettext("slopeat"), 0, (Fl_Callback *) cb_Slope, 0, 0, 0, 0, 14, 56}, + {gettext("distanceatraw"), 0, (Fl_Callback *) cb_DistanceABraw, 0, 0, 0, 0, 14, 56}, + {gettext("angleatraw"), 0, (Fl_Callback *) cb_AngleABCraw, 0, 0, 0, 0, 14, 56}, + {gettext("areaatraw"), 0, (Fl_Callback *) cb_Arearaw, 0, 0, 0, 0, 14, 56}, + {gettext("perimeteratraw"), 0, (Fl_Callback *) cb_Perimeterraw, 0, 0, 0, 0, 14, 56}, + {gettext("slopeatraw"), 0, (Fl_Callback *) cb_Sloperaw, 0, 0, 0, 0, 14, 56}, {0}, // end measures {gettext("Transformations"), 0, 0, 0, 64, 0, 0, 14, 56}, {gettext("reflection"), 0, (Fl_Callback *) cb_Symetrie, 0, 0, 0, 0, 14, 56}, @@ -6007,8 +6060,11 @@ {gettext("similarity"), 0, (Fl_Callback *) cb_Similitude, 0, 0, 0, 0, 14, 56}, {gettext("inversion"), 0, (Fl_Callback *) cb_Inversion, 0, 0, 0, 0, 14, 56}, {0}, // end transformations - {gettext("Intersection"), 0, (Fl_Callback *) cb_Inter_Unique, 0, 0, 0, 0, 14, 56}, - {gettext("Intersection list"), 0, (Fl_Callback *) cb_Inter, 0, 0, 0, 0, 14, 56}, + {gettext("Intersections"), 0, 0, 0, 64, 0, 0, 14, 56}, + {gettext("inter_unique (1 point)"), 0, (Fl_Callback *) cb_Inter_Unique, 0, 0, 0, 0, 14, 56}, + {gettext("inter (list of points)"), 0, (Fl_Callback *) cb_Inter, 0, 0, 0, 0, 14, 56}, + {0}, // end intersections + {gettext("tangent"), 0, (Fl_Callback *) cb_Tangent, 0, 0, 0, 0, 14, 56}, {gettext("Exact"), 0, (Fl_Callback *) cb_Exact, 0, 0, 0, 0, 14, 56}, {gettext("Approx"), 0, (Fl_Callback *) cb_Approx, 0, 0, 0, 0, 14, 56}, {0}, // end Menu Modified: trunk/giac-xcas/giac/src/plot.cc =================================================================== --- trunk/giac-xcas/giac/src/plot.cc 2010-03-12 10:30:24 UTC (rev 774) +++ trunk/giac-xcas/giac/src/plot.cc 2010-03-15 14:04:21 UTC (rev 775) @@ -2807,8 +2807,18 @@ gen f=eval(v[1],contextptr); if ((f.type==_SYMB) && (f._SYMBptr->sommet==at_pnt)){ gen g=remove_at_pnt(f); - g=get_point(g,0,contextptr); - diametre=gen(makevecteur(e,g),_GROUP__VECT); + if (g.type==_VECT && g._VECTptr->size()==2){ + // e=center, g=line, project e on g + gen g1=g._VECTptr->front(); + gen g2=g._VECTptr->back(); + gen t=projection(g1,g2,e,contextptr); + g=g1+t*(g2-g1); // this is the projection + diametre=gen(makevecteur(e+(e-g),g),_GROUP__VECT); + } + else { + g=get_point(g,0,contextptr); + diametre=gen(makevecteur(e,g),_GROUP__VECT); + } } else { while (f.type==_VECT){ @@ -4274,7 +4284,7 @@ t=projection(a,b,c,contextptr); gen pr=t*b+(1-t)*a; // projection of the center c gen d2=abs_norm2(pr-c,contextptr); - gen r2=r*r; + gen r2=r*conj(r,contextptr); if (is_strictly_greater(d2,r2,contextptr)) return pow(sqrt(d2,contextptr)-sqrt(r2,contextptr),2); return 0; @@ -4379,7 +4389,7 @@ else res += im(cote2,contextptr)*re(cote1,contextptr)-re(cote2,contextptr)*im(cote1,contextptr); } - return res/2; + return recursive_normal(res/2,contextptr); } const string _aire_s("area"); unary_function_eval __aire(&giac::_aire,_aire_s); @@ -7647,9 +7657,10 @@ } if (v[i].is_symb_of_sommet(at_equal)){ gen & f = v[i]._SYMBptr->feuille; - if (f.type==_VECT && f._VECTptr->size()==2 && f._VECTptr->back().type==_INT_){ - if (f._VECTptr->front()==at_couleur || f._VECTptr->front()==at_display){ - couleur |= f._VECTptr->back().val; + if (f.type==_VECT && f._VECTptr->size()==2){ + gen f2=evalf_double(f._VECTptr->back(),1,contextptr); + if ( f2.type==_DOUBLE_ && (f._VECTptr->front()==at_couleur || f._VECTptr->front()==at_display)){ + couleur |= int(f2._DOUBLE_val); continue; } } @@ -7750,11 +7761,8 @@ gen l=_aire(eval(v[0],eval_level(contextptr),contextptr),contextptr); int save_digits=decimal_digits(contextptr); decimal_digits(contextptr)=3; -#ifdef WIN32 string ss="a"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; -#else - string ss="◼"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; -#endif + // string ss="◼"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; decimal_digits(contextptr)=save_digits; l=gen('"'+ss+'"',false); vecteur w=makevecteur(v[1],l); @@ -7793,7 +7801,8 @@ gen l=_slope(eval(v[0],eval_level(contextptr),contextptr),contextptr); int save_digits=decimal_digits(contextptr); decimal_digits(contextptr)=3; - string ss="∡"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; + // string ss="∡"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; + string ss="s"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; decimal_digits(contextptr)=save_digits; l=gen('"'+ss+'"',false); vecteur w=makevecteur(v[1],l); @@ -7815,11 +7824,8 @@ gen l=_perimetre(eval(v[0],eval_level(contextptr),contextptr),contextptr); int save_digits=decimal_digits(contextptr); decimal_digits(contextptr)=3; -#ifdef WIN32 string ss="p"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; -#else - string ss="◻"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; -#endif + // string ss="◻"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; decimal_digits(contextptr)=save_digits; l=gen('"'+ss+'"',false); vecteur w=makevecteur(v[1],l); @@ -7883,7 +7889,8 @@ gen l=_angle(gen(makevecteur(eval(v[0],eval_level(contextptr),contextptr),eval(v[1],eval_level(contextptr),contextptr),eval(v[2],eval_level(contextptr),contextptr)),_SEQ__VECT),contextptr); int save_digits=decimal_digits(contextptr); decimal_digits(contextptr)=3; - string ss="∡"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; + string ss="α"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; + // string ss="∡"+v[0].print(contextptr)+"="+l.print(contextptr)+" "; decimal_digits(contextptr)=save_digits; l=gen('"'+ss+'"',false); vecteur w=makevecteur(v[3],l); @@ -11600,10 +11607,10 @@ unary_function_ptr notexprint_plot_sommets[]={at_funcplot,at_paramplot,at_polarplot,at_implicitplot,at_contourplot,at_odeplot,at_interactive_odeplot,at_fieldplot,at_seqplot,at_ellipse,at_hyperbole,at_parabole,0}; unary_function_ptr implicittex_plot_sommets[]={at_plot,at_plot3d,at_plotfunc,at_plotparam,at_plotpolar,at_plotimplicit,at_plotcontour,at_DrawInv,at_DrawFunc,at_DrawParm,at_DrawPol,at_DrwCtour,at_plotode,at_plotfield,at_interactive_plotode,at_plotseq,at_Graph,0}; unary_function_ptr point_sommet_tab_op[]={at_point,at_element,at_inter_unique,at_centre,at_isobarycentre,at_barycentre,0}; - unary_function_ptr nosplit_polygon_function[]={at_inter_unique,at_rotation,at_projection,at_symetrie,at_areaat,at_areaatraw,at_perimeterat,at_perimeteratraw,at_slopeat,at_slopeatraw,0}; + unary_function_ptr nosplit_polygon_function[]={at_inter_unique,at_inter,at_distanceatraw,at_distanceat,at_rotation,at_projection,at_symetrie,at_areaat,at_areaatraw,at_perimeterat,at_perimeteratraw,at_slopeat,at_slopeatraw,at_tangent,at_cercle,0}; unary_function_ptr measure_functions[]={at_angleat,at_angleatraw,at_areaat,at_areaatraw,at_perimeterat,at_perimeteratraw,at_slopeat,at_slopeatraw,at_distanceat,at_distanceatraw,0}; + unary_function_ptr transformation_functions[]={at_projection,at_rotation,at_translation,at_homothetie,at_similitude,at_inversion,at_symetrie,0}; - #ifndef NO_NAMESPACE_GIAC } // namespace giac #endif // ndef NO_NAMESPACE_GIAC Modified: trunk/giac-xcas/giac/src/plot.h =================================================================== --- trunk/giac-xcas/giac/src/plot.h 2010-03-12 10:30:24 UTC (rev 774) +++ trunk/giac-xcas/giac/src/plot.h 2010-03-15 14:04:21 UTC (rev 775) @@ -761,6 +761,7 @@ extern unary_function_ptr point_sommet_tab_op[]; extern unary_function_ptr nosplit_polygon_function[]; extern unary_function_ptr measure_functions[]; + extern unary_function_ptr transformation_functions[]; /* following obsolete declaration that will be remove in the future when all fork/child etc. will be removed */ extern vecteur plot_instructions; Modified: trunk/giac-xcas/giac/src/subst.cc =================================================================== --- trunk/giac-xcas/giac/src/subst.cc 2010-03-12 10:30:24 UTC (rev 774) +++ trunk/giac-xcas/giac/src/subst.cc 2010-03-15 14:04:21 UTC (rev 775) @@ -792,7 +792,7 @@ } // tan(x+pi/2)=-1/tan(x) gen shift_tan(const gen & x,GIAC_CONTEXT){ - return plus_one/symb_tan(ratnormal(x+cst_pi_over_2)); + return minus_one/symb_tan(ratnormal(x+cst_pi_over_2)); } gen shift_phase(const gen & e,GIAC_CONTEXT){ vector< gen_op_context > shift_phase_v; Modified: trunk/giac-xcas/giac/src/threaded.cc =================================================================== --- trunk/giac-xcas/giac/src/threaded.cc 2010-03-12 10:30:24 UTC (rev 774) +++ trunk/giac-xcas/giac/src/threaded.cc 2010-03-15 14:04:21 UTC (rev 775) @@ -144,9 +144,11 @@ if (g.type==_VECT && g._VECTptr->size()==2){ context * cptr=(giac::context *)newcontextptr; if (cptr){ +#ifdef HAVE_LIBPTHREAD pthread_mutex_lock(cptr->globalptr->_mutex_eval_status_ptr); sto(g._VECTptr->back(),g._VECTptr->front(),cptr); pthread_mutex_unlock(cptr->globalptr->_mutex_eval_status_ptr); +#endif } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |