Ejemplo n.º 1
0
/*!
  Print to stdout the values of the current visual feature.

  \param select : Selection of a subset of the possible 2D image point
  feature coordinates.
  - To print all the two polar coordinates \f$(\rho,\theta)\f$ used as
  features use vpBasicFeature::FEATURE_ALL.
  - To print only one of the polar coordinate
  feature \f$(\rho,\theta)\f$ use one of the
  corresponding function selectRho() or selectTheta().

  \code
  // Creation of the current feature s
  vpFeaturePointPolar s;
  s.buildFrom(0.1, M_PI_2, 1.3);

  s.print(); // print all the 2 components of the image point feature
  s.print(vpBasicFeature::FEATURE_ALL); // same behavior then previous line
  s.print(vpFeaturePointPolar::selectRho()); // print only the rho component
  \endcode
*/
void
vpFeaturePointPolar::print(const int select ) const
{

    std::cout <<"Point:  Z=" << get_Z() ;
    if (vpFeaturePointPolar::selectRho() & select )
        std::cout << " rho=" << get_rho() ;
    if (vpFeaturePointPolar::selectTheta() & select )
        std::cout << " theta=" << get_theta() ;
    std::cout <<std::endl ;
}
Ejemplo n.º 2
0
 /*! \brief Get the probability distribution of the radiation profile.
  *
  * This function returns the probability distribution calculated from the radiation profile.
  * This is necessary for the Monte Carlo calculation of the heat flux distribution.
  */
 probabilityDistribution get_probabilityDistribution() const {
     double integral = 0.0;
     for(uint32_t i = 0; i < N-1; ++i) {
         integral += 0.5*(*(m_powerDensity + i) + *(m_powerDensity + i + 1))*(*(m_rho + i + 1) - *(m_rho + i));
     }
     std::vector<double> rho = get_rho();
     std::vector<double> powerDensity = get_powerDensity();
     for(auto iter = powerDensity.begin(); iter != powerDensity.end(); ++iter) {
         *iter /= integral;
     }
     return probabilityDistribution(rho, powerDensity);
 }
Ejemplo n.º 3
0
void ascii_display_of_the_drop(
       lattice_ptr lattice, int j, int rho_cut, int rho_min)
{
  double rho;
  const double rho_v=85.7042;
  const double rho_l=524.3905;
  int i, max_i = 80;
  max_i = (max_i > get_LX(lattice))?( get_LX(lattice)):(max_i);

  for( i=0; i<max_i; i++)
  {
    if( is_solid_node( lattice, /*subs=*/0, IJ2N(i,j)))
    {
      printf("%2d",i%100);
      if( j!=0)
      {
        printf("%s %d >> WARNING: "
            "Function compute_drop() is designed to compute the "
            "width and height of a drop forming on a "
            "surface at the bottom of the domain. "
            "Solid detected at (%d,%d) does not conform to that "
            "configuration.\n",
            __FILE__, __LINE__, i, j );
      }
    }
    else
    {
      rho = get_rho(lattice,i,j,/*subs=*/0);

      if( rho > rho_l)
      { printf("++"); }
      else if( rho > rho_cut)
      { printf("Xx"); }
      else if( rho > rho_min)
      { printf("o "); }
      else if( rho < rho_v)
      { printf("--"); }
      else
      { printf(". "); }
    }
  }
  printf("%3d\n",j);

} // void ascii_display_of_the_drop( lattice_ptr lattice, int j, ...
Ejemplo n.º 4
0
/*!

  Display image point feature.

  \param cam : Camera parameters.
  \param I : Image.
  \param color : Color to use for the display
  \param thickness : Thickness of the feature representation.

*/
void
vpFeaturePointPolar::display(const vpCameraParameters &cam,
                             const vpImage<unsigned char> &I,
                             const vpColor &color,
                             unsigned int thickness) const
{
  try {
    double rho,theta;
    rho   = get_rho();
    theta = get_theta();

    double x,y;
    x = rho*cos(theta);
    y = rho*sin(theta);

    vpFeatureDisplay::displayPoint(x, y, cam, I, color, thickness);
  }
  catch(...) {
    vpERROR_TRACE("Error caught") ;
    throw ;
  }
}
// void compute_drop( lattice_ptr lattice)
//
// Compute the width and height of the drop.
//
void compute_drop( lattice_ptr lattice)
{
  int i, j;
  double rho;
  const double rho_v=85.7042;
  const double rho_l=524.3905;
  const double rho_min=100.;
  //const double rho_cut=450.;
  const double rho_cut=(rho_v+rho_l)/2.;
  //const double rho_cut=212.36;

  //psi(rho_l)=4.*exp(-200/524.3905)
  //psi(rho_v)=4.*exp(-200/85.7042)

  int width=0, width_temp=0, max_width=0;
  int height=0;
  double theta;
  double max_rho=0.;

  for( j=get_LY(lattice)-1; j>=0; j--)
  {
    max_rho=0.;
    for( i=0; i<get_LX( lattice); i++)
    //for( i=0; i<170; i++)
    {
      //printf("%f ",get_rho(lattice,i,/*j=*/2,/*subs=*/0));
      if( max_rho < fabs( get_rho(lattice,i,/*j=*/j,/*subs=*/0)))
      {   max_rho = fabs( get_rho(lattice,i,/*j=*/j,/*subs=*/0)); }
    }
    if( max_rho > rho_min)
    {
      if( max_rho >= rho_cut){ height++;}
      width_temp=0;
      for( i=0; i<get_LX( lattice); i++)
      //for( i=0; i<170; i++)
      {
        if(/*ascii display of the drop*/0)
        {
          if( is_solid_node( lattice, /*subs=*/0, IJ2N(i,j)))
          {
            printf("%%");
            if( j!=0)
            {
              printf("%s %d >> WARNING: "
                  "Function compute_drop() is designed to compute the "
                  "width and height of a drop forming on a "
                  "surface at the bottom of the domain. "
                  "Solid detected at (%d,%d) does not conform to that "
                  "configuration.\n",
                  __FILE__, __LINE__, i, j );
            }
          }
          else
          {
            if(get_rho(lattice,i,/*j=*/j,/*subs=*/0) > rho_cut)
            { printf("X"); width_temp++;}
            else if(get_rho(lattice,i,/*j=*/j,/*subs=*/0) > rho_min)
            { printf("x"); }
            else
            { printf("-"); }
          }
        }
        else
        {
          if(get_rho(lattice,i,/*j=*/j,/*subs=*/0) > rho_cut)
          { width_temp++;}
        }
      }
      if( width_temp > 0)
      {
        width = width_temp;
        if( max_width < width)
        {
          max_width = width;
        }
      }
      if(/*ascii display of the drop*/0) { printf("\n");}
    }
  }
  printf("width=%d, height=%d, ", width, height);
  printf("width/height=%f\n", (double)width/(double)height);
  printf("max_width=%d\n", max_width);
  printf("\n");

  if( height > width)
  {
    // TODO: Need to double check this formula:
    theta = PI/2. + atan( ((double)height/(double)width)
                        - ((double)width/(4.*(double)height)));
  }
  else if( height < width)
  {
    // TODO: Need to double check this formula:
    theta = atan( 1./( ((double)width/(4.*(double)height))
                     - ((double)height/(double)width)      ));
  }
  else if( height == width)
  {
    theta = PI/2.;
  }
  else
  {
    printf("%s %d >> Unhandled case: height=%d, width=%d\n",
      __FILE__, __LINE__, height, width);
    theta = 999.;
  }

  printf("theta = %f\n", theta);

  printf("\n");
  printf("rho_cut = %f\n", rho_cut);
  printf("psi(rho_cut) = %f\n", 4.*exp(-200./rho_cut));
  printf("psi(rho_v) = %f\n", 4.*exp(-200./85.7042));
  printf("psi(rho_l) = %f\n", 4.*exp(-200./524.3905));
  printf("psi((rho_l+rho_v)/2.) = %f\n", 4.*exp(-200./((85.7042+524.3905)/2.)));
  printf("(psi(rho_v)+psi(rho_l))/2. = %f\n",
    (4.*exp(-200./85.7042)+4.*exp(-200./524.3905))/2.);
  rho = 212.36; printf("psi(%f) = %f\n", rho, 4.*exp(-200./rho));

  //4.*exp(-200/524.3905)
  //4.*exp(-200/85.7042)

} /* void compute_drop( lattice_ptr lattice) */
Ejemplo n.º 6
0
/*!
  Compute and return the interaction matrix \f$ L \f$ associated to a
  subset of the possible 2D image point features with polar
  coordinates \f$(\rho,\theta)\f$.

  \f[
  L = \left[
  \begin{array}{l}
  L_{\rho} \\
  \; \\
  L_{\theta}\\
  \end{array}
  \right]
  =
  \left[
  \begin{array}{cccccc}
  \frac{-\cos \theta}{Z} & \frac{-\sin \theta}{Z}  &  \frac{\rho}{Z} & (1+\rho^2)\sin\theta  & -(1+\rho^2)\cos\theta &  0 \\
  \; \\
   \frac{\sin\theta}{\rho Z} & \frac{-\cos\theta}{\rho Z} &  0 &  \cos\theta /\rho &  \sin\theta/\rho & -1 \\
  \end{array}
  \right]
  \f]

  where \f$Z\f$ is the 3D depth of the considered point.

  \param select : Selection of a subset of the possible polar
  point coordinate features.
  - To compute the interaction matrix for all the two 
    subset features \f$(\rho,\theta)\f$ use vpBasicFeature::FEATURE_ALL. In
    that case the dimension of the interaction matrix is \f$ [2 \times
    6] \f$
  - To compute the interaction matrix for only one of the subset
    (\f$\rho,\theta\f$) use one of the corresponding function
    selectRho() or selectTheta(). In that case the returned
    interaction matrix is \f$ [1 \times 6] \f$ dimension.

  \return The interaction matrix computed from the 2D point
  polar coordinate features.

  \exception vpFeatureException::badInitializationError : If the point
  is behind the camera \f$(Z < 0)\f$, or if the 3D depth is null \f$(Z
  = 0)\f$, or if the \f$\rho\f$ polar coordinate of the point is null.

  The code below shows how to compute the interaction matrix associated to 
  the visual feature \f$s = (\rho,\theta)\f$.
  \code
  vpFeaturePointPolar s;
  double rho   = 0.3;
  double theta = M_PI;
  double Z     = 1;
  // Creation of the current feature s
  s.buildFrom(rho, theta, Z);
  // Build the interaction matrix L_s
  vpMatrix L = s.interaction();
  \endcode

  The interaction matrix could also be build by:
  \code
  vpMatrix L = s.interaction( vpBasicFeature::FEATURE_ALL );
  \endcode

  In both cases, L is a 2 by 6 matrix. The first line corresponds to
  the \f$\rho\f$ visual feature while the second one to the
  \f$\theta\f$ visual feature.

  It is also possible to build the interaction matrix associated to
  one of the possible features. The code below shows how to consider
  only the \f$\theta\f$ component.

  \code
  vpMatrix L_theta = s.interaction( vpFeaturePointPolar::selectTheta() );
  \endcode

  In that case, L_theta is a 1 by 6 matrix.
*/
vpMatrix
vpFeaturePointPolar::interaction(const unsigned int select)
{
  vpMatrix L ;

  L.resize(0,6) ;

  if (deallocate == vpBasicFeature::user)
  {
    for (unsigned int i = 0; i < nbParameters; i++)
    {
      if (flags[i] == false)
      {
        switch(i){
        case 0:
          vpTRACE("Warning !!!  The interaction matrix is computed but rho was not set yet");
        break;
        case 1:
          vpTRACE("Warning !!!  The interaction matrix is computed but theta was not set yet");
        break;
        case 2:
          vpTRACE("Warning !!!  The interaction matrix is computed but Z was not set yet");
        break;
        default:
          vpTRACE("Problem during the reading of the variable flags");
        }
      }
    }
    resetFlags();
  }

  double rho   = get_rho() ;
  double theta = get_theta() ;
  double Z_    = get_Z() ;

  double c_ = cos(theta);
  double s_ = sin(theta);

  double rho2 = rho*rho;

  if (fabs(rho) < 1e-6) {
    vpERROR_TRACE("rho polar coordinate of the point is null") ;
    std::cout <<"rho = " << rho << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "rho polar coordinate of the point is null")) ;
  }

  if (Z_ < 0)
  {
    vpERROR_TRACE("Point is behind the camera ") ;
    std::cout <<"Z = " << Z_ << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "Point is behind the camera ")) ;
  }

  if (fabs(Z_) < 1e-6)
  {
    vpERROR_TRACE("Point Z coordinates is null ") ;
    std::cout <<"Z = " << Z_ << std::endl ;

    throw(vpFeatureException(vpFeatureException::badInitializationError,
			     "Point Z coordinates is null")) ;
  }

  if (vpFeaturePointPolar::selectRho() & select )
  {
    vpMatrix Lrho(1,6) ; Lrho = 0;

    Lrho[0][0] = -c_/Z_  ;
    Lrho[0][1] = -s_/Z_ ;
    Lrho[0][2] = rho/Z_ ;
    Lrho[0][3] = (1+rho2)*s_ ;
    Lrho[0][4] = -(1+rho2)*c_ ;
    Lrho[0][5] = 0 ;

//     printf("Lrho: rho %f theta %f Z %f\n", rho, theta, Z);
//     std::cout << "Lrho: " << Lrho << std::endl;

    L = vpMatrix::stackMatrices(L,Lrho) ;
  }

  if (vpFeaturePointPolar::selectTheta() & select )
  {
    vpMatrix Ltheta(1,6) ; Ltheta = 0;

    Ltheta[0][0] = s_/(rho*Z_) ;
    Ltheta[0][1]  = -c_/(rho*Z_) ;
    Ltheta[0][2] = 0 ;
    Ltheta[0][3] = c_/rho ;
    Ltheta[0][4] = s_/rho ;
    Ltheta[0][5] = -1 ;

//     printf("Ltheta: rho %f theta %f Z %f\n", rho, theta, Z);
//     std::cout << "Ltheta: " << Ltheta << std::endl;
    L = vpMatrix::stackMatrices(L,Ltheta) ;
  }
  return L ;
}
Ejemplo n.º 7
0
// void compute_drop( lattice_ptr lattice)
//
// Compute the width and height of the drop. (SCMP)
//
void compute_drop(
       lattice_ptr lattice,
       int output_to_file,
       int jbase,
       double rho_cut,
       int header)
{
  int i, j;

  double rho;

  const double rho_v=85.7042;
  const double rho_l=524.3905;

  const double psi_v = 4.*exp(-200./(rho_v));
  const double psi_l = 4.*exp(-200./(rho_l));
  const double psi_cut=(psi_v+psi_l)/2.;

  //const double rho_cut=(rho_v+rho_l)/2.;
  //const double rho_cut= -200./log(.25*psi_cut);
  //const double rho_cut=450.;
  //const double rho_cut=100.;

  double i1, i2, icut_left, icut_right;
  double j1, j2, jcut;
  double rho1, rho2;

  // INPUTE PARAM NOW: const int jbase = 4;
  //  jbase frame_rate  theta_low       theta  theta_high
  //  ----- ---------- ----------  ----------  ----------
  //      1        100  91.909683   93.327450   94.732496
  //      1       1000  90.947016   92.357518   93.755755
  //      2        100  90.962932   92.396963   93.818305
  //      2       1000  90.000000   91.426377   92.840531
  //      3        100  89.037068   90.479460   91.909683
  //      3       1000  89.037068   90.479460   91.909683
  //      4        100  88.057956   89.516494   90.962932
  //      4       1000  88.057956   89.516494   90.962932

  const double rho_min=100.;
  //const double rho_min=rho_v;

  //psi(rho_l)=4.*exp(-200/524.3905)
  //psi(rho_v)=4.*exp(-200/85.7042)

  int width=0, width_temp=0, max_width=0, max_width_j=0;
  int height=0;
  double theta;
  double max_rho=0.;
  int imax;
  int imax1;
  int imax2;

  double G = get_G( lattice);
  double Gads = get_Gads( lattice, /*subs*/0);

  jcut = -1.; // Flag value.

  // Start at about 3/4 the height of the domain to skip over any condensing
  // blobs on the ceiling. Main drop being measured should not be that high.
  for( j=(int)floor((3./4.)*get_LY(lattice)); j>0; j--)
  {
    max_rho=0.;
    for( i=0; i<get_LX( lattice); i++)
    { rho = get_rho(lattice,i,/*j=*/j,/*subs=*/0);
      if( max_rho < fabs(rho))
      {   max_rho = fabs(rho); imax = i; } }

    if( /*row j crosses the drop*/ max_rho > rho_min)
    {
      if( max_rho > rho_cut && jcut < 0.)
      {
        // rho1 was assigned max_rho from row j-1.
        // j1 was assigned max_rho from row j-1.
        rho2 = max_rho;
        imax2 = imax;
        j2 = j;
        // Linear interpolation of jcut:
        jcut = j1 + ((j2-j1)/(rho2-rho1))*( rho_cut - rho1);
      }

      if( j>=jbase)
      {
        if( max_rho >= rho_cut){ height++;}
        width_temp=0;

        icut_left = -1;
        icut_right = -1;
        for( i=0; i<get_LX(lattice); i++)
        {
          rho = get_rho(lattice,i,j,/*subs=*/0);
          if( rho > rho_cut)
          {
            if( icut_left < 0. )
            {
              // i1 and rho1 were set at i-1.
              rho2 = rho;
              i2 = i;
              // Linear interpolation of icut_left:
              icut_left = i1 + ((i2-i1)/(rho2-rho1))*( rho_cut - rho1);
            }
            else { rho1 = rho; i1 = i; /*save for interp of icut_right*/}

            width_temp++;
          }
          else
          {
            if( icut_left < 0.)
            {
              i1 = i; rho1 = rho; /*save for interp of icut_left*/
            }
            else
            {
              if( icut_right < 0.)
              {
                // i1 and rho1 were set at i-1.
                rho2 = rho;
                i2 = i;
                // Linear interpolation of icut_right:
                icut_right = i1 + ((i2-i1)/(rho2-rho1))*( rho_cut - rho1);
              }
            }
          }
        }

        if( width_temp > 0)
        { width = width_temp;
          if( max_width < width) { max_width = width; max_width_j = j;} }
      }
    }
    else
    {
      rho1 = max_rho; // save rho1 to use for interpolation of jcut.
      imax1 = imax;
      j1 = j;
    }

  }
//for( i=0; i<get_LX( lattice); i++)
//{
//  printf("%f ",get_rho(lattice,i,/*j=*/max_width_j,/*subs=*/0));
//}

  if(/*verbose*/0)
  {
    printf("\n");
    printf("jbase = %d\n", jbase);
    printf("width=%d, height=%d, ", width, height);
    printf("width/height=%f, ", (double)width/(double)height);
    printf("max_width=%d at j=%d, ", max_width, max_width_j);

    theta = theta_of_height_width( jcut-jbase, icut_right-icut_left);
    printf("%f = %f^o ", theta, theta*(180./PI));

    theta = theta_of_height_width( height-1, width+1);
    printf("theta_low = %f = %f^o, ", theta, theta*(180./PI));

    theta = theta_of_height_width( height, width);
    printf("theta = %f = %f^o, ", theta, theta*(180./PI));

    theta = theta_of_height_width( height+1, width-1);
    printf("theta_high = %f = %f^o, ", theta, theta*(180./PI));

    theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l));
    printf("theta_predicted_youngs = %f = %f^o ", theta, theta*(180./PI));

    //theta = PI*( ( Gads/G - psi_l) / ( psi_v - psi_l));
    //printf("theta_predicted_combination = %f = %f^o ", theta, theta*(180./PI));

    printf("\n");
    printf("rho_cut = %f\n", rho_cut);
    printf("(icut_left,icut_right,jcut) = ( %9.6f, %9.6f, %9.6f); "
        "(imax1,imax2)=(%d,%d); (icut_left+icut_right)/2 = %9.6f\n",
        icut_left, icut_right, jcut, imax1, imax2,(icut_left+icut_right)/2.);
    printf("psi(rho_cut) = %f\n", 4.*exp(-200./rho_cut));
    printf("psi(rho_v) = %f\n", 4.*exp(-200./85.7042));
    printf("psi(rho_l) = %f\n", 4.*exp(-200./524.3905));
    printf("psi((rho_l+rho_v)/2.) = %f\n", 4.*exp(-200./((85.7042+524.3905)/2.)));
    printf("(psi(rho_v)+psi(rho_l))/2. = %f\n",
        (4.*exp(-200./85.7042)+4.*exp(-200./524.3905))/2.);
    rho = 212.36; printf("psi(%f) = %f\n", rho, 4.*exp(-200./rho));
  }
  else
  {
    if( header)
    {
      printf("\n");
      printf(
                          " DROP "
          "                 jbase"
          "               rho_cut"
          "                 width"
          "                height"
          "       theta pixelated"
          "    theta interpolated"
          "       theta predicted"
          "\n");
      printf(
                          " DROP "
          " ---------------------"
          " ---------------------"
          " ---------------------"
          " ---------------------"
          " ---------------------"
          " ---------------------"
          " ---------------------"
          "\n");
    }

    printf(" DROP ");
    printf(" %21.17f", (double)jbase);
    printf(" %21.17f", rho_cut);

    printf(" %21.17f", icut_right-icut_left);
    printf(" %21.17f", jcut - jbase);

    theta = theta_of_height_width( height, width);
    printf(" %21.17f", theta*(180/PI));

    theta = theta_of_height_width( jcut-jbase, icut_right-icut_left);
    printf(" %21.17f", theta*(180/PI));

    theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l));
    printf(" %21.17f", theta*(180/PI));

    printf("\n");

  }

  if( output_to_file)
  {
    FILE *o;
    o = fopen( "compute_drop.dat", "a+");

    fprintf( o, "%d ", get_NumFrames( lattice));
    fprintf( o, "%d ", get_FrameRate( lattice));
    fprintf( o, "%8.4f ", get_G( lattice));
    fprintf( o, "%8.4f ", get_Gads( lattice, /*subs*/0));
    fprintf( o, "%d ", jbase);
    fprintf( o, "%d ", width);
    fprintf( o, "%d ", height);

    theta = theta_of_height_width( jcut-jbase, icut_right-icut_left);
    fprintf( o, "%20.17f ", theta*(180./PI));

    theta = theta_of_height_width( height-1, width+1);
    fprintf( o, "%20.17f ", theta*(180./PI));
    theta = theta_of_height_width( height, width);
    fprintf( o, "%20.17f ", theta*(180./PI));
    theta = theta_of_height_width( height+1, width-1);
    fprintf( o, "%20.17f ", theta*(180./PI));

    theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l));
    //fprintf( o, "acos(%20.17f) = ", ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l));
    fprintf( o, "%20.17f ", theta*(180./PI));

    //theta = PI*( ( Gads/G - psi_l) / ( psi_v - psi_l));
    //fprintf( o, "%20.17f ", theta*(180./PI));

    fprintf( o, "\n");
    fclose(o);
  }

  //4.*exp(-200/524.3905)
  //4.*exp(-200/85.7042)

} /* void compute_drop( lattice_ptr lattice, bool output_to_file) */