git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@208 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
3667a9b291
commit
dd2ca4e5d0
|
@ -18,35 +18,35 @@
|
|||
***************************************************************************/
|
||||
|
||||
// Libraries
|
||||
#include "Euler.h"
|
||||
#include "ExplicitEuler.h"
|
||||
|
||||
// We want to use the ReactPhysics3D namespace
|
||||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
Euler::Euler() {
|
||||
ExplicitEuler::ExplicitEuler() {
|
||||
|
||||
}
|
||||
|
||||
// Copy-constructor
|
||||
Euler::Euler(const Euler& euler) {
|
||||
ExplicitEuler::ExplicitEuler(const ExplicitEuler& euler) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Euler::~Euler() {
|
||||
ExplicitEuler::~ExplicitEuler() {
|
||||
|
||||
}
|
||||
|
||||
// Integrate a body state over time. This method use the Euler integration algorithm
|
||||
void Euler::integrate(BodyState& bodyState, const Time& time, const Time& timeStep) {
|
||||
// Integrate a body state over time. This method use the explicit Euler integration algorithm
|
||||
void ExplicitEuler::integrate(BodyState& bodyState, const Time& time, const Time& timeStep) {
|
||||
double dt = timeStep.getValue(); // Timestep
|
||||
|
||||
// Compute the integrated body state
|
||||
bodyState.setPosition(bodyState.getPosition() + bodyState.getLinearVelocity() * dt);
|
||||
bodyState.setLinearMomentum(bodyState.getLinearMomentum() + bodyState.computeForce(time) * dt);
|
||||
bodyState.setLinearMomentum(bodyState.getLinearMomentum() + bodyState.getForce() * dt);
|
||||
bodyState.setOrientation(bodyState.getOrientation() + bodyState.getSpin() * dt);
|
||||
bodyState.setAngularMomentum(bodyState.getAngularMomentum() + bodyState.computeTorque(time) * dt);
|
||||
bodyState.setAngularMomentum(bodyState.getAngularMomentum() + bodyState.getTorque() * dt);
|
||||
|
||||
// Recalculate the secondary values of the body state
|
||||
bodyState.recalculate();
|
||||
|
|
|
@ -17,33 +17,35 @@
|
|||
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EULER_H
|
||||
#define EULER_H
|
||||
#ifndef EXPLICITEULER_H
|
||||
#define EXPLICITEULER_H
|
||||
|
||||
// Libraries
|
||||
#include "IntegrationAlgorithm.h"
|
||||
#include "../body/BodyState.h"
|
||||
#include "../body/DerivativeBodyState.h"
|
||||
|
||||
// TODO : Test explicit-Euler integrator (change has been made : computeForce(time) and computeTorque(time)
|
||||
// replaced by getForce() and getTorque().
|
||||
|
||||
// Namespace ReactPhysics3D
|
||||
namespace reactphysics3d {
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Class Euler :
|
||||
Class ExplicitEuler :
|
||||
This class will be used to solve the differential equation of
|
||||
movement by integrating a body state. This class implements
|
||||
the Euler algorithm. It's important to undersand that Euler
|
||||
the explicit Euler algorithm. It's important to undersand that this
|
||||
algorithm should be used only for testing purpose because the
|
||||
Euler algorithm is not a good one.
|
||||
explicit Euler algorithm can be unstable.
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
class Euler : public IntegrationAlgorithm {
|
||||
class ExplicitEuler : public IntegrationAlgorithm {
|
||||
private :
|
||||
|
||||
public :
|
||||
Euler(); // Constructor
|
||||
Euler(const Euler& euler); // Copy-constructor
|
||||
virtual ~Euler(); // Destructor
|
||||
ExplicitEuler(); // Constructor
|
||||
ExplicitEuler(const ExplicitEuler& euler); // Copy-constructor
|
||||
virtual ~ExplicitEuler(); // Destructor
|
||||
|
||||
void integrate(BodyState& bodyState, const Time& t, const Time& dt); // Integrate a body state over time
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user