Esempio n. 1
0
  void radial_limits( const Real eps, const Real L, Real Rlimits[2] ) {
    // Solve third order polynomial:
    double results[MAXDEGREE] = {0};
    double results_im[MAXDEGREE] = {0};
    double coeffs[MDP1];
    int degree = 3;
    
    // See limits_r.nb
    // We first solve limits for u=1/Rmax
    // c[0]u^3+...
    coeffs[0] = (pow(L,4) * Rs)
               / pow(eps,2);

    coeffs[1] = -1 * pow(L,4)
               / pow(eps,2);

    coeffs[2] = pow(L,2) * Rs
               / pow(eps,2);

    coeffs[3] = ( pow(L,2)- pow(L,2)/pow(eps,2) );
    
    // Solve:
    rpoly_ak1(coeffs, &degree, results, results_im);
    // Check results:
    for( int  i = 0; i < 3; ++i ) { if( results_im[i] != 0) { 
      Rlimits[0]=ERROR; Rlimits[1]=ERROR; return;} }
    if( results[0] <= 0 ) { Rlimits[0]=ERROR; Rlimits[1]=ERROR; cout << "bad data" << endl; return;}
    if( results[0] > results[1]){ Rlimits[0]=ERROR; Rlimits[1]=ERROR; cout << "errordata" << endl; return; }
    Rlimits[0] = 1.0/results[1];
    Rlimits[1] = 1.0/results[0];
    assert( Rlimits[1] >= Rlimits[0] );
    return;
  }
Esempio n. 2
0
void omni3d2pixel( double &x, double &y, const Eigen::Vector3d &xx, int length_poly, double *ss, int width, int height )
{
	// convert 3D coordinates vector into 2D pixel coordinates
	double denom = sqrt( xx[0]*xx[0] + xx[1]*xx[1] );
	double m = xx[2] / denom;

	double rho = 0;

	double *op = (double*) malloc( sizeof(double)*length_poly );
	for ( int i = 0; i < length_poly; i++ ) op[i] = ss[ length_poly - 1 - i ];
	op[length_poly - 2] = op[length_poly - 2] - m;

	int degree = length_poly - 1;

	double zeror[MAXDEGREE];
	double zeroi[MAXDEGREE];
	
	rpoly_ak1( op, &degree, zeror, zeroi );
    free(op);

	for ( int i = 0; i < degree; i++ ) {
		if ( zeroi[i] == 0 && zeror[i] > 0 && zeror[i] < height ) {
			rho = zeror[i];
			break;
		}
	}

	x = xx[0] / denom * rho ;
	y = xx[1] / denom * rho ;
}
Esempio n. 3
0
  void u_limits( const Real eps, const Real L, Real ulimits[2] ) {
    // Solve third order polynomial:
    double results[MAXDEGREE] = {0};
    double results_im[MAXDEGREE] = {0};
    double coeffs[MDP1];
    int degree = 3;
    
    // See FourVelocity.nb
    // We first solve limits for u
    // c[0]u^3+...
    const Real mp= 1; // Mass of the particle
    const Real c = 1; // Speed of light
    coeffs[0] = -1.*(pow(L,4) * Rs)
               / (pow(eps,2)*pow(mp,2));

    coeffs[1] = pow(L,4)
               / (pow(eps,2)*pow(mp,2));

    coeffs[2] = -1.*pow(c,2) * pow(L,2) * Rs
               / pow(eps,2);

    coeffs[3] = ( pow(c,2) * pow(L,2) )
               / pow(eps,2) 
	        -
	        pow(L,2)
               / ( pow(c,2) * pow(mp,2) );
    
    // Solve:
    rpoly_ak1(coeffs, &degree, results, results_im);
    // Check results:
    for( int  i = 0; i < 3; ++i ) { 
      if( results_im[i] != 0) { ulimits[0]=ERROR; ulimits[1]=ERROR; return;} 
    }
    if( results[0] <= 0 ) { ulimits[0]=ERROR; ulimits[1]=ERROR; cout << "bad data" << endl; return;}
    if( results[0] > results[1]){ ulimits[0]=ERROR; ulimits[1]=ERROR; cout << "errordata" << endl; return; }
    ulimits[0] = results[0];
    ulimits[1] = results[1];
    assert( ulimits[1] >= ulimits[0] );
    return;
  }