Simbody

Force_Gravity.h

Go to the documentation of this file.
00001 #ifndef SimTK_SIMBODY_FORCE_GRAVITY_H_
00002 #define SimTK_SIMBODY_FORCE_GRAVITY_H_
00003 /* -------------------------------------------------------------------------- *
00004  *                      SimTK Core: SimTK Simbody(tm)                         *
00005  * -------------------------------------------------------------------------- *
00006  * This is part of the SimTK Core biosimulation toolkit originating from      *
00007  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00008  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00009  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
00010  *                                                                            *
00011  * Portions copyright (c) 2010 Stanford University and the Authors.           *
00012  * Authors: Michael Sherman                                                   *
00013  * Contributors:                                                              *
00014  *                                                                            *
00015  * Permission is hereby granted, free of charge, to any person obtaining a    *
00016  * copy of this software and associated documentation files (the "Software"), *
00017  * to deal in the Software without restriction, including without limitation  *
00018  * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
00019  * and/or sell copies of the Software, and to permit persons to whom the      *
00020  * Software is furnished to do so, subject to the following conditions:       *
00021  *                                                                            *
00022  * The above copyright notice and this permission notice shall be included in *
00023  * all copies or substantial portions of the Software.                        *
00024  *                                                                            *
00025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
00026  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
00027  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
00028  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
00029  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
00030  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
00031  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
00032  * -------------------------------------------------------------------------- */
00033 
00034 #include "SimTKcommon.h"
00035 #include "simbody/internal/Force.h"
00036 
00042 namespace SimTK {
00043 
00069 class SimTK_SIMBODY_EXPORT Force::Gravity : public Force {
00070 public:
00071 
00072 
00073 //------------------------------------------------------------------------------
00086 
00107 Gravity(GeneralForceSubsystem&          forces, 
00108         const SimbodyMatterSubsystem&   matter,
00109         const Vec3&                     gravity);
00110 
00142 Gravity(GeneralForceSubsystem&          forces, 
00143         const SimbodyMatterSubsystem&   matter,
00144         const UnitVec3&                 down,
00145         Real                            g,
00146         Real                            zeroHeight = 0);
00147 
00160 Gravity& setDefaultGravityVector(const Vec3& gravity);
00161 
00170 Gravity& setDefaultDownDirection(const UnitVec3& down);
00175 Gravity& setDefaultDownDirection(const Vec3& down)
00176 {   return setDefaultDownDirection(UnitVec3(down)); }
00177 
00188 Gravity& setDefaultMagnitude(Real g);
00189 
00198 Gravity& setDefaultZeroHeight(Real zeroHeight);
00199 
00202 Vec3 getDefaultGravityVector() const;
00205 const UnitVec3& getDefaultDownDirection() const;
00207 Real getDefaultMagnitude() const;
00210 Real getDefaultZeroHeight() const;
00211 
00216 //------------------------------------------------------------------------------
00232 
00246 const Gravity& setGravityVector(State& state, const Vec3& gravity) const;
00247 
00259 const Gravity& setDownDirection(State&           state,
00260                                 const UnitVec3&  down) const;
00264 const Gravity& setDownDirection(State&          state,
00265                                 const Vec3&     down) const
00266 {   return setDownDirection(state, UnitVec3(down)); }
00267 
00277 const Gravity& setMagnitude(State& state, Real g) const;
00288 const Gravity& setZeroHeight(State& state, Real hz) const;
00289 
00298 Vec3 getGravityVector(const State& state) const;
00306 const UnitVec3& getDownDirection(const State& state) const;
00314 Real getMagnitude(const State& state) const;
00323 Real getZeroHeight(const State& state) const;
00324 
00329 //------------------------------------------------------------------------------
00338 
00349 Real getPotentialEnergy(const State& state) const;
00358 const SpatialVec& 
00359     getBodyForce(const State& state, MobilizedBodyIndex mobod) const;
00360 
00361 // Particles aren't supported yet so don't show this in Doxygen.
00369 const Vec3& 
00370     getParticleForce(const State& state, ParticleIndex particle) const;
00373 
00375 // Don't show this in Doxygen.
00377 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Gravity, GravityImpl, Force);
00379 };
00380 
00381 } // namespace SimTK
00382 
00383 #endif // SimTK_SIMBODY_FORCE_GRAVITY_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines