Esempio n. 1
0
inline bool CheckVec3Nan(eiVector &val)
{
	if (!_finite(val.x))return true;
	if (!_finite(val.y))return true;
	if (!_finite(val.z))return true;
	return false;
}
	double CTranosemaEquations::GetSurvivalRate(size_t s, double T)
	{
		static const double P[NB_STAGES][2] =
		{
			//  x      s
			{ 7.0251, -0.1735 },	//Egg
			{ 9.6200, -0.2389 },	//Pupa
			{ 1.000, 0.0000 }		//Adult
		};

		double r = 0;
		switch (s)
		{
		case EGG:
		case PUPA:	r = 1 / (1 + exp(-(P[s][0] + P[s][1] * T))); break;
		case ADULT:	r = 1; break;
		default: _ASSERTE(false);
		}

		_ASSERTE(!_isnan(r) && _finite(r));
		if (_isnan(r) || !_finite(r))//just in case
			r = 1;

		return r;
	}
Esempio n. 3
0
//==============================================================================
void
interval_orientation3d(const double* x0,
                       const double* x1,
                       const double* x2,
                       const double* x3,
                       double* lower,
                       double* upper)
{
    fesetround(FE_DOWNWARD);
    *lower=simple_orientation3d(x0, x1, x2, x3);
    fesetround(FE_UPWARD);
    *upper=simple_orientation3d(x0, x1, x2, x3);
#ifdef _MSC_VER
    assert( !_isnan(*lower) );
    assert( !_isnan(*upper) );
    assert( _finite(*lower) );
    assert( _finite(*upper) );
#else
    assert( !std::isnan(*lower) );
    assert( !std::isnan(*upper) );
    assert( !std::isinf(*lower) );
    assert( !std::isinf(*upper) );
#endif
    assert(*lower<=*upper);
}
Esempio n. 4
0
////////////////////////////////////////////////////////////////////////////////////////
// Make Sure Entire Vector Has Valid Numbers
////////////////////////////////////////////////////////////////////////////////////////
bool	CVec3::IsFinite()
{
#if defined(_MSC_VER) 
		return 	(_finite(v[0]) && _finite(v[1]) && _finite(v[2]));
#else
		return isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]);
#endif
}
static inline void b3SolveContact(b3ContactConstraint4& cs, 
	const b3Vector3& posA, b3Vector3& linVelA, b3Vector3& angVelA, float invMassA, const b3Matrix3x3& invInertiaA,
	const b3Vector3& posB, b3Vector3& linVelB, b3Vector3& angVelB, float invMassB, const b3Matrix3x3& invInertiaB, 
	float maxRambdaDt[4], float minRambdaDt[4])
{

	b3Vector3 dLinVelA; dLinVelA.setZero();
	b3Vector3 dAngVelA; dAngVelA.setZero();
	b3Vector3 dLinVelB; dLinVelB.setZero();
	b3Vector3 dAngVelB; dAngVelB.setZero();

	for(int ic=0; ic<4; ic++)
	{
		//	dont necessary because this makes change to 0
		if( cs.m_jacCoeffInv[ic] == 0.f ) continue;

		{
			b3Vector3 angular0, angular1, linear;
			b3Vector3 r0 = cs.m_worldPos[ic] - (b3Vector3&)posA;
			b3Vector3 r1 = cs.m_worldPos[ic] - (b3Vector3&)posB;
			b3SetLinearAndAngular( (const b3Vector3 &)-cs.m_linear, (const b3Vector3 &)r0, (const b3Vector3 &)r1, linear, angular0, angular1 );

			float rambdaDt = b3CalcRelVel((const b3Vector3 &)cs.m_linear,(const b3Vector3 &) -cs.m_linear, angular0, angular1,
				linVelA, angVelA, linVelB, angVelB ) + cs.m_b[ic];
			rambdaDt *= cs.m_jacCoeffInv[ic];

			{
				float prevSum = cs.m_appliedRambdaDt[ic];
				float updated = prevSum;
				updated += rambdaDt;
				updated = b3Max( updated, minRambdaDt[ic] );
				updated = b3Min( updated, maxRambdaDt[ic] );
				rambdaDt = updated - prevSum;
				cs.m_appliedRambdaDt[ic] = updated;
			}

			b3Vector3 linImp0 = invMassA*linear*rambdaDt;
			b3Vector3 linImp1 = invMassB*(-linear)*rambdaDt;
			b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
			b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
#ifdef _WIN32
            b3Assert(_finite(linImp0.getX()));
			b3Assert(_finite(linImp1.getX()));
#endif
			{
				linVelA += linImp0;
				angVelA += angImp0;
				linVelB += linImp1;
				angVelB += angImp1;
			}
		}
	}


}
Esempio n. 6
0
bool ExtentRect::isCorrupt()
{  
   bool retval = false;
   
   if (!(_finite(left) && _finite(right) && _finite(bottom) && _finite(top)))
   {
      retval = true;
   }

   return retval;
}
Esempio n. 7
0
    bool IsValidVelocityVector(const Vector3df &pos)
    {
        // This is a heuristic check to guard against the OpenSim server sending us stupid velocity vectors.
        if (fabs(pos.x) > 1e3f || fabs(pos.y) > 1e3f || fabs(pos.z) > 1e3f)
            return false;
        if (_isnan(pos.x) || _isnan(pos.y) || _isnan(pos.z))
            return false;
        if (!_finite(pos.x) || !_finite(pos.y) || !_finite(pos.z))
            return false;

        return true;
    }
Esempio n. 8
0
//---------------------------------------------------------------------------
void TPolFuncFrame::Eval(const TGraphElem *Elem)
{
  if(const TPolFunc *Func = dynamic_cast<const TPolFunc*>(Elem))
  {
    Clear();

    ErrorPrefix = "t: ";
    long double t = Form1->Data.Calc(ToWString(Edit1->Text));
    ErrorPrefix = "r(t): ";
    long double r = Func->GetFunc().CalcR(t);
    ErrorPrefix = "x(t): ";
    long double x = Func->GetFunc().CalcX(t);
    ErrorPrefix = "y(t): ";
    long double y = Func->GetFunc().CalcY(t);

    Edit2->Text = RoundToStr(r);
    Edit3->Text = RoundToStr(x);
    Edit4->Text = RoundToStr(y);

    Form1->SetCrossPos(x, y);

    ErrorPrefix = "dr/dt: ";
    Edit5->Text = RoundToStr(Func->GetFunc().MakeDif().CalcR(t));
    ErrorPrefix = "dy/dx: ";
    long double dydx = Func->GetFunc().CalcSlope(t);
    if(_finite(dydx))
      Edit6->Text = RoundToStr(dydx);
  }
}
Esempio n. 9
0
inline float rmsToDb(float rms)
{
    float db = 20.0f * log10(rms);
    if(!_finite(db))
        return VOL_MIN;
    return db;
}
Esempio n. 10
0
inline float toDB(float RMS)
{
    float db = 20.0f * log10(RMS);
    if(!_finite(db))
        return VOL_MIN;
    return db;
}
void Cylinder::SetRadius( double top_radius, double bottom_radius ) {

  if ( !_finite( bottom_radius ) ) bottom_radius = top_radius;
  this->top_radius = top_radius;
  this->bottom_radius = bottom_radius;

}
Esempio n. 12
0
/**
*   Print numer/denum ratio in dB
*/
static TCHAR * sprint_db_width(double numer, double denum, int width)
{
    static TCHAR buf[FIELDW];
    if (numer == 0)
    {
        _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("MATCH"));
    }
    else if (denum == 0)
    {
        _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("INF  "));
    }
    else
    { 
        double db = -10 * log10(numer / denum);
        if (_isnan(db) || !_finite(db))
        {
            _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("overflow"));
        }
        else
        {
            _sntprintf(buf, FIELDW, _T("%-*.2f"), width, db);
        }
    }
    buf[width] = 0;
    return buf;
}
Esempio n. 13
0
/**
*   Print numer/denum ratio as a bits count for equivalent 
*   uniform quantizer
*/
static TCHAR * SPrintBips (double numer, double denum, int width)
{
    static TCHAR buf[FIELDW];
    if (numer == 0)
    {
        _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("MATCH   "));
    }
    else if (denum == 0)
    {
        _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("INFINITY"));
    }
    else
    {
        double bips = 1. /  sqrt(12 * numer / denum);
        bips = 1 + log(bips) / log(2);
        if (_isnan(bips) || !_finite(bips))
        {
            _sntprintf(buf, FIELDW, _T("%-*s"), width, _T("overflow"));
        }
        else
        {
            _sntprintf(buf, FIELDW, _T("%-*.3f"), width, bips);
        }
    }
    return buf;
}
Esempio n. 14
0
File: nan.c Progetto: EQ4/SPTK
void nan_tmp(FILE * fp)
{
   long count = 0;
#ifdef DOUBLE
   double x;
#else
   float x;
#endif                          /* DOUBLE */

   while (freadx(&x, sizeof(x), 1, fp)) {
#ifdef WIN32
      if (!_finite(x))
         fprintf(stdout, "[No. %ld] is Infinity\n", count);
      if (_isnan(x))
         fprintf(stdout, "[No. %ld] is NaN\n", count);
#else
      if (isinf(x))
         fprintf(stdout, "[No. %ld] is Infinity\n", count);
      if (isnan(x))
         fprintf(stdout, "[No. %ld] is NaN\n", count);
#endif
      ++count;
   }

   return;
}
Esempio n. 15
0
        bool is_nan(float64 x) {
#ifdef WIN32
            return (_isnan(x) != 0) || (_finite(x) == 0) ;
#else
            return isnan(x) || !finite(x);
#endif
        }    
Esempio n. 16
0
	double Curve::GetSample(double value)
	{
		if (this->identity)
		{
			if (_finite(value))
			{
				return clamp(value, 0.0, 1.0);
			}

			return 0.0;
		}

		if (value > 0.0 && value < 1.0)
		{
			value = value * (sampleCount - 1);

			int index = (int)value;

			double f = value - index;

			return (1.0 - f) * samples[index] + f * samples[index + 1];
		}
		else if (value >= 1.0)
		{
			return samples[sampleCount - 1];
		}
		else
		{
			return samples[0];
		}
	}
GoalStateOfHealth::~GoalStateOfHealth()
{
    if( _player->isOverActivity() )
    {	
        Virtues* virtues = getScene()->getCareer()->getVirtues();
        assert( _finite( getGoalScore() ) );
        virtues->evolution.score += getGoalScore();
        if( virtues->evolution.score < 0 )
        {
            virtues->evolution.score = 0;
        }
        if( virtues->evolution.health == 0 )
        {
            bool creditsIsAffected = true;            
            // credits is not affected for licensed character
            creditsIsAffected = !_scene->getCareer()->getLicensedFlag();
            // credits is not affected in developer edition
			if ( Gameplay::iGameplay->_cheatsEnabled )
			{
				creditsIsAffected = false;
			}
            #ifdef GAMEPLAY_DEVELOPER_EDITION
                creditsIsAffected = false;
            #endif
            getCore()->logMessage( "creditsIsAffected=%d", creditsIsAffected );

            if( creditsIsAffected ) virtues->evolution.credits--;
            if( virtues->evolution.credits > 0 )
            {
                virtues->evolution.health = 0.125f;
            }
        }
    }
}
Esempio n. 18
0
inline bool isfinite(T arg) {
#ifndef _MSC_VER
  return (std::isfinite)(arg);
#else
  return _finite(arg) != 0;
#endif
}
Esempio n. 19
0
inline bool sc_isfinite( T x )
{
#if defined ( SC_VS ) && SC_VS < 12 // std::isfinite was added in vs2013
  return _finite( x ) != 0;
#else
  return std::isfinite( x );
#endif
}
Esempio n. 20
0
int my_finite(double x)
{
	#ifdef _MSC_VER
		return _finite(x);
	#else
		return finite(x);
	#endif
}
Esempio n. 21
0
bool IsValid(float val)
{
#ifdef _MSC_VER
  return _finite(val) != 0;
#else
  return val == val;
#endif
}
GoalSmokeball::~GoalSmokeball()
{
    if( _player->isOverActivity() )
    {
        Virtues* virtues = getScene()->getCareer()->getVirtues();
        assert( _finite( getGoalScore() ) );
        virtues->evolution.score += getGoalScore();
    }
}
Esempio n. 23
0
void rpn_exp2(calc_number_t *c)
{
    if (calc.base == IDC_RADIO_DEC) {
        c->f *= c->f;
        if (_finite(c->f) == 0)
            calc.is_nan = TRUE;
    } else
        c->i *= c->i;
}
Esempio n. 24
0
/**
 * \return true if v is Inf.
 */
bool RMath::isInf(double v) {
#ifdef Q_OS_MAC
    return std::fpclassify(v)==FP_INFINITE;
#elif defined Q_OS_WIN32
    return !_finite(v);
#else
    return std::fpclassify(v)==FP_INFINITE;
#endif
}
Esempio n. 25
0
bool Math::is_inf(double p_val) {

#ifdef _MSC_VER
	return !_finite(p_val);
#else
	return isinf(p_val);
#endif

}
Esempio n. 26
0
/* {{{ php_math_is_finite */
static inline int php_math_is_finite(double value) {
#if defined(PHP_WIN32)
	return _finite(value);
#elif defined(isfinite)
	return isfinite(value);
#else
	return value == value && (value == 0. || value * 2. != value);
#endif
}
double
doubleRem(double dividend, double divisor) {
    double res;

    if (!_finite(divisor)) {
	if (_isnan(divisor))
	    return divisor;
	if (_finite(dividend))
	    return dividend;
    }
    res = fmod(dividend, divisor);
    /* With MSVC, "res == 0" succeeds when res is NaN. */
    if (!_isnan(res) && res == 0) {  /*MSFT fmod doesn't do -0.0 right*/
      return _copysign(0.0,dividend);
    } else {
      return res;
    }
}
GoalTrackingPerformance::~GoalTrackingPerformance()
{
    if( _player->isOverActivity() )
    {
        Virtues* virtues = getScene()->getCareer()->getVirtues();
        assert( _finite( getGoalScore() ) );
        virtues->evolution.score += getGoalScore();
    }
}
Esempio n. 29
0
Quaternion UnpackQuaternionFromFloat3(float x, float y, float z)
{
    if (_isnan(x) || _isnan(y) || _isnan(z) || !_finite(x) || !_finite(y) || !_finite(z))
        return Quaternion(0, 0, 0, 1.f);

    float sq = x*x+y*y+z*z;
    // If the inputted coordinates are already too large in magnitude, renormalize the inputs and just set w = 0.
    // It can happen in two cases: Either float imprecision gave us a bit too high values, so setting w=0 is the proper action,
    // or then server sent us values that are bad to begin with. Anything is incorrect in this case, but to preserve at least
    // some sensibility in computations, renormalize the components and set w=0.
    if (sq >= 1.f) 
    {
        float invNorm = 1.f / sqrt(sq);
        return Quaternion(x * invNorm, y * invNorm, z * invNorm, 0.f);
    }
    float w = sqrt(1.f - sq);
    return Quaternion(x, y, z, w);
}
Esempio n. 30
0
void rpn_exp3(calc_number_t *c)
{
    if (calc.base == IDC_RADIO_DEC) {
        c->f = pow(c->f, 3.);
        if (_finite(c->f) == 0)
            calc.is_nan = TRUE;
    } else
        c->i *= (c->i*c->i);
}