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


C++ Velocity类代码示例

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


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

示例1: WCV_interval

// Assumes 0 <= B < T
LossData WCV_tvar::WCV_interval(const Vect3& so, const Velocity& vo, const Vect3& si, const Velocity& vi, double B, double T) const {
  double time_in = T;
  double time_out = B;

  Vect2 so2 = so.vect2();
  Vect2 si2 = si.vect2();
  Vect2 s2 = so2.Sub(si2);
  Vect2 vo2 = vo.vect2();
  Vect2 vi2 = vi.vect2();
  Vect2 v2 = vo2.Sub(vi2);
  double sz = so.z-si.z;
  double vz = vo.z-vi.z;

  Interval ii = wcv_vertical->vertical_WCV_interval(table.getZTHR(),table.getTCOA(),B,T,sz,vz);

  if (ii.low > ii.up) {
    return LossData(time_in,time_out);
  }
  Vect2 step = v2.ScalAdd(ii.low,s2);
  if (Util::almost_equals(ii.low,ii.up)) { // [CAM] Changed from == to almost_equals to mitigate numerical problems
    if (horizontal_WCV(step,v2)) {
      time_in = ii.low;
      time_out = ii.up;
    }
    return LossData(time_in,time_out);
  }
  LossData ld = horizontal_WCV_interval(ii.up-ii.low,step,v2);
  time_in = ld.getTimeIn() + ii.low;
  time_out = ld.getTimeOut() + ii.low;
  return LossData(time_in,time_out);
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: SolveAccelerationProblems1

void SolveAccelerationProblems1()
{
  //1. A flower pot falls from a windowsill 25.0 m above the sidewalk.   
  //   How much time does a person below have to move out of the way?  
  //   How fast is the flower pot moving when it strikes the ground? 
  Meter const potfalls( 25. );
  SquareSecond const falloffsquaretime = (potfalls * 2.) / Acceleration3( 9.8 );
  Second const rep1 = sqrt( falloffsquaretime );
  Velocity const rep1_2 = potfalls / rep1;
  Scalar const _rep1 = rep1.GetValue();
  Scalar const _rep1_2 = rep1_2.GetValue();
  Assert( fequal( _rep1, 2.2587697572631282 ) );
  Assert( fequal( _rep1_2, 11.067971810589327  ) );

  //2. A plane, starting from rest at one end of a runway, undergoes a 
  //   constant acceleration of 1.6 m/s2 for a distance of 1600 m before 
  //   takeoff.  What is its speed upon takeoff?  What is the time required 
  //   for takeoff?
  Meter const planedistance( 1600. );
  SquareSecond const squaretime2 = (planedistance * 2.) / Acceleration3( 1.6 );
  Second const rep2 = sqrt( squaretime2 );
  Velocity const rep2_2 = planedistance / rep2;
  Scalar const _rep2 = rep2.GetValue();
  Scalar const _rep2_2 = rep2_2.GetValue(); 
  Assert( fequal( _rep2, 44.721359549995796 ) );
  Assert( fequal( _rep2_2, 35.777087639996637 ) );

}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: interact

/**********************************************************
 * SHIP :: interact()
 ***********************************************************/
void Ship :: interact(const Interface & pUI, void * asteroids)
{
   orientation += pUI.isLeft() * TURN_RADIUS;
   orientation -= pUI.isRight() * TURN_RADIUS;

   if (pUI.isUp())
   {
      thrustOn = true;
      Velocity thrust;
      thrust.setDx(THRUST *std::cos(deg2rad(orientation + 90)));
      thrust.setDy(THRUST * std::sin(deg2rad(orientation + 90)));
      v += thrust;
   }
   else
      thrustOn = false;
   
   if (pUI.isSpace())
   {
      Asteroids * pAsteroids = (Asteroids *)asteroids;
      pAsteroids->addItem(new Bullet(v, orientation));
      
   }

   
}
开发者ID:hjcoder18,项目名称:Asteroids-Game,代码行数:28,代码来源:ship.cpp

示例4: start

void Receiver1D::removeDirectArrival(const Source& source,
    const Velocity& velocity, float t_width)
{
  float dt = this->getDt();
  int half_len = t_width / dt;

  /// get the velocity average in a range
  int z_min = std::min(source.getDepth(), this->getDepth());
  int z_max = std::max(source.getDepth(), this->getDepth());

  int s[] = {z_min, 0};
  int e[] = {z_max, velocity.getNx()};

  std::vector<int> start(s, s + 2);
  std::vector<int> end(e, e + 2);
  float vel_avg = velocity.getAverageRange(start, end);

  const int nx = this->getGeometryDim()[0];
  for (int ix = 0; ix < nx; ix++) {
    std::vector<int> currRcvLoc, sourceLoc;
    sourceLoc.push_back(source.getDepth());
    sourceLoc.push_back(source.getGeometryOrigin()[0]);
    currRcvLoc.push_back(getDepth());
    currRcvLoc.push_back(getGeometryOrigin()[0] + getGeometryDelta()[0] * ix);
    const float dist2 = variance(sourceLoc, currRcvLoc);

    int tstart = std::sqrt(dist2 * vel_avg);
    int tend = ((tstart + 2 * half_len) > this->getNt()) ? this->getNt() : (tstart + 2 * half_len);

    float *p = &mData[ix * getNt()];
    std::fill(p + tstart, p + tend, 0);
  }

}
开发者ID:conghui,项目名称:congreyhee,代码行数:34,代码来源:receiver1d.cpp

示例5: MediumRock

/**********************************************************
 * MEDIUMROCK constructor
 ***********************************************************/
MediumRock :: MediumRock(Velocity bigV)
{
   setPoint(bigV.getX(), bigV.getY());
   
   v.setDx(random(-MED_SPEED, MED_SPEED));
   v.setDy(random(-MED_SPEED, MED_SPEED));
   v += bigV;
}
开发者ID:hjcoder18,项目名称:Asteroids-Game,代码行数:11,代码来源:rock.cpp

示例6: SmallRock

/**********************************************************
 * SMALLROCK constructor
 ***********************************************************/
SmallRock :: SmallRock(Velocity biggerV)
{
   setPoint(biggerV.getX(), biggerV.getY());

   v.setDx(random(-SM_SPEED, SM_SPEED));
   v.setDy(random(-SM_SPEED, SM_SPEED));
   v += biggerV;
}
开发者ID:hjcoder18,项目名称:Asteroids-Game,代码行数:11,代码来源:rock.cpp

示例7: principia__BubbleVelocityCorrection

XYZ principia__BubbleVelocityCorrection(Plugin const* const plugin,
                                        int const reference_body_index) {
  journal::Method<journal::BubbleVelocityCorrection> m({plugin,
                                                        reference_body_index});
  CHECK_NOTNULL(plugin);
  Velocity<World> const result =
      plugin->BubbleVelocityCorrection(reference_body_index);
  return m.Return(ToXYZ(result.coordinates() / (Metre / Second)));
}
开发者ID:pdn4kd,项目名称:Principia,代码行数:9,代码来源:interface.cpp

示例8: conflict

bool KinematicIntegerBands::conflict(Detection3D* det, const Vect3& so, const Velocity& vo, const Vect3& si, const Velocity& vi,
    double B, double T) {
  if (Util::almost_equals(B,T)) {
    Vect3 sot = vo.ScalAdd(B,so);
    Vect3 sit = vi.ScalAdd(B,si);
    return det->violation(sot,vo,sit,vi);
  }
  return det->conflict(so,vo,si,vi,B,T);
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9:

std::pair<LatLonAlt,Velocity> KinematicsLatLon::vsAccel(const LatLonAlt& so, const Velocity& vo,  double t, double a) {
	double dist = vo.gs()*t;
	double currentTrk = vo.trk();
	LatLonAlt sn = GreatCircle::linear_initial(so, currentTrk, dist);
	double nsz = so.alt() + vo.z*t + 0.5*a*t*t;
	sn = sn.mkAlt(nsz);
	Velocity  vn = vo.mkVs(vo.z + a*t);
	return std::pair<LatLonAlt,Velocity>(sn,vn);
}
开发者ID:nasa,项目名称:WellClear,代码行数:9,代码来源:KinematicsLatLon.cpp

示例10: violation

bool WCV_tvar::violation(const Vect3& so, const Velocity& vo, const Vect3& si, const Velocity& vi) const {
  Vect2 so2 = so.vect2();
  Vect2 si2 = si.vect2();
  Vect2 s2 = so2.Sub(si2);
  Vect2 vo2 = vo.vect2();
  Vect2 vi2 = vi.vect2();
  Vect2 v2 = vo2.Sub(vi2);
  return horizontal_WCV(s2,v2) &&
      wcv_vertical->vertical_WCV(table.getZTHR(),table.getTCOA(),so.z-si.z,vo.z-vi.z);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例11: getControl

Velocity PlanningProblem::getControl(uint i)
{
    Velocity c;
    if(i < trajec.length()) {
        Station st = trajec.getStation(i);
        c = st.getVelocity();
    }
    else
        c.setZero();
    return c;
}
开发者ID:amiryanj,项目名称:cyrus_ssl,代码行数:11,代码来源:planningproblem.cpp

示例12: move

void Item::move()
{
   Velocity     v = this->getVelocity();
   Point    slope = v.getSlope();
   Point location = this->getLocation();

   location.addX(slope.getX());
   location.addY(slope.getY());

   this->setLocation(location);
}
开发者ID:scanalyzer,项目名称:skeet2,代码行数:11,代码来源:item.cpp

示例13: getRandomVelocity

    Velocity Solver::getRandomVelocity()
    {
        Velocity velocity;

        for (int i = 0; i < currentProblem->n; ++i) {
            double randomVariable = getRandomDoubleValue(0.0, 1.0);

            velocity.push_back(randomVariable);
        }

        return velocity;
    }
开发者ID:JeGa,项目名称:mknap_pso,代码行数:12,代码来源:Solver.cpp

示例14: getRandomIntegerValue

    void Solver::findSolution()
    {
        for (auto &i : swarm.getParticles()) {
            Velocity newVelocity;
            Solution newPosition;

            /**
             * Iterate through all dimensions of a Solution/position
             * to calculate the new velocity and update the position.
             *
             * j = dimension
             */
            for (int j = 0; j < currentProblem->n; ++j) {
                int currentPositionD = i.getPosition().at(j);
                double currentVelocityD = i.getVelocity().at(j);

                int pBestD = i.getBestPosition().at(j);
                int gBestD = swarm.getBestPosition().at(j);

                int randomParticleNumber = getRandomIntegerValue(0, 1);
                int randomGlobalNumber = getRandomIntegerValue(0, 1);

                double newVelocityD = parameters.getInertiaWeight() * currentVelocityD +
                                      parameters.getConstant1() * randomParticleNumber * (pBestD - currentPositionD) +
                                      parameters.getConstant2() * randomGlobalNumber * (gBestD - currentPositionD);

                if (newVelocityD > parameters.getVMax())
                    newVelocityD = parameters.getVMax();
                else if (newVelocityD < -parameters.getVMax())
                    newVelocityD = -parameters.getVMax();

                int newPositionD = updateStrategy->updatePosition(currentPositionD, newVelocityD);

                newVelocity.push_back(newVelocityD);
                newPosition.push_back(newPositionD);
            }

            i.setVelocity(newVelocity);
            i.setPosition(newPosition);

            int pBestTmp = calculateProfit(i.getPosition());
            pBestTmp -= calculatePenalty(i.getPosition(), pBestTmp);

            // Update pBest and gBest position/solution
            if (pBestTmp > i.getBestValue()) {
                i.setBestPositionAndValue(i.getPosition(), pBestTmp);

                if (pBestTmp > swarm.getBestValue())
                    swarm.setBestPositionAndValue(i.getPosition(), pBestTmp);
            }
        }
    }
开发者ID:JeGa,项目名称:mknap_pso,代码行数:52,代码来源:Solver.cpp

示例15: createProjection

std::pair<Position,Velocity> ProjectedKinematics::gsAccel(const Position& so, const Velocity& vo, double t, double a) {
	Vect3 s3 = so.point();
	if (so.isLatLon()) {
		s3 = Projection::createProjection(so.lla().zeroAlt()).project(so);
	}
	Vect3 pres = Kinematics::gsAccelPos(s3,vo,t,a);
	Velocity vres = Velocity::mkTrkGsVs(vo.trk(),vo.gs()+a*t,vo.vs());
	if (so.isLatLon()) {
		return Projection::createProjection(so.lla().zeroAlt()).inverse(pres,vres,true);
	} else {
		return std::pair<Position,Velocity>(Position(pres), vres);
	}
}
开发者ID:E-LLP,项目名称:WellClear,代码行数:13,代码来源:ProjectedKinematics.cpp


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