本文整理汇总了C++中Force类的典型用法代码示例。如果您正苦于以下问题:C++ Force类的具体用法?C++ Force怎么用?C++ Force使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Force类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyForces
void ParticleSystem::applyForces()
{
if ( gravity.length() > 0.0f )
{
for ( int i = 0; i < mParticles.size(); ++i )
{
Particle* p = mParticles[i];
p->mAcc += gravity;
}
}
for ( int i = 0; i < mParticles.size(); ++i )
{
Particle* p = mParticles[i];
p->mAcc -= p->mVel * drag;
}
for ( int i = 0; i < mSprings.size(); i++ )
{
Spring* f = mSprings[i];
f->apply();
}
for ( int i = 0; i < attractions.size(); i++ )
{
Attraction* f = attractions[i];
f->apply();
}
for ( int i = 0; i < customForces.size(); i++ )
{
Force* f = customForces[i];
f->apply();
}
}
示例2: TotalForceLength
float RuntimeObject::TotalForceLength() const {
Force ForceMoyenne;
ForceMoyenne.SetX(TotalForceX());
ForceMoyenne.SetY(TotalForceY());
return ForceMoyenne.GetLength();
}
示例3: getForce
sf::Vector3f Force::produitVectoriel(Force vect)
{
sf::Vector3f vect3d;
vect3d.x = 0;
vect3d.y = 0;
vect3d.z = getForce().x*vect.getForce().y-getForce().y*vect.getForce().x;
return vect3d;
}
示例4: SetCollide
S_Chicken::S_Chicken( )
{
AABox* aabox = new AABox;
aabox->SetSize( CHICKEN_WIDTH_DEPTH, CHICKEN_HEIGHT, CHICKEN_WIDTH_DEPTH );
SetCollide( aabox );
Force* force = new Force;
force->SetMaxVelocity( 3.0f );
SetMoveForce( force );
}
示例5: updateDisplayer
void OpenSimContext::updateDisplayer(Force& f) {
// If muscle or force acting along a path then call respective updateDisplayer otherwise do nothing for now
realizeVelocity();
if (dynamic_cast<Muscle*>(&f)!= NULL)
return dynamic_cast<Muscle*>(&f)->updateDisplayer(*_configState);
if (f.hasGeometryPath()){
AbstractProperty& pathProp = f.updPropertyByName("GeometryPath");
Object& pathObj = pathProp.updValueAsObject();
return dynamic_cast<GeometryPath*>(&pathObj)->updateDisplayer(*_configState);
}
if (f.getDisplayer()!= NULL)
f.updateDisplayer(*_configState);
}
示例6: calculateNewPosition
void calculateNewPosition(double delta_t) {
Force resultant = getResultantForce();
// cout << "Resultant Force " << resultant.getDir().getX() << " " << resultant.getDir().getY() << endl;
Vec2D accel(resultant.getX() / _mass, resultant.getY() / _mass);
// cout << "Acceleration " << accel.getX() << " " << accel.getY() << endl;
Vec2D newPos = _pos + _vel * delta_t;
Vec2D newVel = _vel + accel * delta_t;
// cout << "Position " << newPos.getX() << " " << newPos.getY() << endl;
// cout << "Velocity " << newVel.getX() << " " << newVel.getY() << endl;
setPos(newPos);
setVel(newVel);
}
示例7: adoptForce
ForceIndex adoptForce(Force& force) {
invalidateSubsystemTopologyCache();
const ForceIndex index((int) forces.size());
forces.push_back(new Force()); // grow
Force& f = *forces.back(); // refer to the empty handle we just created
force.disown(f); // transfer ownership to f
return index;
}
示例8: options
int ImbalanceGroup::options(int narg, char **arg)
{
Error *error = _lmp->error;
Force *force = _lmp->force;
Group *group = _lmp->group;
if (narg < 3) error->all(FLERR,"Illegal balance weight command");
_num = force->inumeric(FLERR,arg[0]);
if (_num < 1) error->all(FLERR,"Illegal balance weight command");
if (2*_num+1 > narg) error->all(FLERR,"Illegal balance weight command");
_id = new int[_num];
_factor = new double[_num];
for (int i = 0; i < _num; ++i) {
_id[i] = group->find(arg[2*i+1]);
if (_id[i] < 0)
error->all(FLERR,"Unknown group in balance weight command");
_factor[i] = force->numeric(FLERR,arg[2*i+2]);
}
return 2*_num+1;
}
示例9: irr_simd_firr
static void irr_simd_firr(
const int addr,
_out_ double accout[3],
_out_ double jrkout[3],
_out_ int &nnbid)
{
const Particle *ptcl = ::ptcl;
const v2df tnow = ::vec_tnow;
const int nnb = list[addr].nnb;
Force force;
force.clear();
const Pred4 pri(Predictor(ptcl[addr], tnow));
for(int k=0; k<nnb; k++){
const int jaddr = list[addr].nb[k];
ptcl[jaddr].prefetch();
}
for(int k=0; k<nnb; k+=4){
const int *jptr = &(list[addr].nb[k]);
const Predictor p0(ptcl[jptr[0]], tnow);
const Predictor p1(ptcl[jptr[1]], tnow);
const Predictor p2(ptcl[jptr[2]], tnow);
const Predictor p3(ptcl[jptr[3]], tnow);
const Pred4 prj(p0, p1, p2, p3);
assert(0 == (size_t)jptr % 16);
v4sf idx = *(v4sf *)jptr;
force.calc_and_accum(pri, prj, idx);
}
force.write(accout, jrkout, nnbid);
}
示例10: CalcReaction
void GroupT::CalcReaction()
{
double SumFx=0;
double SumFy=0;
double SumTorque=0;
for (list<Force *>::iterator f = s1->forces.begin(); f!=s1->forces.end(); f++)
{
Force *x = *f;
if(x->IsCalculatedx())
SumFx+=x->GetForcex();
if(x->IsCalculatedy())
SumFy+=x->GetForcey();
if(x->IsCalculatedt())
SumTorque+=x->GetForcet();
}
O->R1->SetForce(-SumFx,-SumFy,0);
O->R2->SetForce(SumFx,SumFy,0);
}
示例11: getAngular
static Vector3 getAngular(const Force & self) { return self.angular(); }
示例12: setLinear
static void setLinear(Force & self, const Vector3 & f) { self.linear(f); }
示例13: getLinear
static Vector3 getLinear(const Force & self ) { return self.linear(); }
示例14: getinitargs
static
boost::python::tuple
getinitargs(const Force & f)
{ return bp::make_tuple((Vector3)f.linear(),(Vector3)f.angular()); }
示例15:
const Eigen::Matrix<double, 1, 1>
operator*( const Force& f ) const
{
return ref.axis.transpose()*f.angular();
}