本文整理匯總了C++中Box2D::getYL方法的典型用法代碼示例。如果您正苦於以下問題:C++ Box2D::getYL方法的具體用法?C++ Box2D::getYL怎麽用?C++ Box2D::getYL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Box2D
的用法示例。
在下文中一共展示了Box2D::getYL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: addDensity
void MCnucl::addDensity(Nucleus* nucl, double** dens)
{
vector<Particle*> participant = nucl->getParticipants();
for(unsigned int ipart=0; ipart<participant.size(); ipart++)
{
Particle* part = participant[ipart];
Box2D partBox = part->getBoundingBox();
double x = part->getX();
double y = part->getY();
int x_idx_left = (int)((partBox.getXL() - Xmin)/dx);
int x_idx_right = (int)((partBox.getXR() - Xmin)/dx);
int y_idx_left = (int)((partBox.getYL() - Ymin)/dy);
int y_idx_right = (int)((partBox.getYR() - Ymin)/dy);
if(x_idx_left < 0 || y_idx_left < 0 || x_idx_left > Maxx || y_idx_left > Maxy)
{
cerr << "Wounded nucleon extends out of grid bounds " << "("<< part->getX() << "," << part->getY() << ")" << endl;
}
x_idx_left = max(0, x_idx_left);
x_idx_right = min(Maxx, x_idx_right);
y_idx_left = max(0, y_idx_left);
y_idx_right = min(Maxy, y_idx_right);
for(int ir = x_idx_left; ir < x_idx_right; ir++)
{
double xg = Xmin + ir*dx;
for(int jr = y_idx_left; jr < y_idx_right; jr++)
{
double yg = Ymin + jr*dy;
double dc = (x-xg)*(x-xg) + (y-yg)*(y-yg);
if (shape_of_entropy==1) // "Checker" nucleons:
{
if(dc>dsq)
continue;
double areai = 10.0/siginNN;
dens[ir][jr] += areai*participant[ipart]->getFluctfactor();
}
else if (shape_of_entropy>=2 && shape_of_entropy<=9) // Gaussian nucleons:
{
double density;
if (shape_of_entropy == 3)
{
density = participant[ipart]->getFluctuatedDensity(xg,yg);
}
else
{
density = participant[ipart]->getSmoothDensity(xg,yg);
}
dens[ir][jr] += density;
}
}
}
}
}
示例2: getBinaryCollision
// --- find participants from proj/target and the number of binary coll. ---
int MCnucl::getBinaryCollision()
{
bool missingNucleus = false;
// Handling for the intrinsic nucleus case
if(proj->getAtomic() == 0)
{
vector<Particle*> nucl2 = targ->getNucleons();
missingNucleus = true;
for(int i = 0; i < (int)nucl2.size(); i++){
selectFluctFactors(nucl2[i]);
nucl2[i]->addCollidingParticle(nucl2[i]);
targ->markWounded(nucl2[i]);
}
}
else if(targ->getAtomic() == 0)
{
vector<Particle*> nucl1 = proj->getNucleons();
missingNucleus = true;
for(int i = 0; i < (int)nucl1.size(); i++){
selectFluctFactors(nucl1[i]);
nucl1[i]->addCollidingParticle(nucl1[i]);
proj->markWounded(nucl1[i]);
}
}
else
{
vector<Particle*> projNucleons = proj->getNucleons();
vector<Particle*> targNucleons = targ->getNucleons();
int startingIndex = 0;
for(int iproj = 0; iproj < projNucleons.size(); iproj++)
{
Particle* projPart = projNucleons[iproj];
Box2D projBox = projPart->getBoundingBox();
Box2D targBox;
// Skip the left most nucleons for each proj nucleon.
while(startingIndex < targNucleons.size())
{
targBox = targNucleons[startingIndex]->getBoundingBox();
if(targBox.getXR() >= projBox.getXL())
break;
startingIndex++;
}
// Actually test a collision for the next ones,
// until they get too far away.
int i = startingIndex;
while(i < targNucleons.size()
&& projBox.getXR() >= targBox.getXL() )
{
Particle* targPart = targNucleons[i];
targBox = targPart->getBoundingBox();
if(projBox.getYL() <= targBox.getYR())
{
if(projBox.getYR() >= targBox.getYL())
{
// Now we know the boxes do overlap in x and y.
if(hit(projPart,targPart))
{
selectFluctFactors(projPart);
selectFluctFactors(targPart);
projPart->addCollidingParticle(targPart);
targPart->addCollidingParticle(projPart);
proj->markWounded(projPart);
targ->markWounded(targPart);
}
}
}
i++;
}
// Continue loop over projBoxes
}
// Exit hit detection
}
createBinaryCollisions();
Npart1=proj->getNpart();
Npart2=targ->getNpart();
Npart1 /= overSample;
Npart2 /= overSample;
if(missingNucleus)
return 1;
else
return binaryCollision.size();
}