git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@201 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
e60be368b7
commit
8a465f3868
|
@ -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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
|
@ -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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#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
|
|
|
@ -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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
// Libraries
|
|
||||||
#include "IntegrationAlgorithm.h"
|
|
||||||
|
|
||||||
// Namespace
|
|
||||||
using namespace reactphysics3d;
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
IntegrationAlgorithm::IntegrationAlgorithm() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
IntegrationAlgorithm::~IntegrationAlgorithm() {
|
|
||||||
|
|
||||||
}
|
|
|
@ -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 <http://www.gnu.org/licenses/>. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#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
|
|
Loading…
Reference in New Issue
Block a user