Simbody
3.5
|
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 00070 class SimTK_SIMBODY_EXPORT Force::Gravity : public Force { 00071 public: 00072 00073 00074 //------------------------------------------------------------------------------ 00087 00088 00125 Gravity(GeneralForceSubsystem& forces, 00126 const SimbodyMatterSubsystem& matter, 00127 const UnitVec3& down, 00128 Real g, 00129 Real zeroHeight = 0); 00130 00158 Gravity(GeneralForceSubsystem& forces, 00159 const SimbodyMatterSubsystem& matter, 00160 const Vec3& gravity); 00161 00186 Gravity(GeneralForceSubsystem& forces, 00187 const SimbodyMatterSubsystem& matter, 00188 Real g); 00189 00191 Gravity() {} 00192 00210 Gravity& setDefaultBodyIsExcluded(MobilizedBodyIndex mobod, bool isExcluded); 00211 00221 Gravity& setDefaultGravityVector(const Vec3& gravity); 00222 00231 Gravity& setDefaultDownDirection(const UnitVec3& down); 00236 Gravity& setDefaultDownDirection(const Vec3& down) 00237 { return setDefaultDownDirection(UnitVec3(down)); } 00238 00249 Gravity& setDefaultMagnitude(Real g); 00250 00259 Gravity& setDefaultZeroHeight(Real zeroHeight); 00260 00270 bool getDefaultBodyIsExcluded(MobilizedBodyIndex mobod) const; 00273 Vec3 getDefaultGravityVector() const; 00276 const UnitVec3& getDefaultDownDirection() const; 00278 Real getDefaultMagnitude() const; 00281 Real getDefaultZeroHeight() const; 00282 00287 //------------------------------------------------------------------------------ 00304 00323 const Gravity& setBodyIsExcluded(State& state, MobilizedBodyIndex mobod, 00324 bool isExcluded) const; 00325 00341 const Gravity& setGravityVector(State& state, const Vec3& gravity) const; 00342 00356 const Gravity& setDownDirection(State& state, 00357 const UnitVec3& down) const; 00361 const Gravity& setDownDirection(State& state, 00362 const Vec3& down) const 00363 { return setDownDirection(state, UnitVec3(down)); } 00364 00378 const Gravity& setMagnitude(State& state, Real g) const; 00379 00392 const Gravity& setZeroHeight(State& state, Real hz) const; 00393 00406 bool getBodyIsExcluded(const State& state, MobilizedBodyIndex mobod) const; 00415 Vec3 getGravityVector(const State& state) const; 00423 const UnitVec3& getDownDirection(const State& state) const; 00431 Real getMagnitude(const State& state) const; 00440 Real getZeroHeight(const State& state) const; 00441 00446 //------------------------------------------------------------------------------ 00455 00466 Real getPotentialEnergy(const State& state) const; 00467 00492 const Vector_<SpatialVec>& getBodyForces(const State& state) const; 00493 00505 const SpatialVec& 00506 getBodyForce(const State& state, MobilizedBodyIndex mobod) const 00507 { return getBodyForces(state)[mobod]; } 00508 00509 // Particles aren't supported yet so don't show this in Doxygen. 00516 const Vector_<Vec3>& getParticleForces(const State& state) const; 00519 00521 //------------------------------------------------------------------------------ 00533 long long getNumEvaluations() const; 00534 00538 bool isForceCacheValid(const State& state) const; 00539 00543 void invalidateForceCache(const State& state) const; 00546 // Don't show this in Doxygen. 00548 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Gravity, GravityImpl, Force); 00550 }; 00551 00552 } // namespace SimTK 00553 00554 #endif // SimTK_SIMBODY_FORCE_GRAVITY_H_