diff --git a/sources/reactphysics3d/integration/Euler.cpp b/sources/reactphysics3d/integration/Euler.cpp deleted file mode 100644 index 38614711..00000000 --- a/sources/reactphysics3d/integration/Euler.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2009 Daniel Chappuis * - **************************************************************************** - * This file is part of ReactPhysics3D. * - * * - * ReactPhysics3D is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published * - * by the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * ReactPhysics3D is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with ReactPhysics3D. If not, see . * - ***************************************************************************/ - -// Libraries -#include "Euler.h" - -// We want to use the ReactPhysics3D namespace -using namespace reactphysics3d; - -// Constructor -Euler::Euler() { - -} - -// Copy-constructor -Euler::Euler(const Euler& euler) { - -} - -// Destructor -Euler::~Euler() { - -} - -// Integrate a body state over time. This method use the Euler integration algorithm -void Euler::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.setOrientation(bodyState.getOrientation() + bodyState.getSpin() * dt); - bodyState.setAngularMomentum(bodyState.getAngularMomentum() + bodyState.computeTorque(time) * dt); - - // Recalculate the secondary values of the body state - bodyState.recalculate(); -} diff --git a/sources/reactphysics3d/integration/Euler.h b/sources/reactphysics3d/integration/Euler.h deleted file mode 100644 index 71edade4..00000000 --- a/sources/reactphysics3d/integration/Euler.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -#ifndef EULER_H -#define EULER_H - -// Libraries -#include "IntegrationAlgorithm.h" -#include "../body/BodyState.h" -#include "../body/DerivativeBodyState.h" - -// Namespace ReactPhysics3D -namespace reactphysics3d { - -/* ------------------------------------------------------------------- - Class Euler : - 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 - algorithm should be used only for testing purpose because the - Euler algorithm is not a good one. - ------------------------------------------------------------------- -*/ -class Euler : public IntegrationAlgorithm { - private : - - public : - Euler(); // Constructor - Euler(const Euler& euler); // Copy-constructor - virtual ~Euler(); // Destructor - - void integrate(BodyState& bodyState, const Time& t, const Time& dt); // Integrate a body state over time -}; - -} - -#endif diff --git a/sources/reactphysics3d/integration/ExplicitEuler.cpp b/sources/reactphysics3d/integration/ExplicitEuler.cpp deleted file mode 100644 index 193934ec..00000000 --- a/sources/reactphysics3d/integration/ExplicitEuler.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2009 Daniel Chappuis * - **************************************************************************** - * This file is part of ReactPhysics3D. * - * * - * ReactPhysics3D is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published * - * by the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * ReactPhysics3D is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with ReactPhysics3D. If not, see . * - ***************************************************************************/ - -// Libraries -#include "ExplicitEuler.h" - -// We want to use the ReactPhysics3D namespace -using namespace reactphysics3d; - -// Constructor -ExplicitEuler::ExplicitEuler() { - -} - -// Copy-constructor -ExplicitEuler::ExplicitEuler(const ExplicitEuler& euler) { - -} - -// Destructor -ExplicitEuler::~ExplicitEuler() { - -} - -// 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.getExternalForce() * dt); - bodyState.setOrientation(bodyState.getOrientation() + bodyState.getSpin() * dt); - bodyState.setAngularMomentum(bodyState.getAngularMomentum() + bodyState.getExternalTorque() * 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 deleted file mode 100644 index ffd00aa6..00000000 --- a/sources/reactphysics3d/integration/ExplicitEuler.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -#ifndef EXPLICITEULER_H -#define EXPLICITEULER_H - -// Libraries -#include "IntegrationAlgorithm.h" -#include "../body/BodyState.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 ExplicitEuler : - This class will be used to solve the differential equation of - movement by integrating a body state. This class implements - the explicit Euler algorithm. It's important to undersand that this - algorithm should be used only for testing purpose because the - explicit Euler algorithm can be unstable. - ------------------------------------------------------------------- -*/ -class ExplicitEuler : public IntegrationAlgorithm { - private : - - public : - 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 -}; - -} - -#endif diff --git a/sources/reactphysics3d/integration/IntegrationAlgorithm.cpp b/sources/reactphysics3d/integration/IntegrationAlgorithm.cpp deleted file mode 100644 index 9490229b..00000000 --- a/sources/reactphysics3d/integration/IntegrationAlgorithm.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -// Libraries -#include "IntegrationAlgorithm.h" - -// Namespace -using namespace reactphysics3d; - -// Constructor -IntegrationAlgorithm::IntegrationAlgorithm() { - -} - -// Destructor -IntegrationAlgorithm::~IntegrationAlgorithm() { - -} diff --git a/sources/reactphysics3d/integration/IntegrationAlgorithm.h b/sources/reactphysics3d/integration/IntegrationAlgorithm.h deleted file mode 100644 index 669fec5c..00000000 --- a/sources/reactphysics3d/integration/IntegrationAlgorithm.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -#ifndef INTEGRATIONALGORITHM_H -#define INTEGRATIONALGORITHM_H - -// Libraries -#include "../body/BodyState.h" -#include "../physics/physics.h" - -// ReactPhysics3D namespace -namespace reactphysics3d { - -class IntegrationAlgorithm { - private : - - public : - IntegrationAlgorithm(); // Constructor - virtual ~IntegrationAlgorithm(); // Destructor - - virtual void integrate(BodyState& bodyState, const Time& t, const Time& dt)=0; // Integrate a body state over time -}; - -} // End of the ReactPhysics3D namespace - -#endif diff --git a/sources/reactphysics3d/integration/RungeKutta4.cpp b/sources/reactphysics3d/integration/RungeKutta4.cpp deleted file mode 100644 index b97db75c..00000000 --- a/sources/reactphysics3d/integration/RungeKutta4.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2009 Daniel Chappuis * - **************************************************************************** - * This file is part of ReactPhysics3D. * - * * - * ReactPhysics3D is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published * - * by the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * ReactPhysics3D is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with ReactPhysics3D. If not, see . * - ***************************************************************************/ - -// Libraries -#include "RungeKutta4.h" -#include - -// We want to use the ReactPhysics3D namespace -using namespace reactphysics3d; - -// Constructor -RungeKutta4::RungeKutta4() { - -} - -// Copy-constructor -RungeKutta4::RungeKutta4(const RungeKutta4& rk4) { - -} - -// Destructor -RungeKutta4::~RungeKutta4() { - -} - -// Compute a derivative body state at time t -DerivativeBodyState RungeKutta4::evaluate(const BodyState& bodyState, const Time& time) { - - // Compute the derivaties values at time t - Vector3D linearVelocity = bodyState.getLinearVelocity(); - Vector3D force = bodyState.computeForce(time); - Vector3D torque = bodyState.computeTorque(time); - Quaternion spin = bodyState.getSpin(); - - // Return the derivative body state at time t - return DerivativeBodyState(linearVelocity, force, torque, spin); -} - -// Compute a derivative body state at time t + dt according to the last derivative body state -DerivativeBodyState RungeKutta4::evaluate(BodyState bodyState, const Time& time, const Time& timeStep, - const DerivativeBodyState& lastDerivativeBodyState) { - // Compute the bodyState at time t + dt - bodyState.computeAtTime(timeStep, lastDerivativeBodyState); - - // Compute the derivaties values at time t - Vector3D linearVelocity = bodyState.getLinearVelocity(); - Vector3D force = bodyState.computeForce(time + timeStep); - Vector3D torque = bodyState.computeTorque(time + timeStep); - Quaternion spin = bodyState.getSpin(); - - // Return the derivative body state at time t - return DerivativeBodyState(linearVelocity, force, torque, spin); -} - -// Integrate a body state over time. This method use the RK4 integration algorithm -void RungeKutta4::integrate(BodyState& bodyState, const Time& time, const Time& timeStep) { - - // Compute the 4 derivatives body states at different time values. - DerivativeBodyState a = evaluate(bodyState, time); - DerivativeBodyState b = evaluate(bodyState, time, timeStep*0.5, a); - DerivativeBodyState c = evaluate(bodyState, time, timeStep*0.5, b); - DerivativeBodyState d = evaluate(bodyState, time, timeStep, c); - - double dt = timeStep.getValue(); // Timestep - - // Compute the integrated body state - bodyState.setPosition(bodyState.getPosition() + (a.getLinearVelocity() + (b.getLinearVelocity() + c.getLinearVelocity()) * 2.0 + - d.getLinearVelocity()) * (1.0/6.0) * dt); - bodyState.setLinearMomentum(bodyState.getLinearMomentum() + (a.getForce() + (b.getForce() + c.getForce())*2.0 + d.getForce()) * (1.0/6.0) * dt); - bodyState.setOrientation(bodyState.getOrientation() + (a.getSpin() + (b.getSpin() + c.getSpin())*2.0 + d.getSpin()) * (1.0/6.0) * dt); - bodyState.setAngularMomentum(bodyState.getAngularMomentum() + (a.getTorque() + (b.getTorque() + c.getTorque())*2.0 + d.getTorque()) * (1.0/6.0) * dt); - - // Recalculate the secondary values of the body state - bodyState.recalculate(); -} diff --git a/sources/reactphysics3d/integration/RungeKutta4.h b/sources/reactphysics3d/integration/RungeKutta4.h deleted file mode 100644 index f5914a7b..00000000 --- a/sources/reactphysics3d/integration/RungeKutta4.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -#ifndef RUNGEKUTTA4_H -#define RUNGEKUTTA4_H - -// Libraries -#include "IntegrationAlgorithm.h" -#include "../body/BodyState.h" -#include "../body/DerivativeBodyState.h" - -// Namespace ReactPhysics3D -namespace reactphysics3d { - -/* ------------------------------------------------------------------- - Class RungeKutta4 : - This class will be used to solve the differential equation of - movement by integrating a body state. This class implements - the Runge-Kutta 4 (RK4) integrator. Notice that that this - integrator use an evaluation of the body state at a future time. - Therefore this integrator cannot be used for collision engine - for now. Because if collisions can occur, it difficult to - predict the state of the body at a future time. - ------------------------------------------------------------------- -*/ -class RungeKutta4 : public IntegrationAlgorithm { - private : - DerivativeBodyState evaluate(const BodyState& bodyState, const Time& time); // Compute a derivative body state - DerivativeBodyState evaluate(BodyState bodyState, const Time& time, - const Time& timeStep, const DerivativeBodyState& lastDerivativeBodyState); // Compute a derivative body state - - public : - RungeKutta4(); // Constructor - RungeKutta4(const RungeKutta4& rk4); // Copy-constructor - virtual ~RungeKutta4(); // Destructor - - void integrate(BodyState& bodyState, const Time& t, const Time& dt); // Integrate a body state over time -}; - -} - -#endif diff --git a/sources/reactphysics3d/integration/SemiImplicitEuler.cpp b/sources/reactphysics3d/integration/SemiImplicitEuler.cpp deleted file mode 100644 index d3d8c220..00000000 --- a/sources/reactphysics3d/integration/SemiImplicitEuler.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2009 Daniel Chappuis * - **************************************************************************** - * This file is part of ReactPhysics3D. * - * * - * ReactPhysics3D is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published * - * by the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * ReactPhysics3D is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with ReactPhysics3D. If not, see . * - ***************************************************************************/ - -// Libraries -#include "SemiImplicitEuler.h" - -// We want to use the ReactPhysics3D namespace -using namespace reactphysics3d; - -// Constructor -SemiImplicitEuler::SemiImplicitEuler() { - -} - -// Copy-constructor -SemiImplicitEuler::SemiImplicitEuler(const SemiImplicitEuler& euler) { - -} - -// Destructor -SemiImplicitEuler::~SemiImplicitEuler() { - -} - -// Integrate a body state over time. This method use the semi-implicit Euler integration algorithm -void SemiImplicitEuler::integrate(BodyState& bodyState, const Time& time, const Time& timeStep) { - double dt = timeStep.getValue(); // Timestep - - // Compute the integrated body state - bodyState.setLinearMomentum(bodyState.getLinearMomentum() + bodyState.getExternalForce() * dt); - bodyState.setAngularMomentum(bodyState.getAngularMomentum() + bodyState.getExternalTorque() * dt); - - // Recalculate the secondary values of the body state - bodyState.recalculate(); - - // Compute the integrated position and orientation - bodyState.setPosition(bodyState.getPosition() + bodyState.getLinearVelocity() * dt); - bodyState.setOrientation(bodyState.getOrientation() + bodyState.getSpin() * dt); -} - diff --git a/sources/reactphysics3d/integration/SemiImplicitEuler.h b/sources/reactphysics3d/integration/SemiImplicitEuler.h deleted file mode 100644 index c9d5a66f..00000000 --- a/sources/reactphysics3d/integration/SemiImplicitEuler.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -* Copyright (C) 2009 Daniel Chappuis * -**************************************************************************** -* This file is part of ReactPhysics3D. * -* * -* ReactPhysics3D is free software: you can redistribute it and/or modify * -* it under the terms of the GNU Lesser General Public License as published * -* by the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* ReactPhysics3D is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with ReactPhysics3D. If not, see . * -***************************************************************************/ - -#ifndef SEMIIMPLICITEULER_H -#define SEMIIMPLICITEULER_H - -// Libraries -#include "IntegrationAlgorithm.h" -#include "../body/BodyState.h" - -// Namespace ReactPhysics3D -namespace reactphysics3d { - -// TODO : Test the semi-implicit Euler - -/* ------------------------------------------------------------------- - Class SemiImplicitEuler : - This class will be used to solve the differential equation of - movement by integrating a body state. This class implements - the semi-implicit Euler algorithm. It's a first order integrator - algorithm and it's always stable. - ------------------------------------------------------------------- -*/ -class SemiImplicitEuler : public IntegrationAlgorithm { - private : - - public : - SemiImplicitEuler(); // Constructor - SemiImplicitEuler(const SemiImplicitEuler& euler); // Copy-constructor - virtual ~SemiImplicitEuler(); // Destructor - - void integrate(BodyState& bodyState, const Time& t, const Time& dt); // Integrate a body state over time -}; - -} - -#endif -