コード例 #1
0
ファイル: bt2d_base.c プロジェクト: cr88192/bgbtech_engine
void Tile2D_AnimTick_Bear(Tile2D_Entity *self)
{
	Tile2D_Entity *tmp;
	vec2 dir;
	float h;
	char *s;
	int i, j;

	i=((int)floor(bt2d_state->time_f*4))&1;
	switch(i)
	{
	case 0: s="sprites/tile2d/pedobear_l0"; break;
	case 1: s="sprites/tile2d/pedobear_l1"; break;
	}
	self->spr_tex=LBXGL_Texture_LoadImage(s);

	if(!(rand()&31) && (v2dist(tile2d_player->org, self->org)<64))
	{
		dir=v2sub(tile2d_player->org, self->org);
		dir=v2norm(dir);
		dir=v2scale(dir, 10);
//		dir=vec2(1*sin(h), 1*cos(h));
	
//		j=((int)floor(bt2d_state->time_f*2))&3;
		j=rand()&3;
//		h=(bt2d_state->time_f)*(M_PI/0.1665);
		tmp=Tile2D_SpawnEntity_Bullet(
			v2add(self->org, vec2(0, 1)),
			dir, 0+j);
		tmp->next=tile2d_entity;
		tile2d_entity=tmp;
		tmp->owner=self;
	}
}
コード例 #2
0
ファイル: qr.c プロジェクト: AlecGamble/daala
int qrdecomp_hh(double *aat, int aat_stride, double *d,
 double *qqt, int qqt_stride, double *rr, int n, int m) {
  int rank;
  int i;
  int j;
  int k;
  int l;
  rank = 0;
  l = m < n ? m : n;
  for (k = 0; k < l; k++) {
    double *aatk;
    double d2;
    aatk = aat + k*aat_stride;
    d2 = v2norm(aatk + k, m - k);
    if (d2 != 0) {
      double e;
      double s;
      if (aatk[k] < 0) d2 = -d2;
      for (i = k; i < m; i++) aatk[i] /= d2;
      e = ++aatk[k];
      for (j = k + 1; j < n; j++) {
        double *aatj;
        aatj = aat + j*aat_stride;
        s = -vdot(aatk + k, aatj + k, m - k)/e;
        for (i = k; i < m; i++) aatj[i] += s*aatk[i];
        if (rr != NULL) rr[UT_IDX(k, j, n)] = aatj[k];
      }
      rank++;
    }
    d[k] = -d2;
    if (rr != NULL) rr[UT_IDX(k, k, n)] = d[k];
  }
  /*Uncomment (along with code below for Q) to compute the _unique_
     factorization with the diagonal of R strictly non-negative.
    Unfortunately, this will not match the encoded Q and R in qrt, preventing
     the user from mixing and matching the explicit and implicit
     decompositions.*/
  /*if(rr != NULL) {
    for (k = 0; k < l; k++) {
      if (d[i] < 0) {
        for(j = k; j < n; j++) rr[UT_IDX(k, j, n)] = -rr[UT_IDX(k, j, n)];
      }
    }
  }*/
  if(qqt != NULL) {
    for (k = l; k-- > 0;) {
      double *aatk;
      double *qqtj;
      double e;
      aatk = aat + k*aat_stride;
      qqtj = qqt + k*qqt_stride;
      memset(qqtj, 0, k*sizeof(*qqtj));
      for (i = k; i < m; i++) qqtj[i] = -aatk[i];
      qqtj[k]++;
      e = aatk[k];
      if(e != 0)for(j = k + 1; j < l; j++) {
        double s;
        qqtj = qqt + j*qqt_stride;
        s = -vdot(aatk + k, qqtj + k, m - k)/e;
        for (i = k; i < m; i++) qqtj[i] += s*aatk[i];
      }
    }
    /*Uncomment (along with code above for R) to compute the _unique_
       factorization with the diagonal of R strictly non-negative.
      Unfortunately, this will not match the encoded Q and R in qrt, preventing
       the user from mixing and matching the explicit and implicit
       decompositions.*/
    /*for (k = 0; k < l; k++) if(d[k] < 0) {
      double *qqtk;
      qqtk = qqt + k*qqt_stride;
      for (i = 0; i < m; i++) qqtk[i] = -qqtk[i];
    }*/
  }
  return rank;
}