double alpha;
//Calcular el ángulo que forman las rectas, sabiendo sus vectores directores.
- double cosAlpha = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) ));
+ //double cosAlpha = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) ));
+ double cosAlpha = ( ( x*xp )+( y*yp )+( z*zp ) )/(sqrt( pow(x,2.0) + pow(y,2.0) + pow(z,2.0) )*sqrt ( pow(xp,2.0) + pow(yp,2.0) + pow(zp,2.0) ) );
alpha = (180 * acos(fabs(cosAlpha)))/M_PI;
- //std::cout << "Angulo Alpha: " << alpha << std::endl;
+ /*if((alpha<=90)&&(alpha>=0)){
+ std::cout << " " << a << " " << b <<" " << c <<" " << x <<" " << y <<" " << z <<" " << xp <<" " << yp <<" " << zp;
+ std::cout << " cosAlpha: " << cosAlpha;
+ std::cout << " acos(fabs(cosalpha)) " << acos(fabs(cosAlpha));
+ std::cout << " Angulo Alpha: " << alpha << std::endl ; }*/
double ent = floor(alpha);
double al = alpha - ent;
double min = al * 60;
double beta;
//Calcular el ángulo que forman las rectas, sabiendo sus vectores directores.
- double cosBeta = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) ));
-
+ //double cosBeta = ( ( (x-a)*(xp-a) )+( (y-b)*(yp-b) )+( (z-c)*(zp-c) ) )/sqrt((( (pow(x,2.0)-pow(a,2.0)) + (pow(y,2.0)-pow(b,2.0)) + (pow(z,2.0)-pow(c,2.0)) )*( (pow(xp,2.0)-pow(a,2.0)) + (pow(yp,2.0)-pow(b,2.0)) + (pow(zp,2.0)-pow(c,2.0)) ) ));
+ double cosBeta = ( ( x*xp )+( y*yp )+( z*zp ) )/(sqrt( pow(x,2.0) + pow(y,2.0) + pow(z,2.0) )*sqrt ( pow(xp,2.0) + pow(yp,2.0) + pow(zp,2.0) ) );
beta = (180 * acos(fabs(cosBeta)))/M_PI;
//std::cout << "Angulo Beta: " << beta << std::endl;
double ent = floor(beta);
int numTuple=0;
- for( i = 0 ; i < dim[0] ; i++ )
+ for( k = 0 ; k < dim[2] ; k++ )
{
for( j = 0 ; j < dim[1] ; j++ )
{
- for( k = 0 ; k < dim[2] ; k++ )
+ for( i = 0 ; i < dim[0] ; i++ )
{
//unsigned char* pPix = (unsigned char *)image->GetScalarPointer( i , j , k );
b = beta (Px, Py, Pz,
p2x, p2y, p2z,
vecProj[0], vecProj[1], vecProj[2]);
- //std::cout << " a: " << a << " b: " << b << std::endl;
- unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k );
- *zPtr1 = (unsigned char)a;
- unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k );
- *zPtr2 = (unsigned char)b;
- } //for k
+
+ //if(a>=90&&a<=360) { std::cout << " numTuple: " << numTuple << " a: " << a << " b: " << b << std::endl; }
+ if(p1==0&&p2==0&&p3==0){
+ unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k );
+ *zPtr1 = (unsigned char)255;
+ unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k );
+ *zPtr2 = (unsigned char)255;
+ }else{
+ unsigned char *zPtr1 = (unsigned char *) alphaImage->GetScalarPointer( i , j , k );
+ *zPtr1 = (unsigned char)a;
+ unsigned char *zPtr2 = (unsigned char *) betaImage->GetScalarPointer( i , j , k );
+ *zPtr2 = (unsigned char)b;
+ }
+ } //for i
} // for j
- } // for i
+ } // for k
std::cout << "CFT creaVtkHeartAngles::calculateImages End"<<std::endl;