Esempio n. 1
0
void Plane::Shoot(Double speed, const Point2i& target)
{
  MSG_DEBUG("weapon.shoot", "Plane Shoot");
  nb_dropped_bombs = 0;
  last_dropped_bomb = NULL;

  cible_x = target.x;
  SetY(0);
  distance_to_release = (int)(speed * sqrt(TWO * (GetY() + target.y)));

  Point2d speed_vector;
  if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) {
    image->SetFlipped(false);
    speed_vector.SetValues(speed, 0);
    SetX(ONE - Double(image->GetWidth()));
    //distance_to_release -= obus_dx;
   if (distance_to_release > cible_x)
     distance_to_release = 0;

  } else {
    image->SetFlipped(true);
    speed_vector.SetValues(-speed, 0) ;
    SetX(Double(GetWorld().GetWidth() - 1));
    //distance_to_release += obus_dx;
    if (distance_to_release > GetWorld().GetWidth()-cible_x - obus_dx)
      distance_to_release = 0;
  }

  SetSpeedXY(speed_vector);

  Camera::GetInstance()->FollowObject(this);

  ObjectsList::GetRef().AddObject(this);
}
Esempio n. 2
0
void PictureWidget::ApplyScaling(ScalingType t)
{
  if (spr) {
    Point2d scale(Double(size.x) / picture_size.x,
                  Double(size.y) / picture_size.y);

    if (size.x==0 || size.y==0)
      return;

    switch (t) {
    case NO_SCALING: break;
    case X_SCALING: spr->Scale(scale.x, 1.0); break;
    case Y_SCALING: spr->Scale(1.0, scale.x); break;
    case STRETCH_SCALING: spr->Scale(scale.x, scale.y); break;
    case FIT_SCALING:
    default:
      {
        Double zoom = std::min(scale.x, scale.y);
        spr->Scale(zoom, zoom);
        break;
      }
    }
  }

  type = t;
}
Esempio n. 3
0
    // **************************************************************
    void Print()
    {
        Double memsize = Double(n) * sizeof(Double);
        std::string suffix;
        if(memsize >= 1.024e3)
        {
            memsize *= Double(1.0/1.024e3);
            suffix = "ki";
        }
        if(memsize >= 1.024e3)
        {
            memsize *= Double(1.0/1.024e3);
            suffix = "Mi";
        }
        if(memsize >= 1.024e3)
        {
            memsize *= Double(1.0/1.024e3);
            suffix = "Gi";
        }

        std_cout.Clear_Format();
        std_cout
            << "Lookup table information:\n"
            << "    Name:               " << name << "\n"
            << "    Range:              [" << range_min << ", " << range_max << "]\n"
            << "    Number of points:   " << n << "\n"
            << "    dx:                 " << dx << "\n"
            << "    Size:               " << memsize << " " << suffix << "B\n"
            << "    Pointer:            " << table << "\n";
    }
void FastMarch2D::FindPhi(int index, int x, int y) {
	static Double phiX, phiY, phiZ, b, quotient, phi;
    static int a;
    static bool flagX, flagY;

    phiX = phiY = phiZ = 0.;
    a = 0;
    flagX = flagY = 0;

	//Find The phiS
	CheckFront (phiX, a, flagX, GI(x+1,  y));
	CheckBehind(phiX, a, flagX, GI(x-1,  y));
	CheckFront (phiY, a, flagY, GI(x  ,y+1));
	CheckBehind(phiY, a, flagY, GI(x  ,y-1));

	//Max Tests
	if(a == 2) {
		if(phiX >= phiY) CheckMax2(a, phiX, phiY);
		else			 CheckMax2(a, phiY, phiX);
	}

	b = phiX + phiY + phiZ;
	quotient = square(b) - 
		Double(a) * (square(phiX) + square(phiY) + square(phiZ) - square(h));
	if(quotient < 0.) cout << "0 ";
	else {
		phi = b + sqrt(quotient);
		phi /= Double(a);
		grid[index].value = phi;
		if(grid[index].HeapPosition == -1) AddToHeap(index);
	    else                               UpdateHeap(index); 
	}
}
Esempio n. 5
0
obj applyV(double (*func)(double), obj v, obj name){
	if(type(v)==tDouble)	return Double(func(udbl(v)));
	if(type(v)==INT)	return Double(func(uint(v)));
	if(type(v) == tDblArray) {
		DblArray* a;
		a = &(udar(v));
		obj r = dblArray(a->size);
//		obj r = new dblarr(a->size);
		for(int i=0; i<(a->size); i++) udar(r).v[i] = func(a->v[i]);
		return r;
	}
	if(isVec(type(v))){
		int len = size(v);
		obj r = aArray(len);
		for(int i=0; i<len; i++){
			obj lt = ind(v,i);
			uar(r).v[i] = applyV(func, lt, name); 
			release(lt);
		}
		return r;
	}
	if(type(v)==LIST){
		list l = nil;
		for(list l1 = ul(v); l1; l1=rest(l1)){
			l = cons(applyV(func,first(l1), name), l);
		}
		return List2v(reverse(l));
	}
	obj rr=nil;
	if(name){
		rr = udef_op0(name, v);
	}
	if(!rr) error("func: argument must be a scalar or an array.");
	return rr;
}
Esempio n. 6
0
Double Double::operator-(const Double& d) const {
	if (fabs(_d - d._d) < parameter::small_epsilon()) return Double();

	assert(_d >= d._d);
	if (_d - d._d > LOG_BIGVAL) return *this;
	else return Double(true, d._d + log(exp(_d - d._d) - 1));
}
Esempio n. 7
0
void IERandom::Vec3(IEVector3& result,
					const IEVector3& mean,
					const IEVector3& variance)
{
	result.setX(static_cast<float>(Double(mean.getX(), variance.getX())));
	result.setY(static_cast<float>(Double(mean.getY(), variance.getY())));
	result.setZ(static_cast<float>(Double(mean.getZ(), variance.getZ())));
}
Esempio n. 8
0
Double Double::operator+(const Double& d) const {
#ifdef SANITY_CHECKS
	assert(fabs(_d) < LOG_BIGVAL && fabs(d._d) < LOG_BIGVAL);
#endif /* SANITY_CHECKS */
	if (d._d - _d > LOG_BIGVAL) return d;
	else if (_d - d._d > LOG_BIGVAL) return *this;
	else if (d._d > _d) return Double(true, _d + log(exp(d._d - _d) + 1));
	else return Double(true, d._d + log(exp(_d - d._d) + 1));
}
Esempio n. 9
0
void Polecat::Fart()
{
  // particles must be exactly the same accross the network
  Double norme = Double(RandomSync().GetInt(0, 500))/100;
  Double angle = Double(RandomSync().GetInt(0, 3000))/100;
  ParticleEngine::AddNow(GetPosition(), 3, particle_POLECAT_FART, true, angle, norme);
  last_fart_time = GameTime::GetInstance()->Read();
  JukeBox::GetInstance()->Play("default", "weapon/polecat_fart");
}
Esempio n. 10
0
void IERandom::Quat(IEQuaternion& result,
					const IEQuaternion& mean,
					const IEQuaternion& variance)
{
	result.setX(static_cast<float>(Double(mean.getX(), variance.getX())));
	result.setY(static_cast<float>(Double(mean.getY(), variance.getY())));
	result.setZ(static_cast<float>(Double(mean.getZ(), variance.getZ())));
	result.setW(static_cast<float>(Double(mean.getW(), variance.getW())));
}
Esempio n. 11
0
/**
 * Checks if the size difference of any dimension is more than a
 * factor of two.  This is used to check whether the terrain has to be
 * redrawn after zooming in.
 */
static bool
IsLargeSizeDifference(const GeoBounds &a, const GeoBounds &b)
{
  assert(a.IsValid());
  assert(b.IsValid());

  return a.GetWidth().Native() > Double(b.GetWidth().Native()) ||
    a.GetHeight().Native() > Double(b.GetHeight().Native());
}
Esempio n. 12
0
bool Path::PointInside(const Objects & objects, const Vec2 & pt, bool debug) const
{
	vector<Vec2> x_ints;
	vector<Vec2> y_ints;
	for (unsigned i = m_start; i <= m_end; ++i)
	{
		Bezier bez(objects.beziers[objects.data_indices[i]].ToAbsolute(objects.bounds[i]));
		vector<Vec2> xi(bez.SolveX(pt.x));
		vector<Vec2> yi(bez.SolveY(pt.y));
		x_ints.insert(x_ints.end(), xi.begin(), xi.end());
		y_ints.insert(y_ints.end(), yi.begin(), yi.end());
	}
	//Debug("Solved for intersections");
	unsigned bigger = 0;
	unsigned smaller = 0;
	for (unsigned i = 0; i < x_ints.size(); ++i)
	{
		if (debug)
				Debug("X Intersection %u at %f,%f vs %f,%f", i,Double(x_ints[i].x), Double(x_ints[i].y), Double(pt.x), Double(pt.y));
		if (x_ints[i].y >= pt.y)
		{
			
			++bigger;
		}
	}
	smaller = x_ints.size() - bigger;
	if (debug)
	{
		Debug("%u horizontal, %u bigger, %u smaller", x_ints.size(), bigger, smaller);
	}
	if (smaller % 2 == 0 || bigger % 2 == 0)
		return false;
		
	bigger = 0;
	smaller = 0;

	for (unsigned i = 0; i < y_ints.size(); ++i)
	{
		if (debug)
				Debug("Y Intersection %u at %f,%f vs %f,%f", i,Double(y_ints[i].x), Double(y_ints[i].y), Double(pt.x), Double(pt.y));
		if (y_ints[i].x >= pt.x)
		{
			
			++bigger;
		}
	}
	smaller = y_ints.size() - bigger;
	if (debug)
	{
		Debug("%u vertical, %u bigger, %u smaller", y_ints.size(), bigger, smaller);
	}
	if (smaller % 2 == 0 || bigger % 2 == 0)
		return false;
		
		
	return true;
}
Esempio n. 13
0
 void DoubleToStringConverter::DoubleToAscii(double v,
                                             DtoaMode mode,
                                             int requested_digits,
                                             char* buffer,
                                             int buffer_length,
                                             bool* sign,
                                             int* length,
                                             int* point) {
     Vector<char> vector(buffer, buffer_length);
     ASSERT(!Double(v).IsSpecial());
     ASSERT(mode == SHORTEST || requested_digits >= 0);
     
     if (Double(v).Sign() < 0) {
         *sign = true;
         v = -v;
     } else {
         *sign = false;
     }
     
     if (mode == PRECISION && requested_digits == 0) {
         vector[0] = '\0';
         *length = 0;
         return;
     }
     
     if (v == 0) {
         vector[0] = '0';
         vector[1] = '\0';
         *length = 1;
         *point = 1;
         return;
     }
     
     bool fast_worked;
     switch (mode) {
         case SHORTEST:
             fast_worked = FastDtoa(v, FAST_DTOA_SHORTEST, 0, vector, length, point);
             break;
         case FIXED:
             fast_worked = FastFixedDtoa(v, requested_digits, vector, length, point);
             break;
         case PRECISION:
             fast_worked = FastDtoa(v, FAST_DTOA_PRECISION, requested_digits,
                                    vector, length, point);
             break;
         default:
             UNREACHABLE();
             fast_worked = false;
     }
     if (fast_worked) return;
     
     // If the fast dtoa didn't succeed use the slower bignum version.
     BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode);
     BignumDtoa(v, bignum_mode, requested_digits, vector, length, point);
     vector[*length] = '\0';
 }
Esempio n. 14
0
void AngleTest::construct() {
    /* Default constructor */
    constexpr Deg m1;
    constexpr Deg m2{ZeroInit};
    CORRADE_COMPARE(Float(m1), 0.0f);
    CORRADE_COMPARE(Float(m2), 0.0f);
    #ifndef MAGNUM_TARGET_GLES
    constexpr Radd a1;
    constexpr Radd a2{ZeroInit};
    CORRADE_COMPARE(Double(a1), 0.0);
    CORRADE_COMPARE(Double(a2), 0.0);
    #else
    constexpr Rad a1;
    constexpr Rad a2{ZeroInit};
    CORRADE_COMPARE(Float(a1), 0.0f);
    CORRADE_COMPARE(Float(a2), 0.0f);
    #endif

    /* Value constructor */
    constexpr Deg b(25.0);
    CORRADE_COMPARE(Float(b), 25.0f);
    #ifndef MAGNUM_TARGET_GLES
    constexpr Radd n(3.14);
    CORRADE_COMPARE(Double(n), 3.14);
    #else
    constexpr Rad n(3.14);
    CORRADE_COMPARE(Float(n), 3.14f);
    #endif

    /* Copy constructor */
    constexpr Deg c(b);
    CORRADE_COMPARE(c, b);
    #ifndef MAGNUM_TARGET_GLES
    constexpr Radd o(n);
    CORRADE_COMPARE(o, n);
    #else
    constexpr Rad o(n);
    CORRADE_COMPARE(o, n);
    #endif

    /* Conversion operator */
    constexpr Rad p(n);
    CORRADE_COMPARE(Float(p), 3.14f);
    #ifndef MAGNUM_TARGET_GLES
    constexpr Degd d(b);
    CORRADE_COMPARE(Double(d), 25.0);
    #else
    constexpr Deg d(b);
    CORRADE_COMPARE(Float(d), 25.0f);
    #endif
}
Esempio n. 15
0
Real Gaussian_<Real>::cdf(Real x) const
{
    static const Double a1 = 0.31938153, a2 = -0.356563782, a3 = 1.781477937, a4 = -1.821255978, a5 = 1.330274429;
    static const Double sqrtTwoPi = Alge_d::sqrt(Double_::piTwo);

    Double xz = Double(x-mu) / Double(sigma);
    Double L = Alge_d::abs(xz);
    Double K = 1 / (1 + 0.2316419 * L);
    Double w = 1 - 1 / sqrtTwoPi * Alge_d::exp(-L * L / 2) * (a1 * K + a2 * K * K + a3 * Alge_d::pow(K,3) + a4 * Alge_d::pow(K,4) + a5 * Alge_d::pow(K,5));

    if (xz < 0)
        w = 1 - w;
    return w;
}
Esempio n. 16
0
void Selectivity::Validate() {
  parameters_.Populate();
  DoValidate();

  if (length_based_) {
    boost::math::normal dist{ };

    for (unsigned i = 1; i <= n_quant_; ++i) {
      quantiles_.push_back((Double(i) - 0.5) / Double(n_quant_));
      LOG_FINEST() << ": Quantile value = " << quantiles_[i - 1];
      quantiles_at_.push_back(quantile(dist, AS_DOUBLE(quantiles_[i - 1])));
      LOG_FINEST() << ": Normal quantile value = " << quantiles_at_[i - 1];
    }
  }
}
void Check() { // expected-note{{'Check' declared here}}
  if (toFoobar()) Double(7); // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
  if (noFoobar()) Double(7); // expected-error{{use of undeclared identifier 'noFoobar'; did you mean 'barstool::toFoobar'?}}
  if (moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'moreFoobar'; did you mean 'fizbin::nested::moreFoobar'}}
  if (lessFoobar()) Double(7); // expected-error{{use of undeclared identifier 'lessFoobar'; did you mean 'fizbin::nested::lessFoobar'?}}
  if (baztool::toFoobar()) Double(7); // expected-error{{use of undeclared identifier 'baztool'; did you mean 'fizbin::baztool'?}}
  if (nested::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'nested'; did you mean 'fizbin::nested'?}}
  if (dummy::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}}
  if (dummy::mreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}} \
                                     // expected-error{{no member named 'mreFoobar' in 'fizbin::dummy'; did you mean 'moreFoobar'?}}
  if (moFoobin()) Double(7); // expected-error{{use of undeclared identifier 'moFoobin'}}
}
Esempio n. 18
0
//  Choose applicable inaccuracy functions for current game mode and target type
void Player::Inaccuracy(){
	int i = 0;
	if (p_colinmode) {
		switch (p_targettype) {
			case 0: ColinSingle(); break;
			case 1: ColinSingle(); break;
			case 2: ColinDouble(); break;
			case 3: ColinTreble(); break;
			case 4: ColinBull(); break;		
		}
		if (p_targettype == 2 || p_targettype == 3) {
			for (i = 0; boardpoints[i] != p_hit/p_targettype; i++){	
			}
			p_targetindex = i;
		} else if (p_targettype == 0) {
			for (i = 0; boardpoints[i] != p_hit; i++) {		
			}
			p_targetindex = i;
		}
	} else {
		switch (p_targettype) {
			case 0: Single(); break;
			case 1: Bull(); break;
			case 2: Double(); break;
			case 3: Treble(); break;
			case 4: BullsEye(); break;
		}
	}
}
Esempio n. 19
0
void
KalmanFilter1d::Update(const fixed z_abs, const fixed var_z_abs,
                       const fixed dt)
{
  // Some abbreviated constants to make the code line up nicely:
  static constexpr fixed F1 = fixed(1);

  // Validity checks. TODO: more?
  assert(positive(dt));

  // Note: math is not optimized by hand. Let the compiler sort it out.
  // Predict step.
  // Update state estimate.
  x_abs_ += x_vel_ * dt;
  // Update state covariance. The last term mixes in acceleration noise.
  const fixed dt2 = sqr(dt);
  const fixed dt3 = dt * dt2;
  const fixed dt4 = sqr(dt2);
  p_abs_abs_ += Double(dt*p_abs_vel_) + dt2 * p_vel_vel_ + Quarter(var_x_accel_ * dt4);
  p_abs_vel_ += dt * p_vel_vel_ + Half(var_x_accel_ * dt3);
  p_vel_vel_ += var_x_accel_ * dt2;

  // Update step.
  const fixed y = z_abs - x_abs_;  // Innovation.
  const fixed s_inv = F1 / (p_abs_abs_ + var_z_abs);  // Innovation precision.
  const fixed k_abs = p_abs_abs_*s_inv;  // Kalman gain
  const fixed k_vel = p_abs_vel_*s_inv;
  // Update state estimate.
  x_abs_ += k_abs * y;
  x_vel_ += k_vel * y;
  // Update state covariance.
  p_vel_vel_ -= p_abs_vel_*k_vel;
  p_abs_vel_ -= p_abs_vel_*k_abs;
  p_abs_abs_ -= p_abs_abs_*k_abs;
}
Esempio n. 20
0
 bool DoubleToStringConverter::ToFixed(double value,
                                       int requested_digits,
                                       StringBuilder* result_builder) const {
     ASSERT(kMaxFixedDigitsBeforePoint == 60);
     const double kFirstNonFixed = 1e60;
     
     if (Double(value).IsSpecial()) {
         return HandleSpecialValues(value, result_builder);
     }
     
     if (requested_digits > kMaxFixedDigitsAfterPoint) return false;
     if (value >= kFirstNonFixed || value <= -kFirstNonFixed) return false;
     
     // Find a sufficiently precise decimal representation of n.
     int decimal_point;
     bool sign;
     // Add space for the '\0' byte.
     const int kDecimalRepCapacity =
     kMaxFixedDigitsBeforePoint + kMaxFixedDigitsAfterPoint + 1;
     char decimal_rep[kDecimalRepCapacity];
     int decimal_rep_length;
     DoubleToAscii(value, FIXED, requested_digits,
                   decimal_rep, kDecimalRepCapacity,
                   &sign, &decimal_rep_length, &decimal_point);
     
     bool unique_zero = ((flags_ & UNIQUE_ZERO) != 0);
     if (sign && (value != 0.0 || !unique_zero)) {
         result_builder->AddCharacter('-');
     }
     
     CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
                                 requested_digits, result_builder);
     return true;
 }
Esempio n. 21
0
 bool DoubleToStringConverter::ToShortest(double value,
                                          StringBuilder* result_builder) const {
     if (Double(value).IsSpecial()) {
         return HandleSpecialValues(value, result_builder);
     }
     
     int decimal_point;
     bool sign;
     const int kDecimalRepCapacity = kBase10MaximalLength + 1;
     char decimal_rep[kDecimalRepCapacity];
     int decimal_rep_length;
     
     DoubleToAscii(value, SHORTEST, 0, decimal_rep, kDecimalRepCapacity,
                   &sign, &decimal_rep_length, &decimal_point);
     
     bool unique_zero = (flags_ & UNIQUE_ZERO) != 0;
     if (sign && (value != 0.0 || !unique_zero)) {
         result_builder->AddCharacter('-');
     }
     
     int exponent = decimal_point - 1;
     if ((decimal_in_shortest_low_ <= exponent) &&
         (exponent < decimal_in_shortest_high_)) {
         CreateDecimalRepresentation(decimal_rep, decimal_rep_length,
                                     decimal_point,
                                     Max(0, decimal_rep_length - decimal_point),
                                     result_builder);
     } else {
         CreateExponentialRepresentation(decimal_rep, decimal_rep_length, exponent,
                                         result_builder);
     }
     return true;
 }
Esempio n. 22
0
void JG::updateMarginals(bool recompute)
{
	if (marginal_nodes.empty() || recompute){
		marginal_nodes=vector<JGNode*> (copy_of_gm->variables.size());
		int count=0;
		for (int i = 0; i < nodes.size(); i++) {
			for(int j=0;j<nodes[i]->variables().size();j++){
				if (!marginal_nodes[nodes[i]->variables()[j]->id()]){
					marginal_nodes[nodes[i]->variables()[j]->id()]=nodes[i];
					count++;
				}
			}
			if (count==(int)copy_of_gm->variables.size()){
				break;
			}
		}
	}

	marginals=vector<Function> (copy_of_gm->variables.size());
	for(int i=0;i<copy_of_gm->variables.size();i++){
		vector<Variable*> curr_variable;
		curr_variable.push_back(copy_of_gm->variables[i]);
		if(marginal_nodes[i]){
			marginal_nodes[i]->getMarginal(curr_variable,marginals[i]);
		}
		else {
			marginals[i].variables() = curr_variable;
			marginals[i].tableInit(copy_of_gm->variables[i]->domain_size());
			for (int j = 0; j < copy_of_gm->variables[i]->domain_size(); j++) {
				marginals[i].tableEntry(j) = Double((double) 1.0
						/ (double) copy_of_gm->variables[i]->domain_size());
			}
		}
	}
}
Esempio n. 23
0
void
TaskCalculatorPanel::Refresh()
{
  const auto &calculated = CommonInterface::Calculated();
  const TaskStats &task_stats = calculated.ordered_task_stats;

  TCHAR buffer[32];

  if (target_button != nullptr)
    target_button->SetVisible(task_stats.has_targets);

  SetRowVisible(AAT_TIME, task_stats.has_targets);
  if (task_stats.has_targets) {
    FormatTimespanSmart(buffer, (int)protected_task_manager->GetOrderedTaskSettings().aat_min_time, 2);
    SetText(AAT_TIME, buffer);
  }

  FormatTimespanSmart(buffer, (int)task_stats.GetEstimatedTotalTime(), 2);
  SetText(AAT_ESTIMATED, buffer);

  fixed rPlanned = task_stats.total.solution_planned.IsDefined()
    ? task_stats.total.solution_planned.vector.distance
    : fixed(0);

  if (positive(rPlanned))
    LoadValue(DISTANCE, rPlanned, UnitGroup::DISTANCE);
  else
    ClearValue(DISTANCE);

  LoadValue(MC, CommonInterface::GetComputerSettings().polar.glide_polar_task.GetMC(),
            UnitGroup::VERTICAL_SPEED);
  LoadValue(EFFECTIVE_MC, emc, UnitGroup::VERTICAL_SPEED);

  if (positive(rPlanned)) {
    fixed rMax = task_stats.distance_max;
    fixed rMin = task_stats.distance_min;

    if (rMin < rMax) {
      fixed range = Double((rPlanned - rMin) / (rMax - rMin)) - fixed(1);
      LoadValue(RANGE, range * 100);
    } else
      ClearValue(RANGE);
  } else
    ClearValue(RANGE);

  if (task_stats.total.remaining_effective.IsDefined())
    LoadValue(SPEED_REMAINING, task_stats.total.remaining_effective.GetSpeed(),
              UnitGroup::TASK_SPEED);
  else
    ClearValue(SPEED_REMAINING);

  if (task_stats.total.travelled.IsDefined())
    LoadValue(SPEED_ACHIEVED, task_stats.total.travelled.GetSpeed(),
              UnitGroup::TASK_SPEED);
  else
    ClearValue(SPEED_ACHIEVED);

  LoadValue(CRUISE_EFFICIENCY, task_stats.cruise_efficiency * 100);
}
Esempio n. 24
0
double
GlidePolar::SinkRate(const double V, const double n) const
{
  const auto w0 = SinkRate(V);
  const auto vl = VbestLD / std::max(Half(VbestLD), V);
  return std::max(0.,
                  w0 + (V / Double(bestLD)) * (n * n - 1) * vl * vl);
}
Esempio n. 25
0
fixed
GlidePolar::SinkRate(const fixed V, const fixed n) const
{
  const fixed w0 = SinkRate(V);
  const fixed vl = VbestLD / max(half(VbestLD), V);
  return max(fixed_zero,
             w0 + (V / Double(bestLD)) * (sqr(n) - fixed_one) * sqr(vl));
}
Esempio n. 26
0
static inline Angle
EarthDistance(const fixed a)
{
  if (!positive(a))
    return Angle::Zero();

  return Angle::acos(fixed(1) - Double(a));
}
Esempio n. 27
0
fixed
GlidePolar::SinkRate(const fixed V, const fixed n) const
{
  const fixed w0 = SinkRate(V);
  const fixed vl = VbestLD / std::max(Half(VbestLD), V);
  return std::max(fixed(0),
                  w0 + (V / Double(bestLD)) * (sqr(n) - fixed(1)) * sqr(vl));
}
Esempio n. 28
0
namespace FAITriangleRules
{
  /**
   * The minimum leg percentage for "small FAI triangles".
   */
  static constexpr fixed SMALL_MIN_LEG(0.28);

  /**
   * The maximum leg percentage for "small FAI triangles".  This is a
   * derived value, assuming the other two legs are as short as
   * possible.
   */
  static constexpr fixed SMALL_MAX_LEG(fixed(1) - Double(SMALL_MIN_LEG));

  /**
   * The threshold which allows applying the "large FAI triangle"
   * rules [m].
   *
   * Don't use this variable.  Use FAITriangleSettings::GetThreshold()
   * instead.
   *
   * @see FAITriangleSettings::Threshold::FAI
   */
  static constexpr fixed LARGE_THRESHOLD_FAI(750000);

  /**
   * Relaxed threshold used by some contests such as OLC and DMSt.
   *
   * Don't use this variable.  Use FAITriangleSettings::GetThreshold()
   * instead.
   *
   * @see FAITriangleSettings::Threshold::KM500
   */
  static constexpr fixed LARGE_THRESHOLD_500(500000);

  /**
   * The minimum leg percentage for "large FAI triangles".
   */
  static constexpr fixed LARGE_MIN_LEG(0.25);

  /**
   * The maximum leg percentage for "large FAI triangles".
   */
  static constexpr fixed LARGE_MAX_LEG(0.45);

  static constexpr inline fixed LargeMinLeg(fixed total) {
    return Quarter(total);
  }

  gcc_pure
  bool TestDistances(const fixed d1, const fixed d2, const fixed d3,
                     const FAITriangleSettings &settings);

  gcc_pure
  bool TestDistances(const GeoPoint &a, const GeoPoint &b, const GeoPoint &c,
                     const FAITriangleSettings &settings);
}
Esempio n. 29
0
void
UpdateInfoBoxThermal30s(InfoBoxData &data)
{
  SetVSpeed(data, CommonInterface::Calculated().average);

  // Set Color (red/black)
  data.SetValueColor(Double(CommonInterface::Calculated().average) <
      CommonInterface::Calculated().common_stats.current_risk_mc ? 1 : 0);
}
void AO_COS::getSample(const int& variable, int& value, Double& weight,myRandom& random)
{
	Double epsilon(0.01);
	vector<Double> dist(csp->variables[variable]->domain_size());
	Double norm_const;
	for(int i=0;i<dist.size();i++)
	{
		if(cp_algo->isConsistent(variable,i))
		{
			csp->variables[variable]->addr_value()=i;
			int entry=Variable::getAddress(sampling_functions[variable].variables());
			
			dist[i]=sampling_functions[variable].table()[entry];
			norm_const+=dist[i];
			//dist[i]=Double(1.0);
		}
		
		
	}
	//cout<<"Var = "<<variable<<": ";
	//Double norm_const1;
	//for(int i=0;i<dist.size();i++)
	//{
	//	if(dist[i].isZero())
	//		continue;
	//	if((dist[i]/norm_const) < epsilon);
	//	{
	//		dist[i]=epsilon;
	//	}
	//	norm_const1+=dist[i];
	//	//cout<<dist[i]<<" ";
	//}
	for(int i=0;i<dist.size();i++)
		dist[i]/=norm_const;
	/*for(int i=0;i<dist.size();i++)
	{
		dist[i]/=norm_const1;
		
	}
	*/
	//cout<<endl;
	double sampled_value=random.getDouble();
	double cdf=0.0;
	for(int i=0;i<dist.size();i++)
	{
		cdf+=dist[i].value();
		if(cdf >= sampled_value)
		{
			value=i;
			weight=dist[i];
			return;
		}
	}
	//cerr<<"Should not reach here---Rejection problem\n";
	value=0;
	weight=Double();
}