5-adding_general_force
D’ALEMBERT’S PRINCIPLE
For particles D’Alembert’s principle implies that, if we have a set of forces acting on an object, we can replace all those forces with a single force, which is calculated by
\[f = \sum\limits_{i} f_{i}
\]
In other words, we simply add the forces together using vector addition, and we apply the single force that results.
FORCE GENERATORS
class ParticleForceGenerator
{
public:
/**
* Overload this in implementations of the interface to calculate
* and update the force applied to the given particle.
*/
virtual void updateForce(Particle *particle, real duration) = 0; //更新每个粒子的加速度
};
A GRAVITY FORCE GENERATOR
class ParticleGravity : public ParticleForceGenerator
{
/** Holds the acceleration due to gravity. */
Vector3 gravity;
public:
/** Creates the generator with the given acceleration. */
ParticleGravity(const Vector3 &gravity);
/** Applies the gravitational force to the given particle. */
virtual void updateForce(Particle *particle, real duration);
};
posted on 2024-03-13 14:51 Ultraman_X 阅读(10) 评论(0) 收藏 举报