Beispiel #1
0
void nemo_main()
{
    int i, nrad, n;
    int mode = getiparam("mode");

    if (mode==1) {
      dubinski();
      return;
    }

    sign_L = getdparam("sign");

    nrad = nemoinpi(getparam("nbody"),nbody,MAXRAD);
    n = nemoinpd(getparam("radius"),radius,MAXRAD);
    if (n!=nrad) error("radius=");
    n = nemoinpd(getparam("mass"),mass,MAXRAD);
    if (n!=nrad) error("mass=");
    n = nemoinpd(getparam("phi"),phi,MAXRAD);
    if (n!=nrad) error("phi=");

    nobj_max = nbody[0];
    for (i=1; i<nrad; i++)
      if (nbody[i] > nobj_max) nobj_max = nbody[i];

    pmass = (real *) allocate(sizeof(real)*nobj_max);
    pphase = allocate_mdarray3(nobj_max,2,NDIM);
    headline = getparam("headline");

    for (i=0; i<nrad; i++) {
      makering(nbody[i],mass[i],radius[i],phi[i]);
      writesnap(nbody[i]);
    }
    strclose(outstr);
    nemo_dprintf(1,"Total number of particles written: %d\n",ntot);
}
Beispiel #2
0
/*
 * map() maps a M2 x M1 source image fsource[i][j] onto an N2 x N1 target
 * image ftarget[i][j] with the mapping
 *		ftarget(r) += fsource(r + d)
 * where the deflection d = (di, dj) is supplied by function deflection()
 *
 * we use the slightly confusing notation (i,j) -> (y, x)
 */
void map(float **ftarget, int N1, int N2, float **fsource, int M1, int M2,
         int (*deflection)(float ri, float rj, float *di, float *dj))
{
  int   i, j, index, goodtriangle;
  float di, dj;
  vert *point[3], *basevert;

  /* set source image globals */
  gfsource = fsource;
  gftarget = ftarget;
  gM1      = M1;
  gM2      = M2;

  for (i = 0; i < N2; i++) {
    gtargeti = i;
    for (j = 0; j < N1; j++) {
      gtargetj = j;
      gfsum    = gareasum = 0.0;
      /* do the upper triangle */
      point[0]     = makevertex(j, i + 1);
      point[1]     = makevertex(j + 1, i + 1);
      point[2]     = makevertex(j + 1, i);
      goodtriangle = 1;
      for (index = 0; index < 3; index++) {
        goodtriangle    *= deflection(point[index]->y, 
                                      point[index]->x, &di, &dj);
        point[index]->y += di;
        point[index]->x += dj;
      }
      if (goodtriangle) {
        makering(&basevert, point, 3);
        if (globalmapmode == INVERSEMAPMODE) {
          garea = trianglearea(basevert);
        }
        decompose(basevert);
      }
      /* do the lower triangle */
      point[0]     = makevertex(j, i + 1);
      point[1]     = makevertex(j, i);
      point[2]     = makevertex(j + 1, i);
      goodtriangle = 1;
      for (index = 0; index < 3; index++) {
        goodtriangle    *= deflection(point[index]->y, 
                                      point[index]->x, &di, &dj);
        point[index]->y += di;
        point[index]->x += dj;
      }
      if (goodtriangle) {
        makering(&basevert, point, 3);
        if (globalmapmode == INVERSEMAPMODE) {
          garea = trianglearea(basevert);
        }
        decompose(basevert);
      }
      /* now add the pixel value */
      if ((gareasum > 0.0) && (globalmapmode == FORWARDMAPMODE)) {
        ftarget[i][j] = gfsum / gareasum;
      }
      freeverts();
    }
  }
}