Esempio n. 1
0
void GsMat::translation ( float tx, float ty, float tz, char fmt )
 {
   if ( fmt=='C' ) // column-major format
    { setl1 (  1,  0,  0,  0 );
      setl2 (  0,  1,  0,  0 );
      setl3 (  0,  0,  1,  0 );
      setl4 ( tx,  ty, tz, 1 );
    }
   else // line-major format
    { setl1 (  1,  0,  0, tx );
      setl2 (  0,  1,  0, ty );
      setl3 (  0,  0,  1, tz );
      setl4 (  0,  0,  0,  1 );
    }
 }
Esempio n. 2
0
void GsMat::set ( const double *p )
 {
   setl1 ( (float)p[0],  (float)p[1],  (float)p[2],  (float)p[3]  );
   setl2 ( (float)p[4],  (float)p[5],  (float)p[6],  (float)p[7]  );
   setl3 ( (float)p[8],  (float)p[9],  (float)p[10], (float)p[11] );
   setl4 ( (float)p[12], (float)p[13], (float)p[14], (float)p[15] );
 }
Esempio n. 3
0
void GsMat::sub ( const GsMat& m1, const GsMat& m2 )
 {
   setl1 ( m1.E11-m2.E11, m1.E12-m2.E12, m1.E13-m2.E13, m1.E14-m2.E14 );
   setl2 ( m1.E21-m2.E21, m1.E22-m2.E22, m1.E23-m2.E23, m1.E24-m2.E24 );
   setl3 ( m1.E31-m2.E31, m1.E32-m2.E32, m1.E33-m2.E33, m1.E34-m2.E34 );
   setl4 ( m1.E41-m2.E41, m1.E42-m2.E42, m1.E43-m2.E43, m1.E44-m2.E44 );
 }
Esempio n. 4
0
void GsMat::set ( const float *p )
 {
   setl1 ( p[0],  p[1],  p[2],  p[3]  );
   setl2 ( p[4],  p[5],  p[6],  p[7]  );
   setl3 ( p[8],  p[9],  p[10], p[11] );
   setl4 ( p[12], p[13], p[14], p[15] );
 }
Esempio n. 5
0
void GsMat::rot ( const GsVec& vec, float sa, float ca, char fmt )
 {
   double x, y, z, norm;
   double xx, yy, zz, xy, yz, zx, xs, ys, zs, oc;

   x=vec.x; y=vec.y; z=vec.z;

   norm = x*x + y*y + z*z;
   if ( norm!=1.0 )
    { norm = sqrt(norm);
      if (norm!=0) { x/=norm; y/=norm; z/=norm; }
    }

   // If in column-major format, just get the negative angle:
   if ( fmt=='C' ) sa*=-1.0;

   xx = x * x;   yy = y * y;   zz = z * z;
   xy = x * y;   yz = y * z;   zx = z * x;
   xs = x * sa;  ys = y * sa;  zs = z * sa;

   oc = 1.0 - ca;

   setl1 ( float(oc * xx + ca), float(oc * xy - zs), float(oc * zx + ys), 0 );
   setl2 ( float(oc * xy + zs), float(oc * yy + ca), float(oc * yz - xs), 0 );
   setl3 ( float(oc * zx - ys), float(oc * yz + xs), float(oc * zz + ca), 0 );
   setl4 (                   0,                   0,                   0, 1 );
 }
Esempio n. 6
0
void GsMat::add ( const GsMat& m1, const GsMat& m2 )
 {
   setl1 ( m1.E11+m2.E11, m1.E12+m2.E12, m1.E13+m2.E13, m1.E14+m2.E14 );
   setl2 ( m1.E21+m2.E21, m1.E22+m2.E22, m1.E23+m2.E23, m1.E24+m2.E24 );
   setl3 ( m1.E31+m2.E31, m1.E32+m2.E32, m1.E33+m2.E33, m1.E34+m2.E34 );
   setl4 ( m1.E41+m2.E41, m1.E42+m2.E42, m1.E43+m2.E43, m1.E44+m2.E44 );
 }
Esempio n. 7
0
void GsMat::scale ( float sx, float sy, float sz )
 {
   setl1 (  sx,   0,   0,   0 );
   setl2 (   0,  sy,   0,   0 );
   setl3 (   0,   0,  sz,   0 );
   setl4 (   0,   0,   0,   1 );
 }
Esempio n. 8
0
void GsMat::rotz ( float sa, float ca, char fmt )
 {
   if ( fmt=='C' ) // column-major format
    {
      setl1 (  ca,  sa,  0,  0 );
      setl2 ( -sa,  ca,  0,  0 );
      setl3 (   0,   0,  1,  0 );
      setl4 (   0,   0,  0,  1 );
    }
   else // line-major format
    {
      setl1 (  ca, -sa,  0,  0 );
      setl2 (  sa,  ca,  0,  0 );
      setl3 (   0,   0,  1,  0 );
      setl4 (   0,   0,  0,  1 );
    }
 }
Esempio n. 9
0
GsMat::GsMat ( float a, float b, float c, float d,
               float e, float f, float g, float h, 
               float i, float j, float k, float l,
               float m, float n, float o, float p )
 {
   setl1 ( a, b, c, d );
   setl2 ( e, f, g, h );
   setl3 ( i, j, k, l );
   setl4 ( m, n, o, p );
 }
Esempio n. 10
0
void GsMat::ortho ( float left, float right, float bottom, float top, float near, float far )
 {
   const float t = 2.0f;
   float rml=right-left, tmb=top-bottom, nmf=near-far;
   setl1 (             t/rml,                 0,              0,  0 );
   setl2 (                 0,             t/tmb,              0,  0 );
   setl3 (                 0,                 0,          t/nmf,  0 );
   setl4 ( -(right+left)/rml, -(top+bottom)/tmb, (far+near)/nmf,  1 );

   transpose(); // back to line-major format...
 }
Esempio n. 11
0
void GsMat::orthowin ( float w, float h )
 {
   // equiv to ortho ( 0, w-1, h-1, 0, -1, 1 )
   const float t = 2.0f;
   setl1 ( t/(w-1),       0,  0,  0 );
   setl2 (       0, t/(1-h),  0,  0 );
   setl3 (       0,       0, -1,  0 );
   setl4 (      -1,       1,  0,  1 );

   transpose(); // back to line-major format...
 }
int command(isdn_ctrl *cmd)
{
	int card;

	card = get_card_from_id(cmd->driver);
	if(!IS_VALID_CARD(card)) {
		pr_debug("Invalid param: %d is not a valid card id\n", card);
		return -ENODEV;
	}

	pr_debug("%s: Received %s command from Link Layer\n",
		sc_adapter[card]->devicename, commands[cmd->command]);

	/*
	 * Dispatch the command
	 */
	switch(cmd->command) {
	case ISDN_CMD_IOCTL:
	{
		unsigned long 	cmdptr;
		scs_ioctl	ioc;

		memcpy(&cmdptr, cmd->parm.num, sizeof(unsigned long));
		if (copy_from_user(&ioc, (scs_ioctl __user *)cmdptr,
				   sizeof(scs_ioctl))) {
			pr_debug("%s: Failed to verify user space 0x%x\n",
				sc_adapter[card]->devicename, cmdptr);
			return -EFAULT;
		}
		return sc_ioctl(card, &ioc);
	}
	case ISDN_CMD_DIAL:
		return dial(card, cmd->arg, cmd->parm.setup);
	case ISDN_CMD_HANGUP:
		return hangup(card, cmd->arg);
	case ISDN_CMD_ACCEPTD:
		return answer(card, cmd->arg);
	case ISDN_CMD_ACCEPTB:
		return acceptb(card, cmd->arg);
	case ISDN_CMD_CLREAZ:
		return clreaz(card, cmd->arg);
	case ISDN_CMD_SETEAZ:
		return seteaz(card, cmd->arg, cmd->parm.num);
	case ISDN_CMD_SETL2:
		return setl2(card, cmd->arg);
	case ISDN_CMD_SETL3:
		return setl3(card, cmd->arg);
	default:
		return -EINVAL;
	}
	return 0;
}
Esempio n. 13
0
void GsMat::lookat ( const GsVec& eye, const GsVec& center, const GsVec& up )
 {
   GsVec f = center-eye; f.normalize(); // forward vector
   GsVec s = cross ( f, up ); s.normalize(); // side vector
   GsVec u = cross ( s, f );  // recompute up

   setl1 ( s.x, u.x, -f.x, 0 );
   setl2 ( s.y, u.y, -f.y, 0 );
   setl3 ( s.z, u.z, -f.z, 0 );
   setl4 ( dot(s,-eye), dot(u,-eye), dot(f,eye), 1.0f );

   transpose(); // back to line-major format...
 }
Esempio n. 14
0
void GsMat::perspective ( float fovy, float aspect, float znear, float zfar )
 {
   float top = znear * tanf ( fovy/2.0f );
   float left = -top * aspect;

   float w = -left-left; // width
   float h = top+top;    // height
   float z = zfar-znear; // znear and zfar are > 0

   setl1 (    (2*znear)/w,           0,                 0,  0 );
   setl2 (              0, (2*znear)/h,                 0,  0 );
   setl3 (              0,           0,   -(zfar+znear)/z, -1 );
   setl4 (              0,           0, -(2*zfar*znear)/z,  0 );

   // Notes: 
   // The OpenGL docs show the matrix in line-major format not column-major as here

   transpose(); // back to line-major format...
 }