当前位置: 首页>>代码示例>>C++>>正文


C++ Double函数代码示例

本文整理汇总了C++中Double函数的典型用法代码示例。如果您正苦于以下问题:C++ Double函数的具体用法?C++ Double怎么用?C++ Double使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Double函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MSG_DEBUG

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);
}
开发者ID:yeKcim,项目名称:warmux,代码行数:34,代码来源:air_attack.cpp

示例2: scale

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;
}
开发者ID:fluxer,项目名称:warmux,代码行数:26,代码来源:picture_widget.cpp

示例3: Print

    // **************************************************************
    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";
    }
开发者ID:nbigaouette,项目名称:memory,代码行数:31,代码来源:LookUpTable.hpp

示例4: CheckFront

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); 
	}
}
开发者ID:pizibing,项目名称:particlelevelsetlibrary,代码行数:33,代码来源:FastMarch2D.cpp

示例5: applyV

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;
}
开发者ID:mogami29,项目名称:cipher-shell,代码行数:35,代码来源:eval.cpp

示例6: assert

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));
}
开发者ID:arne-cl,项目名称:turian-parser,代码行数:7,代码来源:Double.C

示例7:

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())));
}
开发者ID:yalcinerbora,项目名称:GIThesis,代码行数:8,代码来源:IERandom.cpp

示例8: Double

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");
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:9,代码来源:polecat.cpp

示例9: Quat

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())));
}
开发者ID:yalcinerbora,项目名称:GIThesis,代码行数:9,代码来源:IERandom.cpp

示例10: IsLargeSizeDifference

/**
 * 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());
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:14,代码来源:TerrainRenderer.cpp

示例11: bez

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;
}
开发者ID:szmoore,项目名称:ipdf-code,代码行数:57,代码来源:path.cpp

示例12: vector

 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';
 }
开发者ID:emuikernel,项目名称:EAWebKit,代码行数:56,代码来源:double-conversion.cpp

示例13: CORRADE_COMPARE

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
}
开发者ID:Asuzer,项目名称:magnum,代码行数:51,代码来源:AngleTest.cpp

示例14: Double

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;
}
开发者ID:srish13,项目名称:Honeycomb,代码行数:14,代码来源:Gaussian.cpp

示例15: Check

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'}}
}
开发者ID:melanierk,项目名称:Harmony-PBV,代码行数:12,代码来源:missing-namespace-qualifier-typo-corrections.cpp


注:本文中的Double函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。