Beispiel #1
0
int main() 
{
    int T,a,b,N;
    
    scanf("%d", &T); //Number of test cases
    for (int i=1; i<=T; i++) 
    {
        scanf("%d %d %d", &a, &b, &N);
        for (int j=0; j<=N-1; j++) printf("%d ", Tn(a, b, j));            
        printf("\n");
    }
    return 0;
}
Beispiel #2
0
/** @brief calculate the normals of all triangles (Tn) and the average
  normals of the vertices (N); average normals are averaged over
  all adjacent triangles that are in the triangle list or member of
  a strip */
void Mesh::computeNormals() {
  uint i;
  Vector a, b, c;
  Tn.resize(T.d0, 3);
  Tn.setZero();
  Vn.resize(V.d0, 3);
  Vn.setZero();
  //triangle normals and contributions
  for(i=0; i<T.d0; i++) {
    a.set(&V(T(i, 0), 0));
    b.set(&V(T(i, 1), 0));
    c.set(&V(T(i, 2), 0));

    b-=a; c-=a; a=b^c; a.normalize();
    Tn(i, 0)=a.x;  Tn(i, 1)=a.y;  Tn(i, 2)=a.z;
    Vn(T(i, 0), 0)+=a.x;  Vn(T(i, 0), 1)+=a.y;  Vn(T(i, 0), 2)+=a.z;
    Vn(T(i, 1), 0)+=a.x;  Vn(T(i, 1), 1)+=a.y;  Vn(T(i, 1), 2)+=a.z;
    Vn(T(i, 2), 0)+=a.x;  Vn(T(i, 2), 1)+=a.y;  Vn(T(i, 2), 2)+=a.z;
  }
  Vector d;
  for(i=0; i<Vn.d0; i++) { d.set(&Vn(i, 0)); Vn[i]()/=d.length(); }
}
// Fonction d'intérpolation Hermite
void SolveTCB ( float t, int *x, int *y, int *z)
{
// Déclaration des Keyframes utilisés
Key *NextKey, *NextNextKey, *CurKey, *PrevKey;

// Varaible d'incrémentation
int i;

// Taille du tableau de Keyframe
const int NumKeys = ((double)sizeof(TabKey))/((double)sizeof(Key));
const int NumKeysMinusOne = NumKeys-1;


// Boucle de parcours des Keyframes
//..

for(i = 0; i < NumKeys;i++)
{
	NextKey = &TabKey[i];
	if (t<NextKey->t){
		
		if(i==0) {
			CurKey = &TabKey[NumKeysMinusOne];
			PrevKey = &TabKey[NumKeysMinusOne-1];	
			NextNextKey = &TabKey[1];	
			}
				
		else if(i==1){
			CurKey = &TabKey[0];
			PrevKey = &TabKey[NumKeysMinusOne];	
			NextNextKey = &TabKey[2];	
			}

		else if(i==NumKeysMinusOne){
			CurKey = &TabKey[i-1];
			PrevKey = &TabKey[i-2];	
			NextNextKey = &TabKey[0];	
			}

		else   {
			CurKey = &TabKey[i-1];	
			PrevKey = &TabKey[i-2];	
			NextNextKey = &TabKey[i+1];
			}
		
		// calcul tangents	
			//curent
			float u = ((t-CurKey->t) / (NextKey->t - CurKey->t));
			float ctx,cty,ctz;
			float ntx,nty,ntz;
			
			ctx  = Tn(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.x,CurKey->pos.x);
			cty  = Tn(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.y,CurKey->pos.y);
			ctz  = Tn(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.z,CurKey->pos.z);

			//printf("ctx -- > %lf \n",ctx);
			
			//next
			ntx  = Tn1(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.x,CurKey->pos.x,NextKey->pos.x,NextNextKey->pos.x);
			nty  = Tn1(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.y,CurKey->pos.y,NextKey->pos.y,NextNextKey->pos.y);
			ntz  = Tn1(CurKey->tension,CurKey->bias,CurKey->continuity,PrevKey->pos.z,CurKey->pos.z,NextKey->pos.z,NextNextKey->pos.z);

			//printf(" ntx -- > %lf \n",ntx);
			

		// mise a jour des positions
			*x = (int) (H0(u)*CurKey->pos.x + H1(u)*NextKey->pos.x + H2(u)*ctx + H3(u)*ntx);
			*y = (int) (H0(u)*CurKey->pos.y + H1(u)*NextKey->pos.y + H2(u)*cty + H3(u)*nty);
			*z = (int) (H0(u)*CurKey->pos.z + H1(u)*NextKey->pos.z + H2(u)*ctz + H3(u)*ntz);
			printf("\n%lf\n",( CurKey->pos.x ));
			printf("\n%lf, %lf\n",H1(t),( NextKey->pos.x ));
			printf("\n%lf\n",( H2(t)*CurKey->tension ));				
			printf("\n%lf\n",( H3(t)*NextKey->tension ));
	 		//printf(" time -> %f X -- > %d \n",t,*x);
			//printf(" H0(t) = %f , H1(t) = %f , H2(t) = %f , H3(t) = %f \n",H0(t),H1(t),H2(t),H3(t));
			//if(*x < (-8000) || *x > 8000)
			//exit(0);
	//break;
	return;	
	}
}
 time = 0;
 return;


}
Beispiel #4
0
void Mesh::clean() {
  uint i, j, idist=0;
  Vector a, b, c, m;
  double mdist=0.;
  arr Tc(T.d0, 3); //tri centers
  arr Tn(T.d0, 3); //tri normals
  uintA Vt(V.d0);
  intA VT(V.d0, 100); //tri-neighbors to a vertex
  Vt.setZero(); VT=-1;
  
  for(i=0; i<T.d0; i++) {
    a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0));
    
    //tri center
    m=(a+b+c)/3.;
    Tc(i, 0)=m.x;  Tc(i, 1)=m.y;  Tc(i, 2)=m.z;
    
    //farthest tri
    if(m.length()>mdist) { mdist=m.length(); idist=i; }
    
    //tri normal
    b-=a; c-=a; a=b^c; a.normalize();
    Tn(i, 0)=a.x;  Tn(i, 1)=a.y;  Tn(i, 2)=a.z;
    
    //vertex neighbor count
    j=T(i, 0);  VT(j, Vt(j))=i;  Vt(j)++;
    j=T(i, 1);  VT(j, Vt(j))=i;  Vt(j)++;
    j=T(i, 2);  VT(j, Vt(j))=i;  Vt(j)++;
  }
  
  //step through tri list and flip them if necessary
  boolA Tisok(T.d0); Tisok=false;
  uintA Tok; //contains the list of all tris that are ok oriented
  uintA Tnew(T.d0, T.d1);
  Tok.append(idist);
  Tisok(idist)=true;
  int A=0, B=0, D;
  uint r, k, l;
  intA neighbors;
  for(k=0; k<Tok.N; k++) {
    i=Tok(k);
    Tnew(k, 0)=T(i, 0); Tnew(k, 1)=T(i, 1); Tnew(k, 2)=T(i, 2);
    
    for(r=0; r<3; r++) {
      if(r==0) { A=T(i, 0);  B=T(i, 1);  /*C=T(i, 2);*/ }
      if(r==1) { A=T(i, 1);  B=T(i, 2);  /*C=T(i, 0);*/ }
      if(r==2) { A=T(i, 2);  B=T(i, 0);  /*C=T(i, 1);*/ }
      
      //check all triangles that share A & B
      setSection(neighbors, VT[A], VT[B]);
      neighbors.removeAllValues(-1);
      if(neighbors.N>2) MT_MSG("edge shared by more than 2 triangles " <<neighbors);
      neighbors.removeValue(i);
      //if(!neighbors.N) cout <<"mesh.clean warning: edge has only one triangle that shares it" <<endl;
      
      //orient them correctly
      for(l=0; l<neighbors.N; l++) {
        j=neighbors(l); //j is a neighboring triangle sharing A & B
        D=-1;
        //align the neighboring triangle and let D be its 3rd vertex
        if((int)T(j, 0)==A && (int)T(j, 1)==B) D=T(j, 2);
        if((int)T(j, 0)==A && (int)T(j, 2)==B) D=T(j, 1);
        if((int)T(j, 1)==A && (int)T(j, 2)==B) D=T(j, 0);
        if((int)T(j, 1)==A && (int)T(j, 0)==B) D=T(j, 2);
        if((int)T(j, 2)==A && (int)T(j, 0)==B) D=T(j, 1);
        if((int)T(j, 2)==A && (int)T(j, 1)==B) D=T(j, 0);
        if(D==-1) HALT("dammit");
        //determine orientation
        if(!Tisok(j)) {
          T(j, 0)=B;  T(j, 1)=A;  T(j, 2)=D;
          Tok.append(j);
          Tisok(j)=true;
        } else {
          //check if consistent!
        }
      }
      
#if 0
      //compute their rotation
      if(neighbors.N>1) {
        double phi, phimax;
        int jmax=-1;
        Vector ni, nj;
        for(l=0; l<neighbors.N; l++) {
          j=neighbors(l); //j is a neighboring triangle sharing A & B
          
          a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0));
          b-=a; c-=a; a=b^c; a.normalize();
          ni = a;
          
          a.set(&V(T(j, 0), 0)); b.set(&V(T(j, 1), 0)); c.set(&V(T(j, 2), 0));
          b-=a; c-=a; a=b^c; a.normalize();
          nj = a;
          
          Quaternion q;
          q.setDiff(ni, -nj);
          q.getDeg(phi, c);
          a.set(&V(A, 0)); b.set(&V(B, 0));
          if(c*(a-b) < 0.) phi+=180.;
          
          if(jmax==-1 || phi>phimax) { jmax=j; phimax=phi; }
        }
        if(!Tisok(jmax)) {
          Tok.append(jmax);
          Tisok(jmax)=true;
        }
      } else {
        j = neighbors(0);
        if(!Tisok(j)) {
          Tok.append(j);
          Tisok(j)=true;
        }
      }
#endif
    }
  }
  if(k<T.d0) {
    cout <<"mesh.clean warning: not all triangles connected: " <<k <<"<" <<T.d0 <<endl;
    cout <<"WARNING: cutting of all non-connected triangles!!" <<endl;
    Tnew.resizeCopy(k, 3);
    T=Tnew;
    deleteUnusedVertices();
  }
  computeNormals();
}
Beispiel #5
0
int K1(int iRT, int zO_P, int Do, int vxlI, int j1i, int a, int JUdI, int X, int pOY) {
if (Bba - QJ0E >= + ! HL(- z(302957500, ! (k9j) != eJvv + (G((ShI * (dAd)), 2084374456, - (1394734516) - 578517423, 420911301)), (zqg)), xdqI, P, (rnkx(+ V2(2141821581, ! pSOs((10986324), - + XAO > E7 == N() <= Sl() / 264945842 >= TE + qV < (1458692725) % XYqq), - ! ! M, 1551887947, XnwB()), Tn(782235838 == uQZ > podo(1337746681, ! 224880727), ! eca < ZTyn, 484572022, + ! ! v4v))) >= - w8w5(290173308 * k5, 1725371014, 1216256323, o2DU) > 50666347 != SnrK) % KPt + dDQ3) ;
 else return K;
while (! 1985392826) return J2st(x23, 142371013);
return AJkU / 1202235129;
{
int lLU;
int S9;
int ZYL;
int SjH;
int Uor;
int nv;
int _JYO;
ceH_;
}
;
}