From 320913007c7bd97831157a78a0d198ac18ac5fd4 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Sat, 7 Mar 2009 14:40:14 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@111 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/body/BodyState.cpp | 6 +++--- sources/reactphysics3d/body/BodyState.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sources/reactphysics3d/body/BodyState.cpp b/sources/reactphysics3d/body/BodyState.cpp index 980983c4..70533a88 100644 --- a/sources/reactphysics3d/body/BodyState.cpp +++ b/sources/reactphysics3d/body/BodyState.cpp @@ -39,7 +39,7 @@ BodyState::BodyState(const BodyState& bodyState) : position(bodyState.position), linearMomentum(bodyState.linearMomentum), orientation(bodyState.orientation), angularMomentum(bodyState.angularMomentum), linearVelocity(bodyState.linearVelocity), angularVelocity(bodyState.angularVelocity), spin(bodyState.spin), inertiaTensorInverse(bodyState.inertiaTensorInverse), - massInverse(bodyState.massInverse) { + massInverse(bodyState.massInverse), force(bodyState.force) { } // Destructor @@ -86,11 +86,11 @@ void BodyState::computeAtTime(const Time& timeStep, const DerivativeBodyState& l // Return the force on the body at time t Vector3D BodyState::computeForce(Time time) const { // TODO : Implement this method - return Vector3D(0.0, 0.0, 0.0); + return force + Vector3D(0.0, 0.0, 0.0); } // Return the torque on the body at time Vector3D BodyState::computeTorque(Time time) const { // TODO : Implement this method - return Vector3D(0.0, 0.0 ,0.0); + return force + Vector3D(0.0, 0.0 ,0.0); } diff --git a/sources/reactphysics3d/body/BodyState.h b/sources/reactphysics3d/body/BodyState.h index 8ce52f84..09d95c47 100644 --- a/sources/reactphysics3d/body/BodyState.h +++ b/sources/reactphysics3d/body/BodyState.h @@ -40,6 +40,7 @@ class BodyState { Vector3D linearMomentum; // Linear momentum of the body Quaternion orientation; // Orientation quaternion of the body Vector3D angularMomentum; // Angular momentum of the body + Vector3D force; // force on the body // Secondary values Vector3D linearVelocity; // Linear velocity of the body @@ -68,6 +69,8 @@ class BodyState { Quaternion getSpin() const; // Return the spin of the body void setMassInverse(Kilogram massInverse); // Set the inverse of the mass void setInertiaTensorInverse(const Matrix3x3& inertiaTensorInverse); // Set the inverse of the inertia tensor + Vector3D getForce() const; // Return the force over the body + void setForce(const Vector3D force); // Set the force over the body void recalculate(); // Recalculate the secondary values // of the BodyState from the primary ones @@ -144,6 +147,17 @@ inline void BodyState::setInertiaTensorInverse(const Matrix3x3& inertiaTensorInv this->inertiaTensorInverse = inertiaTensorInverse; } +// Return the force over the body +inline Vector3D BodyState::getForce() const { + return force; } +// Set the force over the body +inline void BodyState::setForce(const Vector3D force) { + this->force = force; + +} + +} // End of the ReactPhysics3D namespace + #endif