Simbody
3.4 (development)
|
00001 #ifndef SimTK_SIMBODY_FORCE_GRAVITY_H_ 00002 #define SimTK_SIMBODY_FORCE_GRAVITY_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm) * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2010-13 Stanford University and the Authors. * 00013 * Authors: Michael Sherman * 00014 * Contributors: * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00027 #include "SimTKcommon.h" 00028 #include "simbody/internal/Force.h" 00029 00035 namespace SimTK { 00036 00067 class SimTK_SIMBODY_EXPORT Force::Gravity : public Force { 00068 public: 00069 00070 00071 //------------------------------------------------------------------------------ 00084 00085 00122 Gravity(GeneralForceSubsystem& forces, 00123 const SimbodyMatterSubsystem& matter, 00124 const UnitVec3& down, 00125 Real g, 00126 Real zeroHeight = 0); 00127 00155 Gravity(GeneralForceSubsystem& forces, 00156 const SimbodyMatterSubsystem& matter, 00157 const Vec3& gravity); 00158 00183 Gravity(GeneralForceSubsystem& forces, 00184 const SimbodyMatterSubsystem& matter, 00185 Real g); 00186 00188 Gravity() {} 00189 00207 Gravity& setDefaultBodyIsExcluded(MobilizedBodyIndex mobod, bool isExcluded); 00208 00218 Gravity& setDefaultGravityVector(const Vec3& gravity); 00219 00228 Gravity& setDefaultDownDirection(const UnitVec3& down); 00233 Gravity& setDefaultDownDirection(const Vec3& down) 00234 { return setDefaultDownDirection(UnitVec3(down)); } 00235 00246 Gravity& setDefaultMagnitude(Real g); 00247 00256 Gravity& setDefaultZeroHeight(Real zeroHeight); 00257 00267 bool getDefaultBodyIsExcluded(MobilizedBodyIndex mobod) const; 00270 Vec3 getDefaultGravityVector() const; 00273 const UnitVec3& getDefaultDownDirection() const; 00275 Real getDefaultMagnitude() const; 00278 Real getDefaultZeroHeight() const; 00279 00284 //------------------------------------------------------------------------------ 00300 00317 const Gravity& setBodyIsExcluded(State& state, MobilizedBodyIndex mobod, 00318 bool isExcluded) const; 00319 00333 const Gravity& setGravityVector(State& state, const Vec3& gravity) const; 00334 00346 const Gravity& setDownDirection(State& state, 00347 const UnitVec3& down) const; 00351 const Gravity& setDownDirection(State& state, 00352 const Vec3& down) const 00353 { return setDownDirection(state, UnitVec3(down)); } 00354 00364 const Gravity& setMagnitude(State& state, Real g) const; 00375 const Gravity& setZeroHeight(State& state, Real hz) const; 00376 00388 bool getBodyIsExcluded(const State& state, MobilizedBodyIndex mobod) const; 00397 Vec3 getGravityVector(const State& state) const; 00405 const UnitVec3& getDownDirection(const State& state) const; 00413 Real getMagnitude(const State& state) const; 00422 Real getZeroHeight(const State& state) const; 00423 00428 //------------------------------------------------------------------------------ 00437 00448 Real getPotentialEnergy(const State& state) const; 00449 00472 const Vector_<SpatialVec>& getBodyForces(const State& state) const; 00473 00485 const SpatialVec& 00486 getBodyForce(const State& state, MobilizedBodyIndex mobod) const 00487 { return getBodyForces(state)[mobod]; } 00488 00489 // Particles aren't supported yet so don't show this in Doxygen. 00496 const Vector_<Vec3>& getParticleForces(const State& state) const; 00499 00501 //------------------------------------------------------------------------------ 00513 long long getNumEvaluations() const; 00514 00518 bool isForceCacheValid(const State& state) const; 00519 00523 void invalidateForceCache(const State& state) const; 00526 // Don't show this in Doxygen. 00528 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Gravity, GravityImpl, Force); 00530 }; 00531 00532 } // namespace SimTK 00533 00534 #endif // SimTK_SIMBODY_FORCE_GRAVITY_H_