Exemple #1
0
 private void updateImage() {
   fill(_vnull, _v);
   for (int is = 0; is < _ns; ++is) {
     float[] x1 = _x1[is];
     float[] x2 = _x2[is];
     float[] vx = _vx[is];
     int np = _x1[is].length;
     if (np == 1) {
       _is2.set(x1[0], x2[0], vx[0]);
     } else if (np > 1) {
       for (int ip = 1; ip < np; ++ip) {
         float x1a = x1[ip - 1];
         float x2a = x2[ip - 1];
         float vxa = vx[ip - 1];
         float x1b = x1[ip];
         float x2b = x2[ip];
         float vxb = vx[ip];
         ImageSampler2.Line line = _is2.sampleLine(x1a, x2a, x1b, x2b);
         int nr = line.nr();
         float ra = line.ra();
         float rb = line.rb();
         float dvx = (nr > 1) ? (vxb - vxa) / (float) (nr - 1) : vxa;
         for (int ir = 0; ir < nr; ++ir) {
           float vxi = vxa + (float) ir * dvx;
           line.set(ir, vxi);
         }
       }
     }
   }
 }
Exemple #2
0
 private void insertPoint(int is, int ip, int x, int y) {
   Check.argument(is <= _ns, "is in bounds");
   Check.argument(is == _ns && ip == 0 || is < _ns && ip <= _x1[is].length, "is in bounds");
   if (is == _ns) {
     int ns = is + 1;
     float[][] x1 = new float[ns][0];
     float[][] x2 = new float[ns][0];
     float[][] vx = new float[ns][0];
     for (int js = 0; js < _ns; ++js) {
       x1[js] = _x1[js];
       x2[js] = _x2[js];
       vx[js] = _vx[js];
     }
     _x1 = x1;
     _x2 = x2;
     _vx = vx;
     _ns = ns;
   }
   int np = _x1[is].length;
   float[] x1p = _x1[is];
   float[] x2p = _x2[is];
   float[] vxp = _vx[is];
   float[] x1t = new float[np + 1];
   float[] x2t = new float[np + 1];
   float[] vxt = new float[np + 1];
   for (int jp = 0; jp < ip; ++jp) {
     x1t[jp] = x1p[jp];
     x2t[jp] = x2p[jp];
     vxt[jp] = vxp[jp];
   }
   x1t[ip] = x1(x, y);
   x2t[ip] = x2(x, y);
   vxt[ip] = _is2.get(x1t[ip], x2t[ip]);
   for (int jp = ip; jp < np; ++jp) {
     x1t[jp + 1] = x1p[jp];
     x2t[jp + 1] = x2p[jp];
     vxt[jp + 1] = vxp[jp];
   }
   _x1[is] = x1t;
   _x2[is] = x2t;
   _vx[is] = vxt;
 }