00001 #ifndef SimTK_SIMBODY_FORCE_H_
00002 #define SimTK_SIMBODY_FORCE_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "SimTKcommon.h"
00035 #include "simbody/internal/common.h"
00036 #include "simbody/internal/GeneralForceSubsystem.h"
00037
00038 namespace SimTK {
00039
00040 class SimbodyMatterSubsystem;
00041 class GeneralForceSubsystem;
00042 class MobilizedBody;
00043 class Force;
00044 class ForceImpl;
00045
00046
00047
00048 #ifndef SimTK_SIMBODY_DEFINING_FORCE
00049 extern template class PIMPLHandle<Force, ForceImpl, true>;
00050 #endif
00051
00057 class SimTK_SIMBODY_EXPORT Force : public PIMPLHandle<Force, ForceImpl, true> {
00058 public:
00059 Force() { }
00060 explicit Force(ForceImpl* r) : HandleBase(r) { }
00061
00063 ForceIndex getForceIndex() const;
00064
00065 class TwoPointLinearSpring;
00066 class TwoPointLinearDamper;
00067 class TwoPointConstantForce;
00068 class MobilityLinearSpring;
00069 class MobilityLinearDamper;
00070 class MobilityConstantForce;
00071 class ConstantForce;
00072 class ConstantTorque;
00073 class GlobalDamper;
00074 class UniformGravity;
00075 class Custom;
00076
00077 class TwoPointLinearSpringImpl;
00078 class TwoPointLinearDamperImpl;
00079 class TwoPointConstantForceImpl;
00080 class MobilityLinearSpringImpl;
00081 class MobilityLinearDamperImpl;
00082 class MobilityConstantForceImpl;
00083 class ConstantForceImpl;
00084 class ConstantTorqueImpl;
00085 class GlobalDamperImpl;
00086 class UniformGravityImpl;
00087 class CustomImpl;
00088 };
00089
00101 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearSpring : public Force {
00102 public:
00114 TwoPointLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real k, Real x0);
00115 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearSpring, TwoPointLinearSpringImpl, Force);
00116 };
00117
00130 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearDamper: public Force {
00131 public:
00142 TwoPointLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real damping);
00143 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearDamper, TwoPointLinearDamperImpl, Force);
00144 };
00145
00157 class SimTK_SIMBODY_EXPORT Force::TwoPointConstantForce: public Force {
00158 public:
00169 TwoPointConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real force);
00170 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointConstantForce, TwoPointConstantForceImpl, Force);
00171 };
00172
00184 class SimTK_SIMBODY_EXPORT Force::MobilityLinearSpring : public Force {
00185 public:
00195 MobilityLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real k, Real q0);
00196 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityLinearSpring, MobilityLinearSpringImpl, Force);
00197 };
00198
00209 class SimTK_SIMBODY_EXPORT Force::MobilityLinearDamper : public Force {
00210 public:
00219 MobilityLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real damping);
00220 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityLinearDamper, MobilityLinearDamperImpl, Force);
00221 };
00222
00233 class SimTK_SIMBODY_EXPORT Force::MobilityConstantForce : public Force {
00234 public:
00243 MobilityConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real force);
00244 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityConstantForce, MobilityConstantForceImpl, Force);
00245 };
00246
00254 class SimTK_SIMBODY_EXPORT Force::ConstantForce: public Force {
00255 public:
00256 ConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& station, const Vec3& force);
00257 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantForce, ConstantForceImpl, Force);
00258 };
00259
00267 class SimTK_SIMBODY_EXPORT Force::ConstantTorque: public Force {
00268 public:
00269 ConstantTorque(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& torque);
00270 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantTorque, ConstantTorqueImpl, Force);
00271 };
00272
00287 class SimTK_SIMBODY_EXPORT Force::GlobalDamper : public Force {
00288 public:
00289 GlobalDamper(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, Real damping);
00290 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(GlobalDamper, GlobalDamperImpl, Force);
00291 };
00292
00299 class SimTK_SIMBODY_EXPORT Force::UniformGravity : public Force {
00300 public:
00301 UniformGravity(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, const Vec3& g, Real zeroHeight=0);
00302 Vec3 getGravity() const;
00303 void setGravity(const Vec3& g);
00304 Real getZeroHeight() const;
00305 void setZeroHeight(Real height);
00306 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(UniformGravity, UniformGravityImpl, Force);
00307 };
00308
00338 class SimTK_SIMBODY_EXPORT Force::Custom : public Force {
00339 public:
00340 class Implementation;
00349 Custom(GeneralForceSubsystem& forces, Implementation* implementation);
00350 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Custom, CustomImpl, Force);
00351 protected:
00352 const Implementation& getImplementation() const;
00353 Implementation& updImplementation();
00354 };
00355
00356 class SimTK_SIMBODY_EXPORT Force::Custom::Implementation {
00357 public:
00358 virtual ~Implementation() { }
00370 virtual void calcForce(const State& state, Vector_<SpatialVec>& bodyForces, Vector_<Vec3>& particleForces, Vector& mobilityForces) const = 0;
00376 virtual Real calcPotentialEnergy(const State& state) const = 0;
00382 virtual bool dependsOnlyOnPositions() const {
00383 return false;
00384 }
00389 virtual void realizeTopology(State& state) const {
00390 }
00391 virtual void realizeModel(State& state) const {
00392 }
00393 virtual void realizeInstance(const State& state) const {
00394 }
00395 virtual void realizeTime(const State& state) const {
00396 }
00397 virtual void realizePosition(const State& state) const {
00398 }
00399 virtual void realizeVelocity(const State& state) const {
00400 }
00401 virtual void realizeDynamics(const State& state) const {
00402 }
00403 virtual void realizeAcceleration(const State& state) const {
00404 }
00405 virtual void realizeReport(const State& state) const {
00406 }
00408 };
00409
00410 }
00411
00412 #endif // SimTK_SIMBODY_FORCE_H_