Simbody  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Force_Gravity.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_FORCE_GRAVITY_H_
2 #define SimTK_SIMBODY_FORCE_GRAVITY_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2010-13 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
27 #include "SimTKcommon.h"
28 #include "simbody/internal/Force.h"
29 
35 namespace SimTK {
36 
68 public:
69 
70 
71 //------------------------------------------------------------------------------
84 
85 
123  const SimbodyMatterSubsystem& matter,
124  const UnitVec3& down,
125  Real g,
126  Real zeroHeight = 0);
127 
156  const SimbodyMatterSubsystem& matter,
157  const Vec3& gravity);
158 
184  const SimbodyMatterSubsystem& matter,
185  Real g);
186 
189 
207 Gravity& setDefaultBodyIsExcluded(MobilizedBodyIndex mobod, bool isExcluded);
208 
218 Gravity& setDefaultGravityVector(const Vec3& gravity);
219 
228 Gravity& setDefaultDownDirection(const UnitVec3& down);
234 { return setDefaultDownDirection(UnitVec3(down)); }
235 
246 Gravity& setDefaultMagnitude(Real g);
247 
256 Gravity& setDefaultZeroHeight(Real zeroHeight);
257 
267 bool getDefaultBodyIsExcluded(MobilizedBodyIndex mobod) const;
270 Vec3 getDefaultGravityVector() const;
273 const UnitVec3& getDefaultDownDirection() const;
275 Real getDefaultMagnitude() const;
278 Real getDefaultZeroHeight() const;
279 
284 //------------------------------------------------------------------------------
300 
317 const Gravity& setBodyIsExcluded(State& state, MobilizedBodyIndex mobod,
318  bool isExcluded) const;
319 
333 const Gravity& setGravityVector(State& state, const Vec3& gravity) const;
334 
346 const Gravity& setDownDirection(State& state,
347  const UnitVec3& down) const;
352  const Vec3& down) const
353 { return setDownDirection(state, UnitVec3(down)); }
354 
364 const Gravity& setMagnitude(State& state, Real g) const;
375 const Gravity& setZeroHeight(State& state, Real hz) const;
376 
388 bool getBodyIsExcluded(const State& state, MobilizedBodyIndex mobod) const;
397 Vec3 getGravityVector(const State& state) const;
405 const UnitVec3& getDownDirection(const State& state) const;
413 Real getMagnitude(const State& state) const;
422 Real getZeroHeight(const State& state) const;
423 
428 //------------------------------------------------------------------------------
437 
448 Real getPotentialEnergy(const State& state) const;
449 
472 const Vector_<SpatialVec>& getBodyForces(const State& state) const;
473 
485 const SpatialVec&
486 getBodyForce(const State& state, MobilizedBodyIndex mobod) const
487 { return getBodyForces(state)[mobod]; }
488 
489 // Particles aren't supported yet so don't show this in Doxygen.
496 const Vector_<Vec3>& getParticleForces(const State& state) const;
499 
501 //------------------------------------------------------------------------------
513 long long getNumEvaluations() const;
514 
518 bool isForceCacheValid(const State& state) const;
519 
523 void invalidateForceCache(const State& state) const;
526 // Don't show this in Doxygen.
530 };
531 
532 } // namespace SimTK
533 
534 #endif // SimTK_SIMBODY_FORCE_GRAVITY_H_
This is the base class from which all Force element handle classes derive.
Definition: Force.h:50
This is for arrays indexed by mobilized body number within a subsystem (typically the SimbodyMatterSu...
UnitVec< Real, 1 > UnitVec3
Definition: UnitVec.h:41
This is the Vector class intended to appear in user code.
Definition: BigMatrix.h:186
This force element represents a uniform gravitational field applied to a set of bodies.
Definition: Force_Gravity.h:67
const Gravity & setDownDirection(State &state, const Vec3 &down) const
Convenience overload that takes the down direction as a Vec3 and normalizes it (throwing away the mag...
Definition: Force_Gravity.h:351
Gravity & setDefaultDownDirection(const Vec3 &down)
Convenience overload that takes the down direction as a Vec3 and normalizes it (throwing away the mag...
Definition: Force_Gravity.h:233
This is the handle class for the hidden State implementation.
Definition: State.h:264
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
#define SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(DERIVED, DERIVED_IMPL, PARENT)
Definition: PrivateImplementation.h:343
const SpatialVec & getBodyForce(const State &state, MobilizedBodyIndex mobod) const
Convenience method to extract the gravitational force on just one body; see getBodyForces() to get th...
Definition: Force_Gravity.h:486
Gravity()
Default constructor creates an empty handle.
Definition: Force_Gravity.h:188
This is a concrete subsystem which can apply arbitrary forces to a MultibodySystem.
Definition: GeneralForceSubsystem.h:47
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:130