[BACK]Return to calc.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / plot

Diff for /OpenXM_contrib2/asir2000/plot/calc.c between version 1.5 and 1.6

version 1.5, 2001/10/09 01:36:27 version 1.6, 2002/08/02 08:59:47
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2000/plot/calc.c,v 1.4 2001/08/22 09:19:21 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/plot/calc.c,v 1.5 2001/10/09 01:36:27 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 55 
Line 55 
 #include "genpari.h"  #include "genpari.h"
 #endif  #endif
   
   #ifndef MAXSHORT
   #define MAXSHORT ((short)0x7fff)
   #endif
   
 void calc(double **tab,struct canvas *can,int nox)  void calc(double **tab,struct canvas *can,int nox)
 {  {
         double x,y,xmin,ymin,xstep,ystep;          double x,y,xmin,ymin,xstep,ystep;
Line 330  void plotcalc(struct canvas *can)
Line 334  void plotcalc(struct canvas *can)
         can->pa[0].length = w;          can->pa[0].length = w;
         can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT));          can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT));
         for ( ix = 0; ix < w; ix++ ) {          for ( ix = 0; ix < w; ix++ ) {
 #ifndef MAXSHORT  
 #define MAXSHORT ((short)0x7fff)  
 #endif  
                 double t;                  double t;
   
                 XC(pa[ix]) = ix;                  XC(pa[ix]) = ix;
Line 343  void plotcalc(struct canvas *can)
Line 344  void plotcalc(struct canvas *can)
                         YC(pa[ix]) = -MAXSHORT;                          YC(pa[ix]) = -MAXSHORT;
                 else                  else
                         YC(pa[ix]) = (long)t;                          YC(pa[ix]) = (long)t;
           }
   }
   
   void polarplotcalc(struct canvas *can)
   {
           double xmax,xmin,ymax,ymin,dx,dy,pmin,pstep;
           int i,nstep;
           double usubstrp();
           int w,h;
           double tr,p;
           double *tabx,*taby;
           POINT *pa;
           Real r;
           Obj fr,t,s;
   
           MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr);
           w = can->width; h = can->height; nstep = can->nzstep;
           pmin = can->zmin; pstep = (can->zmax-can->zmin)/nstep;
           tabx = (double *)ALLOCA(nstep*sizeof(double));
           taby = (double *)ALLOCA(nstep*sizeof(double));
           MKReal(1,r); /* dummy real number */
           for( i = 0, p = pmin; i < nstep ; i++, p += pstep ) {
                   /* full substitution */
                   BDY(r) = p;
                   substr(CO,0,fr,can->vx,p?(Obj)r:0,&s);
                   devalr(CO,(Obj)s,&t);
                   if ( t && (OID(t)!=O_N || NID((Num)t)!=N_R) )
                           error("polarplotcalc : invalid evaluation");
                   tr = ToReal((Num)t);
                   tabx[i] = tr*cos(p);
                   taby[i] = tr*sin(p);
           }
           xmax = xmin = tabx[0];
           ymax = ymin = taby[0];
           for ( i = 1; i < nstep; i++ ) {
                   if ( tabx[i] > xmax ) xmax = tabx[i];
                   if ( tabx[i] < xmin ) xmin = tabx[i];
                   if ( taby[i] > ymax ) ymax = taby[i];
                   if ( taby[i] < ymin ) ymin = taby[i];
           }
           can->xmax = xmax; can->xmin = xmin;
           can->ymax = ymax; can->ymin = ymin;
           dx = xmax-xmin;
           dy = ymax-ymin;
           can->pa = (struct pa *)MALLOC(sizeof(struct pa));
           can->pa[0].length = nstep;
           can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT));
           for ( i = 0; i < nstep; i++ ) {
                   XC(pa[i]) = (w-1)*(tabx[i]-xmin)/dx;
                   YC(pa[i]) = (h-1)*(ymax-taby[i])/dy;
         }          }
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>