本文整理汇总了C++中ParticleList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleList::push_back方法的具体用法?C++ ParticleList::push_back怎么用?C++ ParticleList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleList
的用法示例。
在下文中一共展示了ParticleList::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resample
void ParticleFilterLocalizer::resample() {
ParticleList resampledParticles;
int particleCount = (int)particles.size();
int index = Math::randomInt(0, particleCount - 1);
float beta = 0.0f;
float maxProbability = 1.0f;
for (int i = 0; i < particleCount; i++) {
beta += Math::randomFloat() * 2.0f * maxProbability;
while (beta > particles[index]->probability) {
beta -= particles[index]->probability;
index = (index + 1) % particleCount;
}
resampledParticles.push_back(new Particle(
particles[index]->x,
particles[index]->y,
particles[index]->orientation,
particles[index]->probability
));
}
for (ParticleList::const_iterator it = particles.begin(); it != particles.end(); it++) {
delete *it;
}
particles.clear();
particles = resampledParticles;
}
示例2: removeLostParticles
void Cell::removeLostParticles(ParticleList &lost) {
for (ParticleList::iterator it = particles.begin(); it != particles.end();) {
const Particle &particle = *it;
if (!isInside(particle)) { // particle moved outside of cell
lost.push_back(particle); // add to lost
it = particles.erase(it); // erase particle
} else
it++;
}
}
示例3: SeedParticles
static void SeedParticles(ParticleList& list, float dt)
{
static float time = 0;
time += dt;
unsigned int num_new = (unsigned int) (time * ParticlesPerSecond);
if (num_new == 0)
return;
time = 0;
list.reserve(list.size() + num_new);
for (unsigned int i = 0; i < num_new; ++i) {
float theta = randhashf(Seed++, 0, M_PI * 2);
float r = randhashf(Seed++, 0, SeedRadius);
float y = randhashf(Seed++, 0, InitialBand);
Particle p;
p.Px = r*std::cos(theta);
p.Py = PlumeBase + y;
p.Pz = r*std::sin(theta) + 0.125f; // Nudge the emitter towards the viewer
p.ToB = Time;
list.push_back(p);
}
}
示例4: main
//.........这里部分代码省略.........
while(iter != my_particles.end())
{
particle_t *curr_particle = &(*iter);
curr_particle->ax = 0;
curr_particle->ay = 0;
apply_force(curr_particle, cells);
++iter;
}
reference_particles.clear();
ParticleList out_of_bounds;
out_of_bounds.clear();
ParticleList bounds;
bounds.clear();
iter = my_particles.begin();
/*
Iterate through all my particles and send all particles that are not our responsibility
any longer to other processes. Send first and last row particles as references to other
processes aswell.
*/
while(iter != my_particles.end())
{
move(*iter);
Point p = get_cell_index(*iter);
if(p.y < top_row || p.y >= bottom_row) // check if out of bounds
{
particle_t tmp = (*iter);
int index = out_of_bounds.size();
out_of_bounds.push_back(tmp);
iter = my_particles.erase(iter);
// send to process above or below
int target = (p.y < top_row)? rank-1 : rank+1;
MPI_Request request;
MPI_Isend(&out_of_bounds[index], 1, PARTICLE, target, NEW, MPI_COMM_WORLD, &request ); // non blocking send
continue;
}
else if(p.y == top_row && top_row > 0) // send our top row particles to the process above except if we are root
{
particle_t tmp = (*iter);
int index = bounds.size();
bounds.push_back(tmp);
MPI_Request request;
MPI_Isend(&bounds[index], 1, PARTICLE, rank-1, BOUND, MPI_COMM_WORLD, &request ); // non blocking send
}
else if(p.y == bottom_row-1 && rank < n_proc-1) // send our top row particles to the process below except if we are last
{
particle_t tmp = (*iter);
int index = bounds.size();
bounds.push_back(tmp);
MPI_Request request;
MPI_Isend(&bounds[index], 1, PARTICLE, rank+1, BOUND, MPI_COMM_WORLD, &request ); // non blocking send
}
++iter;
示例5: spawn
//.........这里部分代码省略.........
p.mOriginalPosition = p.mPosition;
p.mNodeOriginalPosition = m.applyToOrigin();
Matrix mtxX;
{
Quaternion q;
q.fromAngleAxis(randomReal(0,latitude * TwoPI / 360.f), Vector3::AxisX);
mtxX.make(Vector3::Zero, Vector3::One, q);
}
Matrix mtxY;
{
Quaternion q;
q.fromAngleAxis(randomReal(0,TwoPI), Vector3::AxisY);
mtxY.make(Vector3::Zero, Vector3::One, q);
}
Matrix rot;
rot.multiply(mtxX, mtxY);
p.mVelocity = rot.applyVector(Vector3(0,1,0));
p.mVelocity.normalise();
p.mVelocity = m.applyVectorNormal(p.mVelocity);
p.mVelocity *= speed;
p.mAge = 0.0f;
if(mLifeSpan < mLifeVar)
p.mLife = mLifeSpan;
else
p.mLife= randomReal(mLifeSpan - mLifeVar, mLifeSpan + mLifeVar);
p.mGravity = mGravity.getFrame(at);
p.mExplosiveForce = mExplosiveForce.getFrame(at);
//每个粒子的缩放比例都可能不同
p.mScale.x = randomReal(mScale.x - mScaleVar.x, mScale.x + mScaleVar.x);
if(mFixedSize)
{
p.mScale.y = p.mScale.z = p.mScale.x;
}
else
{
p.mScale.y = randomReal(mScale.y - mScaleVar.y, mScale.y + mScaleVar.y);
p.mScale.z = randomReal(mScale.z - mScaleVar.z, mScale.z + mScaleVar.z);
}
//粒子旋转的角度
p.mAngle = randomReal(mInitAngleBegin, mInitAngleEnd);
p.mRotateSpeed = randomReal(mRotateSpeed - mRotateSpeedVar, mRotateSpeed + mRotateSpeedVar) * timeFactor * 15.0f;
if(mHead)
{
p.mHeadFramesNum = ((mHeadLifeSpan.y - mHeadLifeSpan.x + 1.0f) * mHeadLifeSpan.z);
p.mHeadDecalFramesNum = ((mHeadDecay.y - mHeadDecay.x + 1.0f) * mHeadDecay.z);
}
else
{
p.mHeadFramesNum = 0;
p.mHeadDecalFramesNum = 0;
}
if(mTail)
{
p.mTailFramesNum = ((mTailLifeSpan.y - mTailLifeSpan.x + 1.0f) * mTailLifeSpan.z);
p.mTailDecalFramesNum = ((mTailDecay.y - mTailDecay.x + 1.0f) * mTailDecay.z);
}
else
{
p.mTailFramesNum = 0;
p.mTailDecalFramesNum = 0;
}
if(mWander)
{
p.mWanderRadius = mWanderRadius;
p.mWanderSpeed = mWanderSpeed;
p.mWander = true;
p.mWanderS = 0.0f;
Matrix m1,m2;
for(int i = 0;i < 4;i++)
{
{
Quaternion q;
q.fromAngleAxis(randomReal(0,TwoPI), Vector3::AxisX);
m1.make(Vector3::Zero, Vector3::One, q);
}
{
Quaternion q;
q.fromAngleAxis(randomReal(0,TwoPI), Vector3::AxisY);
m2.make(Vector3::Zero, Vector3::One, q);
}
Matrix mt;
mt.multiply(m1, m2);
p.mWanderCatmullRom[i] = mWanderRadius * (mt.applyVector(Vector3::AxisZ));
}
}
//
ps.push_back(p);
//
mCurrentEmission -= 1.0f;
}
}