From dd2ca4e5d075705e96e6cbd2b687383b1421e02a Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Sat, 7 Nov 2009 16:24:49 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@208 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../integration/ExplicitEuler.cpp | 16 +++++++------- .../integration/ExplicitEuler.h | 22 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/sources/reactphysics3d/integration/ExplicitEuler.cpp b/sources/reactphysics3d/integration/ExplicitEuler.cpp index 38614711..f2d1430a 100644 --- a/sources/reactphysics3d/integration/ExplicitEuler.cpp +++ b/sources/reactphysics3d/integration/ExplicitEuler.cpp @@ -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(); diff --git a/sources/reactphysics3d/integration/ExplicitEuler.h b/sources/reactphysics3d/integration/ExplicitEuler.h index 71edade4..ffd00aa6 100644 --- a/sources/reactphysics3d/integration/ExplicitEuler.h +++ b/sources/reactphysics3d/integration/ExplicitEuler.h @@ -17,33 +17,35 @@ * along with ReactPhysics3D. If not, see . * ***************************************************************************/ -#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 };