Simbody  3.7
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 
71 public:
72 
73 
74 //------------------------------------------------------------------------------
87 
88 
126  const SimbodyMatterSubsystem& matter,
127  const UnitVec3& down,
128  Real g,
129  Real zeroHeight = 0);
130 
159  const SimbodyMatterSubsystem& matter,
160  const Vec3& gravity);
161 
187  const SimbodyMatterSubsystem& matter,
188  Real g);
189 
192 
211 
222 
237 { return setDefaultDownDirection(UnitVec3(down)); }
238 
250 
260 
282 
287 //------------------------------------------------------------------------------
304 
324  bool isExcluded) const;
325 
341 const Gravity& setGravityVector(State& state, const Vec3& gravity) const;
342 
357  const UnitVec3& down) const;
362  const Vec3& down) const
363 { return setDownDirection(state, UnitVec3(down)); }
364 
378 const Gravity& setMagnitude(State& state, Real g) const;
379 
392 const Gravity& setZeroHeight(State& state, Real hz) const;
393 
406 bool getBodyIsExcluded(const State& state, MobilizedBodyIndex mobod) const;
415 Vec3 getGravityVector(const State& state) const;
423 const UnitVec3& getDownDirection(const State& state) const;
431 Real getMagnitude(const State& state) const;
440 Real getZeroHeight(const State& state) const;
441 
446 //------------------------------------------------------------------------------
455 
466 Real getPotentialEnergy(const State& state) const;
467 
492 const Vector_<SpatialVec>& getBodyForces(const State& state) const;
493 
505 const SpatialVec&
506 getBodyForce(const State& state, MobilizedBodyIndex mobod) const
507 { return getBodyForces(state)[mobod]; }
508 
509 // Particles aren't supported yet so don't show this in Doxygen.
516 const Vector_<Vec3>& getParticleForces(const State& state) const;
519 
521 //------------------------------------------------------------------------------
533 long long getNumEvaluations() const;
534 
538 bool isForceCacheValid(const State& state) const;
539 
543 void invalidateForceCache(const State& state) const;
546 // Don't show this in Doxygen.
550 };
551 
552 } // namespace SimTK
553 
554 #endif // SimTK_SIMBODY_FORCE_GRAVITY_H_
SimTK::State
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
MobilizedBodyIndex
SimTK::Force::Gravity::setGravityVector
const Gravity & setGravityVector(State &state, const Vec3 &gravity) const
Set the gravity vector v, that is, the magnitude and direction with which gravitational forces will a...
SimTK::Force::Gravity::setDefaultDownDirection
Gravity & setDefaultDownDirection(const UnitVec3 &down)
Set the default "down" direction d, that is, the direction along which gravity will act.
SimTK::Force::Gravity::getBodyForce
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:506
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS
#define SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(DERIVED, DERIVED_IMPL, PARENT)
Definition: PrivateImplementation.h:343
SimTK::Force::Gravity::Gravity
Gravity(GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter, const Vec3 &gravity)
Convenience constructor to create a Gravity force element by specifying only a gravity vector,...
SimTK::Force::Gravity::getBodyForces
const Vector_< SpatialVec > & getBodyForces(const State &state) const
Obtain a reference to the set of gravitational forces currently being applied by this Gravity force e...
SimTK::Force::Gravity::setMagnitude
const Gravity & setMagnitude(State &state, Real g) const
Set the gravity magnitude g (a nonnegative scalar) in this state, overriding the default gravity magn...
SimTK::Force::Gravity::getPotentialEnergy
Real getPotentialEnergy(const State &state) const
Obtain the gravitational potential energy contained in this Gravity force element in the given config...
SimTK::Force::Gravity::setZeroHeight
const Gravity & setZeroHeight(State &state, Real hz) const
Set the potential energy zero height hz (a scalar) in this state, overriding the default zero height ...
SimTK::Force::Gravity::getDownDirection
const UnitVec3 & getDownDirection(const State &state) const
Get the gravity "down" direction d (a unit vector) that is currently set in this state.
SimTK::Force::Gravity::getDefaultGravityVector
Vec3 getDefaultGravityVector() const
Return the default gravity vector being used for this Gravity force element, calculated from the defa...
SimTK
This is a System that represents the dynamics of a particle moving along a smooth surface.
Definition: Assembler.h:37
SimTK::Force::Gravity::getGravityVector
Vec3 getGravityVector(const State &state) const
Get the gravity vector v that will be used for computations done with this state.
SimTK::Force::Gravity::Gravity
Gravity(GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter, const UnitVec3 &down, Real g, Real zeroHeight=0)
This is the most general constructor for creating a Gravity force element within a particular force s...
SimTK::Force::Gravity::Gravity
Gravity(GeneralForceSubsystem &forces, const SimbodyMatterSubsystem &matter, Real g)
Convenience constructor to create a Gravity force element by specifying only gravity's magnitude,...
SimTK::Force::Gravity::getDefaultBodyIsExcluded
bool getDefaultBodyIsExcluded(MobilizedBodyIndex mobod) const
Return the current setting of the "is excluded by default" flag for the given body.
SimTK::Force::Gravity::setDefaultBodyIsExcluded
Gravity & setDefaultBodyIsExcluded(MobilizedBodyIndex mobod, bool isExcluded)
Set how the indicated body is to be treated by default.
SimTK::Force::Gravity::setDefaultGravityVector
Gravity & setDefaultGravityVector(const Vec3 &gravity)
Set the default value for the gravity vector, that is, the direction and magnitude with which gravity...
SimTK::Force::Gravity::getMagnitude
Real getMagnitude(const State &state) const
Get the gravity magnitude g (a nonnegative scalar) that is currently set in this state.
SimTK::UnitVec< Real, 1 >
SimTKcommon.h
SimTK::Force::Gravity::getZeroHeight
Real getZeroHeight(const State &state) const
Get the zero height hz that is currently set in this state for use in calculating gravitational poten...
SimTK::Vec< 3 >
SimTK::SimbodyMatterSubsystem
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:133
SimTK::Force
This is the base class from which all Force element handle classes derive.
Definition: Force.h:50
SimTK::Force::Gravity::setDefaultDownDirection
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:236
SimTK::GeneralForceSubsystem
This is a concrete subsystem which can apply arbitrary forces to a MultibodySystem.
Definition: GeneralForceSubsystem.h:47
SimTK::Force::Gravity::getBodyIsExcluded
bool getBodyIsExcluded(const State &state, MobilizedBodyIndex mobod) const
Return the current setting of the "is excluded" flag for a given body in a given State.
SimTK::Force::Gravity::invalidateForceCache
void invalidateForceCache(const State &state) const
Invalidate the stored gravitational forces if they have already been calculated at this configuration...
SimTK::UnitVec3
UnitVec< Real, 1 > UnitVec3
Definition: UnitVec.h:41
SimTK::Force::Gravity::getDefaultDownDirection
const UnitVec3 & getDefaultDownDirection() const
Return the default down direction (a unit vector) for this Gravity force element.
SimTK_SIMBODY_EXPORT
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
SimTK::Force::Gravity
This force element represents a uniform gravitational field applied to a set of bodies.
Definition: Force_Gravity.h:70
SimTK::Real
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:606
SimTK::Force::Gravity::setBodyIsExcluded
const Gravity & setBodyIsExcluded(State &state, MobilizedBodyIndex mobod, bool isExcluded) const
Within a given State, selectively exclude (or include) a body from the effects of this Gravity force.
SimTK::Force::Gravity::Gravity
Gravity()
Default constructor creates an empty handle.
Definition: Force_Gravity.h:191
SimTK::Vector_
This is the vector class intended to appear in user code for large, variable size column vectors.
Definition: BigMatrix.h:171
SimTK::Force::Gravity::setDownDirection
const Gravity & setDownDirection(State &state, const UnitVec3 &down) const
Set the "down" direction d (a unit vector), that is, the direction along which gravitational forces w...
SimTK::Force::Gravity::setDefaultMagnitude
Gravity & setDefaultMagnitude(Real g)
Set the default magnitude of gravity (a nonegative scalar).
SimTK::Force::Gravity::setDownDirection
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:361
SimTK::Force::Gravity::isForceCacheValid
bool isForceCacheValid(const State &state) const
Return true if the gravitational forces for this configuration have already been calculated and are u...
Force.h
SimTK::Force::Gravity::getNumEvaluations
long long getNumEvaluations() const
Return a count of the number of times the set of gravitational forces or potential energy was calcula...
SimTK::Force::Gravity::setDefaultZeroHeight
Gravity & setDefaultZeroHeight(Real zeroHeight)
Set the default zero height (a signed scalar), for use in potential energy calculation.
SimTK::Force::Gravity::getDefaultZeroHeight
Real getDefaultZeroHeight() const
Return the default zero height used in the calculation of graviational potential energy.
SimTK::Force::Gravity::getDefaultMagnitude
Real getDefaultMagnitude() const
Return the default gravity magnitude g (a nonnegative scalar).