Example #1
0
void XGraphicsOpenGL::FillRect( float x, float y, float w, float h, XCOLOR collt, XCOLOR colrt, XCOLOR collb, XCOLOR colrb  )
{
	if( w == 0 || h == 0 )	return;
    if( w < 0 )
    {
        x -= w;     // 좌측 좌표를 -w만큼 이동시켜주고
        w = -w;     // w는 부호 바꿈
    }
    if( h < 0 )
    {
        y -= h;
        h = -h;
    }
	if( x > GetScreenWidth() || y > GetScreenHeight() )	// w, h가 마이너스가 올수도 있기땜에 이렇게 함
		return;
	if( x + w < 0 || y + h < 0 )
		return;
	
	//	if( x > GetScreenWidth() || y > GetScreenHeight() )
	//		return;
	//	if( w < 0 || h < 0 )
	//		return;
	
	
//	GLfloat r, g, b, a;
//	r = XCOLOR_RGB_R(color) / 255.0f;
//	g = XCOLOR_RGB_G(color) / 255.0f;
//	b = XCOLOR_RGB_B(color) / 255.0f;
//	a = XCOLOR_RGB_A(color) / 255.0f;
	//	if( a != 255 )	glEnable(GL_BLEND);		// 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자.
	
	// width-1이 맞나? 안하는게 맞나?
	GLfloat pos[8] = { 0, h, w, h, 0, 0, w, 0 };
	GLfloat col[16] = {  _R(collb), _G(collb),_B(collb),_A(collb),	// 좌하
						_R(colrb), _G(colrb),_B(colrb),_A(colrb),	// 우하
						_R(collt), _G(collt),_B(collt),_A(collt),	// 좌상
						_R(colrt), _G(colrt),_B(colrt),_A(colrt)	};	// 우상
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(x, y, 0);
	glScalef(1.0f, 1.0f, 1.0f);
	//    glLoadIdentity();
	
	glDisable( GL_TEXTURE_2D );
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);	// 이건 안해줘도 되네.
	glVertexPointer(2, GL_FLOAT, 0, pos);
	glEnableClientState(GL_VERTEX_ARRAY);
	glColorPointer(4, GL_FLOAT, 0, col);
	glEnableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	
	glDisableClientState(GL_COLOR_ARRAY);
	glEnable( GL_TEXTURE_2D );
	glPopMatrix();
	//	if( a != 255 )	glDisable(GL_BLEND);
	
}
Example #2
0
double _jres ( void *arg, double dtilde ) {
  double jres, Pdmin, Vmin, P, jtilde, mui, jmin;
  double gamma, Nn, Ti, j, Estar, Etilde;
  long plasmatype;
  gamma = ( ( arg_t * ) arg )->gamma;
  Nn = ( ( arg_t * ) arg )->Nn;
  Ti = ( ( arg_t * ) arg )->Ti;
  j = ( ( arg_t * ) arg )->j;
  plasmatype = ( ( arg_t * ) arg )->plasmatype;
  P = Nn * Ti * kB / 133.0;     /* Torr */
  Pdmin = ebar / _A ( plasmatype ) * ( 1.0 / gamma + 1.0 );     /* Torr cm */
  Vmin = ebar * _B ( plasmatype ) / _A ( plasmatype ) * log ( 1.0 / gamma + 1.0 );      /* Vstar */

  jtilde = 1.0 / dtilde / sqr ( 1.0 + log ( dtilde ) );

  Etilde = 1.0 / ( 1.0 + log ( dtilde ) );
  Estar = Etilde * _B ( plasmatype ) * P * 100.0 / Nn;

  mui = _mui ( plasmatype, Nn, Ti, Estar ) * 1e4;       /* cm2 / Vstar s */
  jmin = sqr ( P ) * ( 1.0 + gamma ) / 9e11 * mui * P * sqr ( Vmin ) / 4.0 / pi / Pdmin / Pdmin / Pdmin;

  jres = j - jtilde * jmin * 1e4;
//  printf("dtilde=%E gamma=%E Nn=%E Ti=%E  jres=%E\n",dtilde,gamma,Nn,Ti,jres);

  return ( jres );
}
LipmConstHeightPlanner::LipmConstHeightPlanner(double z, double dt)
: _height(z)
, _dt(dt)
, _lqr(LqrController<2,1>())
{
  _Q.setIdentity();
  _R.setIdentity();
  _Q *= 1e-6;

  _A(0,0) = 1;
  _A(0,1) = _dt;
  _A(1,0) = _dt*GRAVITY/_height;
  _A(1,1) = 1;

  _B(0,0) = 0;
  _B(1,0) = -_dt*GRAVITY/_height;

  _lqr.setQ(_Q);
  _lqr.setR(_R);
  _lqr.infTimeLQR(_A, _B);

  _K = _lqr.getK();
  _Quu_inv = (_B.transpose()*_lqr.getV()*_B + _R).inverse();
  
#if 0
  std::cout << "A" << std::endl << _A << std::endl
            << "B" << std::endl << _B << std::endl
            << "K" << std::endl << _K << std::endl
            << "Quu_inv" << std::endl << _Quu_inv << std::endl;
#endif
}
Example #4
0
linAccModel::linAccModel() {
    valid = true;
    type = "constAcceleration";

    printf("linAccModel::init:start \n");
    rowA = 2;
    colA = 2;
    Matrix _A(2,2);
    Matrix _B(2,1);
    Matrix _H(2,2);
    A = _A;
    B = _B;
    H = _H;
    A.zero();
    B.zero();
    H.zero();    
    
    //discratisation with sampling rate 0.01
    A(0,0) = 1; A(0,1) = 0.01;
    A(1,1) = 1;
    B(0,1) = 5e-05;
    B(1,0) = 0.01;
    H(1,1) = 1;
    
    printf("linAccModel::init:stop \n");

}
Example #5
0
void minJerkModel::init(double _paramA, double _paramB) {
    paramA = _paramA;
    paramB = _paramB;

    T = _paramB;
    u = _paramA;

    double T2 = T * T;
    double T3 = T2 * T;

    a = -150.765868956161/T3;
    b = -84.9812819469538/T2;
    c = -15.9669610709384/T;
    
    rowA = 3;
    colA = 3;
    Matrix _A(3,3);
    Matrix _B(3,1);
    Matrix _H(3,3);
    A = _A;
    B = _B;
    H = _H;
    A.zero();
    B.zero();
    H.zero();
    
    //discretisation with sampling rate 0.01;
    if(T==1) {          
        A(0,0) = 1.0000000; A(0,1) = 0.009986; A(0,2) = 4.741e-05;
        A(1,0) = -0.007148; A(1,1) = 0.995900; A(1,2) = 0.0092290;                 
        A(2,0) = -1.391000; A(2,1) = -0.79150; A(2,2) = 0.8486000;
        B(0,0) = 2.415e-05;
        B(1,0) = 0.0071480;
        B(2,0) = 1.391;     
        
    }
    else if (T== 2){          
        A(0,0) = 1.000000000; A(0,1) = 0.009997; A(0,2) =  4.869e-05;
        A(1,0) =  -0.0009175; A(1,1) = 0.999000; A(1,2) =   0.009608;
        A(2,0) = -0.18110000; A(2,1) = -0.20500; A(2,2) =     0.9223;       
        B(0,0) = 3.079e-06;
        B(1,0) = 0.0009175;
        B(2,0) = 0.1811;
       
    }
    else {
        // unknown T
        // A is 0
        // B is 0
    }
    
    H(0,0) = 1;
    H(1,1) = 1;
    H(2,2) = 1;

}
void BlockLocalPositionEstimator::initSS()
{
	initP();

	// dynamics matrix
	_A.setZero();
	// derivative of position is velocity
	_A(X_x, X_vx) = 1;
	_A(X_y, X_vy) = 1;
	_A(X_z, X_vz) = 1;

	// input matrix
	_B.setZero();
	_B(X_vx, U_ax) = 1;
	_B(X_vy, U_ay) = 1;
	_B(X_vz, U_az) = 1;

	// update components that depend on current state
	updateSSStates();
	updateSSParams();
}
Example #7
0
void genPredModel::init(double paramA, double paramB) {
    rowA = 3;
    colA = 3;
    Matrix _A(3,3);
    Matrix _B(3,3);
    Matrix _H(3,3);
    A = _A;
    B = _B;   
    H = _H;
    A.zero();
    B.zero();
    H.zero();
}
Example #8
0
LipmConstHeightPlanner::LipmConstHeightPlanner(double z, double dt)
  : _height(z)
  , _dt(dt)
  , _lqr(LqrController<2,1>())
{
  _Q.setIdentity();
  _R.setIdentity();
  _Q *= 1e-6;

  _A(0,0) = 1;
  _A(0,1) = _dt;
  _A(1,0) = _dt*GRAVITY/_height;
  _A(1,1) = 1;

  _B(0,0) = 0;
  _B(1,0) = -_dt*GRAVITY/_height;

  _lqr.setQ(_Q);
  _lqr.setR(_R);
  _lqr.infTimeLQR(_A, _B);

  _K = _lqr.getK();
  _Quu_inv = (_B.transpose()*_lqr.getV()*_B + _R).inverse();
}
Example #9
0
linVelModel::linVelModel() {
    valid = true;
    type = "constVelocity";
    rowA = 2;
    colA = 2;
    printf("initialisation matrix A,B,H with main dimension %d \n", rowA, colA);
    Matrix _A(2,2);
    Matrix _B(2,1);
    Matrix _H(2,2);
    A = _A;
    B = _B;
    H = _H;   
    A.zero();
    B.zero();
    H.zero();    
       
    A(0,0) = 1; 
    A(1,1) = 1;
    B(0,0) = 0.01;   
    H(1,1) = 1;
}
Example #10
0
	bool isWhitePixel(int i, int j, char * image, int threshold)
	        {
			/*unsigned int b = image[_B(i, j)];
			unsigned int g = image[_G(i, j)];
			unsigned int r = image[_R(i, j)];*/
					unsigned char b = image[_B(i, j)];
					unsigned char g = image[_G(i, j)];
					unsigned char r = image[_R(i, j)];
					unsigned int r_ = r;
					unsigned int g_ = g;
					unsigned int b_ = b;

	            //return ((image[_B(i, j)] > threshold) &&
	            //            (image[_G(i, j)] > threshold) &&
	            //            (image[_R(i, j)] > threshold));
			return ( (b > threshold) &&
				                        (g > threshold) &&
				                        (r > threshold) );
			//return ( (*(image + _B(i, j)) > threshold) &&
			//                        (*(image + _G(i, j)) > threshold) &&
			//                        (*(image + _R(i, j)) > threshold) );
	        }
Example #11
0
void CAMCode<B,T,D>::AdvMom ()
{
  CalcE (_B, _Ua, _dnf);

  T ni, dth = T(.5) * _time.Dt ();
  FldVector ui, uf, bi, ei;

  DomainIterator<D> itu, itb, ite;
  _dn.GetDomainIterator (itu, false);
  _B.GetDomainIterator (itb, false);
  _E.GetDomainIteratorAll (ite, true);

  do
  {
    ni = _dn(itu);
    ui = _U (itu);
    uf = _Uf(itu);
    bi = _B (itb);
    CartStencil::Average (_E, ite, ei);

    _U(itu) = uf + dth * (ni*ei + ui % bi);
  }
  while (itu.Next() && itb.Next() && ite.Next());
}
Example #12
0
void main(){
	CBrain myBrain(5, 64, 1, 2, 64);

	vector<v_double> trainingset[5];
	vector<v_double> outputset[5];

	vector<double> tset;

	MyImage A("./trainingset/A.txt");
	MyImage B("./trainingset/B.txt");
	MyImage C("./trainingset/C.txt");
	MyImage D("./trainingset/D.txt");
	MyImage E("./trainingset/E.txt");

	MyImage _A("./trainingset/_A.txt");
	MyImage _B("./trainingset/_B.txt");
	MyImage _C("./trainingset/_C.txt");
	MyImage _D("./trainingset/_D.txt");
	MyImage _E("./trainingset/_E.txt");

	trainingset[0].push_back(A.Image);
	outputset[0].push_back(A.Result);
	trainingset[1].push_back(B.Image);
	outputset[1].push_back(B.Result);
	trainingset[2].push_back(C.Image);
	outputset[2].push_back(C.Result);
	trainingset[3].push_back(D.Image);
	outputset[3].push_back(D.Result);
	trainingset[4].push_back(E.Image);
	outputset[4].push_back(E.Result);

	trainingset[0].push_back(_A.Image);
	outputset[0].push_back(_A.Result);
	trainingset[1].push_back(_B.Image);
	outputset[1].push_back(_B.Result);
	trainingset[2].push_back(_C.Image);
	outputset[2].push_back(_C.Result);
	trainingset[3].push_back(_D.Image);
	outputset[3].push_back(_D.Result);
	trainingset[4].push_back(_E.Image);
	outputset[4].push_back(_E.Result);

	for(int i=0; i<5; i++){
		myBrain.train(i, trainingset[i], outputset[i]);
	}
	
	for(int i=0; i<5; i++){
		printf("%d: ",i); 
		printf("%d\n", myBrain.update(trainingset[i].at(0)));
	}

	myBrain.Save();

	while(1){
		char str[100];

		memset(str, 0, sizeof(str));
		printf("input file name:");
		scanf("%s", str);
		MyImage MyImg(str);

		vector<v_double> input;
		input.push_back(MyImg.Image);

		int out= myBrain.update(input.at(0));

		switch(out){
		case 0:
			printf("A\n");
			break;
		case 1:
			printf("B\n");
			break;
		case 2:
			printf("C\n");
			break;
		case 3:
			printf("D\n");
			break;
		case 4:
			printf("E\n");
			break;
		}

	}

	return;
}
Example #13
0
// Apply 3d cross numerical pattern
// to the given data field (regular CPU version).
int cross3d(
	int nx, int ny, int nz,
	int bx, int by, int bs,
	int ex, int ey, int es,
	dtype* prev, dtype* curr /** OUT **/ )
{
	int np = nx * ny;

	for (int iz = bs; iz < nz - es; iz++)
		for (int iy = by; iy < ny - ey; iy++)
			for (int ix = bx; ix < nx - ex; ix++)
			{
				dtype val = *_C(prev), *ptr;
				
				// Account pattern left extent values.
				ptr = _C(prev);
				for (int i = 0; i < bx; i++)
				{
					ptr = _L(ptr);
					val += *ptr;
				}
				
				// Account pattern right extent values.
				ptr = _C(prev);
				for (int i = 0; i < ex; i++)
				{
					ptr = _R(ptr);
					val += *ptr;
				}

				// Account pattern lower extent values.
				ptr = _C(prev);
				for (int i = 0; i < by; i++)
				{
					ptr = _D(ptr);
					val += *ptr;
				}
				
				// Account pattern upper extent values.
				ptr = _C(prev);
				for (int i = 0; i < ey; i++)
				{
					ptr = _U(ptr);
					val += *ptr;
				}

				// Account pattern back extent values.
				ptr = _C(prev);
				for (int i = 0; i < bs; i++)
				{
					ptr = _B(ptr);
					val += *ptr;
				}
				
				// Account pattern front extent values.
				ptr = _C(prev);
				for (int i = 0; i < es; i++)
				{
					ptr = _F(ptr);
					val += *ptr;
				}	
				
				*_C(curr) = val;
			}

	return 0;
}
Example #14
0
 //Java debug channel approach
 inline void DbgOut(LPCTSTR lpStr) { DTRACE_PRINT(_B(lpStr)); }
Example #15
0
void C_THISCLASS::smp_render(int this_thread, int max_threads, char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
{
  if (!enabled) return;

	unsigned int *f = (unsigned int *) framebuffer;
  unsigned int *of = (unsigned int *) fbout;
  unsigned int *lfo = (unsigned int *) lastframe;


  int start_l = ( this_thread * h ) / max_threads;
  int end_l;

  if (this_thread >= max_threads - 1) end_l = h;
  else end_l = ( (this_thread+1) * h ) / max_threads;  

  int outh=end_l-start_l;
  if (outh<1) return;

  int skip_pix=start_l*w;

  f += skip_pix;
  of+= skip_pix;
  lfo += skip_pix;

  int at_top=0, at_bottom=0;

  if (!this_thread) at_top=1;
  if (this_thread >= max_threads - 1) at_bottom=1;


  timingEnter(0);

  {

    if (at_top)
    // top line
    {
      int x;
    
      // left edge
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // middle of line
      x=(w-2);
	    while (x--)
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r/=2; g/=2; b/=2;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // right block
	    {
        int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }
	  }


	  // middle block
    {
      int y=outh-at_top-at_bottom;
      while (y--)
      {
        int x;
      
        // left edge
	      {
          int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }

        // middle of line
        x=(w-2);
#ifdef NO_MMX
	      while (x--)
	      {
          int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
          r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }
#else
        __asm
        {
          mov esi, f
          mov edi, of
          mov edx, lfo
          mov ecx, x
          mov ebx, w
          shl ebx, 2
          shr ecx, 1
          sub esi, ebx
          align 16
mmx_water_loop1:
          movd mm0, [esi+ebx+4]

          movd mm1, [esi+ebx-4]
          punpcklbw mm0, [zero]

          movd mm2, [esi+ebx*2]
          punpcklbw mm1, [zero]

          movd mm3, [esi]
          punpcklbw mm2, [zero]

          movd mm4, [edx]
          paddw mm0, mm1

          punpcklbw mm3, [zero]
          movd mm7, [esi+ebx+8]

          punpcklbw mm4, [zero]
          paddw mm2, mm3

          movd mm6, [esi+ebx]
          paddw mm0, mm2

          psrlw mm0, 1
          punpcklbw mm7, [zero]

          movd mm2, [esi+ebx*2+4]
          psubw mm0, mm4

          movd mm3, [esi+4]
          packuswb mm0, mm0

          movd [edi], mm0
          punpcklbw mm6, [zero]

          movd mm4, [edx+4]
          punpcklbw mm2, [zero]

          paddw mm7, mm6
          punpcklbw mm3, [zero]

          punpcklbw mm4, [zero]
          paddw mm2, mm3
          
          paddw mm7, mm2
          add edx, 8

          psrlw mm7, 1
          add esi, 8

          psubw mm7, mm4

          packuswb mm7, mm7

          movd [edi+4], mm7

          add edi, 8

          dec ecx
          jnz mmx_water_loop1

          add esi, ebx
          mov f, esi
          mov of, edi
          mov lfo, edx
        };
#endif
        // right block
	      {
          int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }
	    }
    }
    // bottom line
    if (at_bottom)
    {
      int x;
    
      // left edge
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // middle of line
      x=(w-2);
	    while (x--)
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r/=2; g/=2; b/=2;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // right block
	    {
        int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }
	  }
  }

  memcpy(lastframe+skip_pix,framebuffer+skip_pix,w*outh*sizeof(int));
  
#ifndef NO_MMX
    __asm emms;
#endif
	timingLeave(0);
}

C_RBASE *R_Water(char *desc)
{
	if (desc) { strcpy(desc,MOD_NAME); return NULL; }
	return (C_RBASE *) new C_THISCLASS();
}


static C_THISCLASS *g_this;

static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
      if (g_this->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
			return 1;
    case WM_COMMAND:
      if (LOWORD(wParam) == IDC_CHECK1)
      {
        if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1))
          g_this->enabled=1;
        else
          g_this->enabled=0;
      }
    return 0;
	}
	return 0;
}


HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
{
	g_this = this;
	return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_WATER),hwndParent,g_DlgProc);
}
Example #16
0
int main ( int argc, char **argv ) {
  double j, jtilde, gamma, Pdmin, EoverPmin, Vmin, dtilde, d, P, Vtilde, Etilde, Ti, Nn;
  bool Ti_flag, gamma_flag, P_flag, j_flag;
  long plasmatype;
  char *strtmp;

  Ti = 300;                     /* K */
  P = 101300;                   /* Pa */
  j = 0.5;                      /* A/m2 */
  gamma = 0.1;
  strtmp = ( char * ) malloc ( 0 );
  /* take care of the command line options */
  Ti_flag = FALSE;
  gamma_flag = FALSE;
  P_flag = FALSE;
  j_flag = FALSE;

  if ( chkarg ( argc, argv, "-Ti" ) != 0 ) {
    Ti_flag = TRUE;
    sscanf ( argv[chkarg ( argc, argv, "-Ti" ) + 1], "%lg", &Ti );
  }

  if ( chkarg ( argc, argv, "-P" ) != 0 ) {
    P_flag = TRUE;
    sscanf ( argv[chkarg ( argc, argv, "-P" ) + 1], "%lg", &P );
  }

  if ( chkarg ( argc, argv, "-j" ) != 0 ) {
    j_flag = TRUE;
    sscanf ( argv[chkarg ( argc, argv, "-j" ) + 1], "%lg", &j );
  }

  if ( chkarg ( argc, argv, "-g" ) != 0 ) {
    gamma_flag = TRUE;
    sscanf ( argv[chkarg ( argc, argv, "-g" ) + 1], "%lg", &gamma );
  }

  plasmatype = -1;
  if ( chkarg ( argc, argv, "-type" ) != 0 ) {

    strtmp = ( char * ) realloc ( strtmp,
                                  ( 2 +
                                    ( long ) strlen ( argv[chkarg ( argc, argv, "-type" ) + 1] ) ) *
                                  sizeof ( char ) );
    strcpy ( strtmp, argv[chkarg ( argc, argv, "-type" ) + 1] );
    if ( strcmp ( strtmp, "AIR" ) == 0 )
      plasmatype = PLASMA_AIR;
    if ( strcmp ( strtmp, "N2" ) == 0 )
      plasmatype = PLASMA_N2;
    if ( strcmp ( strtmp, "N2lowE" ) == 0 )
      plasmatype = PLASMA_N2lowE;
    if ( plasmatype == -1 ) {
      printf ( "wrong plasma type :%s:\n", strtmp );
      exit ( EXIT_FAILURE );
    }
  }

  if ( !( Ti_flag && P_flag && j_flag && gamma_flag ) ) {
    fprintf ( stderr, "\nFlags:\n\n"
              "Flag   \tArg                                    \tArg Type \tRequired? \n"
              "----------------------------------------------------------------------------\n"
              "-g     \t<electron emission coefficient gamma>  \tdouble   \tY\n"
              "-Ti    \t<ion temperature [K]>                  \tdouble   \tY\n"
              "-P     \t<plasma pressure [Pa]>                 \tdouble   \tY\n"
              "-j     \t<current density [A/m2]>               \tdouble   \tY\n"
              "-type  \t<plasma type, AIR, N2, N2lowE>         \tstring   \tY\n" "\n" );

  } else {
    Nn = P / kB / Ti;
    d = _d ( plasmatype, Ti, Nn, gamma, j ) * 100.0;    /* cm */

    P = P / 133.0;              /* Torr */

    Pdmin = ebar / _A ( plasmatype ) * ( 1.0 / gamma + 1.0 );   /* Torr cm */
    EoverPmin = _B ( plasmatype );      /* Vstar / cm Torr */
    Vmin = ebar * _B ( plasmatype ) / _A ( plasmatype ) * log ( 1.0 / gamma + 1.0 );    /* Vstar */

    dtilde = P * d / Pdmin;
    Vtilde = dtilde / ( 1.0 + log ( dtilde ) );
    Etilde = 1.0 / ( 1.0 + log ( dtilde ) );
    jtilde = 1.0 / dtilde / sqr ( 1.0 + log ( dtilde ) );
    printf ( "\n" );
    printf ( "Type of Plasma: " );
    if ( plasmatype == PLASMA_N2 )
      printf ( "N2 (100<EoverP<600 Vstar/cmTorr)\n" );
    if ( plasmatype == PLASMA_N2lowE )
      printf ( "N2 (27<EoverP<200 Vstar/cmTorr)\n" );
    if ( plasmatype == PLASMA_AIR )
      printf ( "AIR (100<EoverP<800 Vstar/cmTorr)\n" );
    printf ( "Type of Discharge: " );
    if ( jtilde > 1.0 )
      printf ( "High Current Discharge\n" );
    else
      printf ( "Low Current Discharge\n" );
    printf ( "\n" );
    printf ( "mui (at the cathode):                  %E m2/Vs\n",
             _mui_min ( plasmatype, Nn, Ti, Etilde * EoverPmin * P * 100.0 / Nn ) );
    printf ( "mui (at the sheath edge):              %E m2/Vs\n",
             _mui_max ( plasmatype, Nn, Ti, Etilde * EoverPmin * P * 100.0 / Nn ) );
    printf ( "mui (geometric average):               %E m2/Vs\n",
             _mui ( plasmatype, Nn, Ti, Etilde * EoverPmin * P * 100.0 / Nn ) );
    printf ( "d:                                     %E m \n", d / 100.0 );
    printf ( "Pressure:                              %E torr\n", P );
    printf ( "Voltage drop in cathode sheath:        %E Vstar\n", Vtilde * Vmin );
    printf ( "Current in cathode sheath:             %E A/m2\n", j );
    printf ( "Electric field at the cathode:         %E Vstar/m\n", Etilde * EoverPmin * P * 100.0 );
    printf ( "Reduced Electric field at the cathode: %E Vm2\n", Etilde * EoverPmin * P * 100.0 / Nn );
    printf ( "E over P at the cathode:               %E Vstar/cmTorr\n", EoverPmin );
    printf ( "jtilde:                                %E \n", jtilde );

  }
  free ( strtmp );
  return ( EXIT_SUCCESS );
}
Example #17
0
// -----------------------------------------------------------------------
static void emdas_print_arg(struct emdas *emd, struct emdas_op *op, uint16_t *varg, struct emdas_dh_elem *ref, int as_data)
{
	// .word "argument"
	if (as_data || (op->id == EMD_OP_NONE)) {
		if (ref) {
			emdas_buf_app(emd->dbuf, "%s_%x", emdas_lab_types[ref->type], ref->addr);
		} else {
			emdas_buf_app(emd->dbuf, "0x%04x", op->v);
		}
		return;
	}

	// register argument
	if (op->flags & EMD_FL_ARG_REG) {
		if (op->flags & EMD_FL_ARG2) {
			// arguments continue
			emdas_buf_app(emd->dbuf, "r%i, ", _A(op->v));
		} else {
			// register is the only argument
			emdas_buf_app(emd->dbuf, "r%i", _A(op->v));
			return;
		}
	}

	// short 4-bit argument
	if (op->flags & EMD_FL_ARG_SHORT4) {
		emdas_buf_app(emd->dbuf, "%i", _t(op->v));

	// short 7-bit argument
	} else if (op->flags & EMD_FL_ARG_SHORT7) {
		if (ref) {
			emdas_buf_app(emd->dbuf, "%s_%x", emdas_lab_types[ref->type], ref->addr);
		} else {
			// unsigned (octal) for HLT
			if (op->id == EMD_OP_HLT) {
				emdas_buf_app(emd->dbuf, "0%02o", _Tuns(op->v));
			// signed for other
			} else {
				emdas_buf_app(emd->dbuf, "%s%i", _Tsign(op->v), _Tabs(op->v));
			}
		}

	// short 8-bit argument
	} else if (op->flags & EMD_FL_ARG_SHORT8) {
		uint16_t arg = _b(op->v);
		// BRC and BLC args always refer to CPU flags
		if (op->flags & EMD_FL_ARG_FLAGS) {
			// correction for BLC argument
			if (op->id == EMD_OP_BLC) arg <<= 8;
			emdas_print_flags(emd->dbuf, arg);
		} else {
			emdas_buf_app(emd->dbuf, "%d", arg);
		}

	// normal argument
	} else if (op->flags & EMD_FL_ARG_NORM) {
		if (op->flags & EMD_FL_MOD_D) emdas_buf_c(emd->dbuf, '[');

		// 2nd arg
		if (op->flags & EMD_FL_2WORD) {
			// no memory or split arg
			if (!varg) {
				emdas_buf_app(emd->dbuf, "%s", "r0");
			// named argument
			} else if (ref) {
				emdas_buf_app(emd->dbuf, "%s_%x", emdas_lab_types[ref->type], ref->addr);
			// arg refers to CPU flags
			} else if ((op->flags & EMD_FL_ARG_FLAGS) && !(op->flags & EMD_FL_MOD_D)) {
				emdas_print_flags(emd->dbuf, *varg);
			// print small integers as decimal
			} else if (*varg < 16) {
				emdas_buf_app(emd->dbuf, "%i", *varg);
			// hex constant
			} else {
				emdas_buf_app(emd->dbuf, "0x%04x", *varg);
			}

		// rC
		} else {
			emdas_buf_app(emd->dbuf, "r%d", _C(op->v));
		}

		// rB
		if (op->flags & EMD_FL_MOD_B) {
			emdas_buf_app(emd->dbuf, "+r%d", _B(op->v));
		}

		if (op->flags & EMD_FL_MOD_D) emdas_buf_c(emd->dbuf, ']');
	}
}