AGX Dynamics 2.38.0.0
Loading...
Searching...
No Matches
agx::RigidBody Class Reference

The rigid body class, combining a geometric model and a frame of reference. More...

#include <RigidBody.h>

+ Inheritance diagram for agx::RigidBody:

Public Types

enum  MotionControl { STATIC = 1 , KINEMATICS = 2 , DYNAMICS = 3 }
 The MotionControl enumeration indicates what makes a RigidBody move. More...
 

Public Member Functions

 RigidBody (agxCollide::Geometry *geometry)
 Construct given geometry.
 
 RigidBody (const agx::Name &name="")
 Construct given name.
 
bool add (agxCollide::Geometry *geometry, bool incrementalMassCalculation=false)
 Add a geometry to this rigid body.
 
bool add (agxCollide::Geometry *geometry, const agx::AffineMatrix4x4 &localTransform, bool incrementalMassCalculation=false)
 Connect a geometry to this rigid body.
 
bool addAttachment (agx::Frame *frame, const agx::String &name)
 Add a named attachment frame to this rigid body.
 
void addForce (agx::Real fx, agx::Real fy, agx::Real fz)
 Add the specified force, fx fy fz, given in world coordinate frame, that will be affecting this body in the next solve.
 
void addForce (const agx::Vec3 &force)
 Add the specified force, given in world coordinate frame, that will be affecting this body in the next solve.
 
void addForceAtLocalCmPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz)
 Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame.
 
void addForceAtLocalCmPosition (const agx::Vec3 &force, const agx::Vec3 &position)
 Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame.
 
void addForceAtLocalPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz)
 Add a force given in world coordinate frame, applied at a point specified in local coordinate model frame.
 
void addForceAtLocalPosition (const agx::Vec3 &force, const agx::Vec3 &position)
 Add a force, given in the world coordinate frame, applied at a point specified in the local Model coordinate frame.
 
void addForceAtPosition (agx::Real fx, agx::Real fy, agx::Real fz, agx::Real px, agx::Real py, agx::Real pz)
 Add a force, given in the world coordinate frame, applied at a point specified in the world coordinate frame.
 
void addForceAtPosition (const agx::Vec3 &force, const agx::Vec3 &position)
 Add a force, given in the World coordinate frame, applied at a point specified in world coordinate frame.
 
void addLocalTorque (agx::Real tx, agx::Real ty, agx::Real tz)
 Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body in the next solve.
 
void addLocalTorque (const agx::Vec3 &torque)
 Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body in the next solve.
 
void addTorque (agx::Real tx, agx::Real ty, agx::Real tz)
 Adds the specified torque, given in world coordinate frame, that will be affecting this body in the next solve.
 
void addTorque (const agx::Vec3 &torque)
 Adds the specified torque, given in world coordinate frame, that will be affecting this body in the next solve.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::RigidBody)
 
agx::Vec3 calculateCenterOfMassOffset (agx::Real mass=agx::Real()) const
 Calculate the center of mass offset of this rigid body using the volume and density of the added geometries.
 
agx::Real calculateMass () const
 Calculate the mass of this rigid body using the volume and density of added geometries.
 
RigidBodyclone (bool shallowCopyRenderData=false) const
 Create a clone of the rigid body.
 
agx::Vec3 getAcceleration () const
 Will always be 0 for KINEMATIC and STATIC bodies.
 
agx::Vec3 getAngularAcceleration () const
 Will always be 0 for KINEMATIC and STATIC bodies.
 
agx::Vec3 getAngularMomentum () const
 
agx::Vec3 getAngularVelocity () const
 Angular velocity in world coordinate frame.
 
agx::Vec3f getAngularVelocityDamping () const
 
agx::Vec3f getAngularVelocityZeroDamping () const
 
FramegetAttachment (const agx::String &name)
 Access a named attachment frame.
 
agx::FramegetCmFrame ()
 Return the center of mass (CM) frame of this rigid body.
 
const agx::FramegetCmFrame () const
 Return the center of mass (CM) frame of this rigid body.
 
agx::Vec3 getCmLocalTranslate () const
 
agx::Vec3 getCmPosition () const
 
agx::Quat getCmRotation () const
 
const agx::AffineMatrix4x4getCmTransform () const
 Convenience methods for center of mass frame.
 
agx::ReferencedgetCustomData () const
 
bool getEnable () const
 Access the state enable flag.
 
agx::Physics::RigidBodyPtr getEntity () const
 Internal method.
 
agx::Vec3 getForce () const
 
agx::FramegetFrame ()
 Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.
 
const agx::FramegetFrame () const
 Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.
 
const agxCollide::GeometryRefVectorgetGeometries () const
 
agxCollide::GeometrygetGeometry (const agx::Name &name)
 Find (linear search) the first Geometry in the RigidBody with a matching name.
 
const agxCollide::GeometrygetGeometry (const agx::Name &name) const
 Find (linear search) the first Geometry in the RigidBody with a matching name.
 
bool getHandleAsParticle () const
 
agx::UInt32 getId () const
 Internal method.
 
agx::Vec3 getLastForce () const
 Access the summed force applied to this rigid body last time the system was integrated.
 
agx::Vec3 getLastTorque () const
 Access the summed torque applied to this rigid body last time the system was integrated.
 
agx::Vec3 getLinearMomentum () const
 
agx::Vec3f getLinearVelocityDamping () const
 
agx::Vec3f getLinearVelocityZeroDamping () const
 
agx::Vec3 getLocalPosition () const
 
agx::Quat getLocalRotation () const
 
const agx::AffineMatrix4x4getLocalTransform () const
 
agx::MassPropertiesgetMassProperties ()
 
const agx::MassPropertiesgetMassProperties () const
 
agx::Vec3 getModelAcceleration (const agx::Vec3 &relPos=agx::Vec3()) const
 Calculates the linear acceleration at the given point relPos.
 
agx::Vec3 getModelVelocity (const agx::Vec3 &relPos=agx::Vec3()) const
 Calculates the linear velocity at the given point relPos.
 
agx::RigidBody::MotionControl getMotionControl () const
 
const agx::NamegetName () const
 
agx::UInt16 getNumConstraints () const
 
agx::FramegetParentFrame ()
 
const agx::FramegetParentFrame () const
 
agx::Vec3 getPosition () const
 Current model frame position, given in world coordinate frame.
 
agx::PropertyContainergetPropertyContainer () const
 Access property container of this rigid body.
 
agx::Quat getRotation () const
 Current model frame rotation, given in world coordinate frame.
 
agx::DynamicsSystemgetSystem ()
 
const agx::DynamicsSystemgetSystem () const
 
agx::Vec3 getTorque () const
 
const agx::AffineMatrix4x4getTransform () const
 Current model frame transform, given in world coordinate frame.
 
agx::Vec3 getVelocity () const
 Velocity of center of mass frame origin, in world coordinate frame.
 
bool hasConstraints () const
 
bool hasPropertyContainer () const
 
bool hasValidEntityIndex () const
 
bool isEnabled () const
 Access the state enable flag.
 
bool isPowerlineBody () const
 
void moveTo (const agx::AffineMatrix4x4 &target, agx::Real t)
 Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.
 
void moveTo (const agx::Vec3 &targetPosition, const agx::Quat &targetRotation, agx::Real t)
 Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.
 
bool remove (agxCollide::Geometry *geometry, bool incrementalMassCalculation=false)
 Remove geometry if geometry is part of this rigid body.
 
bool removeAttachment (const agx::String &name)
 Remove an attachment from the rigid body.
 
void setAngularVelocity (agx::Real vx, agx::Real vy, agx::Real vz)
 Set the angular velocity of the center of mass of this rigid body.
 
void setAngularVelocity (const agx::Vec3 &angularVelocity)
 Set the angular velocity of the center of mass of this rigid body.
 
void setAngularVelocityDamping (const agx::Vec3f &damping)
 Give angular velocity damping in each direction, given in local body coordinate frame.
 
void setAngularVelocityDamping (float damping)
 Set angular velocity damping for the body in all directions x, y and z.
 
void setAngularVelocityZeroDamping (const agx::Vec3f &dir)
 Specify a vector (in body coordinates) along which no angular velocity damping should occur.
 
void setCmLocalTranslate (const agx::Vec3 &translate)
 Sets the local offset of the center of mass position to the model origin (in model frame coordinates).
 
void setCmPosition (const agx::Vec3 &p, bool synchronizeModel=true)
 Assign new center of mass position, given in world coordinate frame.
 
void setCmRotation (const agx::EulerAngles &e)
 Assign new center of mass rotation, given in world coordinate frame.
 
void setCmRotation (const agx::OrthoMatrix3x3 &m)
 Assign new center of mass rotation, given in world coordinate frame.
 
void setCmRotation (const agx::Quat &q)
 Assign new center of mass rotation, given in world coordinate frame.
 
void setCmTransform (const agx::AffineMatrix4x4 &matrix, bool synchronizeModel=true)
 Assign new center of mass transform, given in world coordinate frame.
 
void setCustomData (agx::Referenced *data)
 It's possible to derive from agx::Referenced and implement a reference counted object and associate it to this rigid body via this method.
 
void setEnable (bool enable)
 Change state enable of this rigid body.
 
void setEntity (agx::Physics::RigidBodyPtr entity)
 Internal method.
 
void setForce (agx::Real fx, agx::Real fy, agx::Real fz)
 Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.
 
void setForce (const agx::Vec3 &force)
 Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.
 
void setHandleAsParticle (bool handleAsParticle)
 Set this, six degrees of freedom, rigid body to be handled as a three degrees of freedom particle (rotational degrees of freedom ignored).
 
void setInertiaTensor (const agx::SPDMatrix3x3 &inertiaTensor, const agx::AffineMatrix4x4 &cmLocalTransform=agx::AffineMatrix4x4(), bool autogenerateCmOffset=false, bool autogenerateInertia=false)
 Convenience method for setting the inertia tensor from extern calculations given in local center of mass coordinate frame.
 
void setInertiaTensor (const agx::Vec3 &inertiaDiagonal, const agx::AffineMatrix4x4 &cmLocalTransform=agx::AffineMatrix4x4(), bool autogenerateCmOffset=false, bool autogenerateInertia=false)
 Convenience method for setting the inertia tensor from extern calculations, in diagonal form, given in local center of mass coordinate frame.
 
void setIsPowerlineBody (bool isHydraulicBody)
 Internal method.
 
void setLinearVelocityDamping (const agx::Vec3f &damping)
 Give linear velocity damping in each direction, given in local body coordinate frame.
 
void setLinearVelocityDamping (float damping)
 Set linear velocity damping for the body in all directions x, y and z.
 
void setLinearVelocityZeroDamping (const agx::Vec3f &dir)
 Specify a vector (in body coordinates) along which no linear velocity damping should occur.
 
void setLocalPosition (agx::Real x, agx::Real y, agx::Real z)
 Set the position of the body relative to its model frame's parent frame.
 
void setLocalPosition (const agx::Vec3 &p)
 Set the position of the body relative to its model frame's parent frame.
 
void setLocalRotation (const agx::EulerAngles &e)
 Set the rotation of the body relative to its model frame's parent frame.
 
void setLocalRotation (const agx::Quat &q)
 Set the rotation of the body relative to its model frame's parent frame.
 
void setLocalTransform (const agx::AffineMatrix4x4 &matrix)
 Assign the local transformation matrix for this body, ignoring any eventual parent transformation.
 
void setMotionControl (agx::RigidBody::MotionControl control)
 Assign new motion control state to this rigid body.
 
void setName (const agx::Name &name)
 Assign new name to this rigid body.
 
bool setParentFrame (agx::Frame *frame)
 Set the parent frame of this body's model frame.
 
void setPosition (agx::Real x, agx::Real y, agx::Real z)
 Set the position of the model frame in world coordinates.
 
void setPosition (const agx::Vec3 &p)
 Set the position of the model frame in world coordinates.
 
void setPropertyContainer (agx::PropertyContainer *container)
 Assign new property container.
 
void setRotation (const agx::EulerAngles &e)
 Set the rotation of the body relative to world frame.
 
void setRotation (const agx::OrthoMatrix3x3 &m)
 Set the rotation of the body relative to world frame.
 
void setRotation (const agx::Quat &q)
 Set the rotation of the body relative to world frame.
 
void setTorque (agx::Real tx, agx::Real ty, agx::Real tz)
 Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.
 
void setTorque (const agx::Vec3 &torque)
 Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.
 
void setTransform (const agx::AffineMatrix4x4 &matrix)
 Set the transform of the body.
 
void setVelocity (agx::Real vx, agx::Real vy, agx::Real vz)
 Set the linear velocity of the center of mass of this rigid body.
 
void setVelocity (const agx::Vec3 &velocity)
 Set the linear velocity of the center of mass of this rigid body.
 
void setVelocityDamping (float damping)
 Set both linear- and angular velocity damping in all directions.
 
void transfer (agxData::EntityStorage *storage)
 Internal method.
 
void updateMassProperties ()
 Method to explicitly update mass properties.
 
void updateMassProperties (agx::UInt32 mask)
 Method to explicitly update mass properties.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

Static Public Member Functions

static agxStream::Serializablecreate (agxStream::InputArchive &)
 
static bool shouldIgnoreGravity (agx::RigidBodyState state)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 

Protected Member Functions

 RigidBody (const agx::Name &name, agx::Physics::RigidBodyPtr entity)
 
 RigidBody (const agx::RigidBody &)
 
virtual ~RigidBody ()
 
void incrementalMassPropertyUpdate (agx::UInt32 mask, int sign, const agxCollide::Geometry *geometry)
 Will calculate new mass properties for this rigid body as the previously calculated one +/- the specified geometry.
 
RigidBodyoperator= (const agx::RigidBody &)
 
void setId (agx::UInt32 id)
 Assign dynamics system unique id to this rigid body.
 
void setSystem (agx::DynamicsSystem *system)
 Assign dynamics system where this body belongs to.
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

The rigid body class, combining a geometric model and a frame of reference.

Definition at line 51 of file RigidBody.h.

Member Enumeration Documentation

◆ MotionControl

The MotionControl enumeration indicates what makes a RigidBody move.

There are three forms of motion allowed:

  • STATIC means no motion whatsoever;
  • KINEMATICS means that motion is scripted;
  • DYNAMICS means that motion results from forces;
Enumerator
STATIC 

This body will never move.

KINEMATICS 

This body's motion is scripted.

(Position/velocity set by the user)

DYNAMICS 

This body moves from the influence of forces.

(Position/velocity updated by the system)

Definition at line 62 of file RigidBody.h.

Constructor & Destructor Documentation

◆ RigidBody() [1/4]

agx::RigidBody::RigidBody ( const agx::Name name = "")

Construct given name.

Default: mass = 1, inertia diagonal = (1, 1, 1), geometries = 0, position = (0, 0, 0), linear velocity = (0, 0, 0), angular velocity = (0, 0, 0), enable = true, motion control = DYNAMICS.

Parameters
name- name of this rigid body (default: "")

◆ RigidBody() [2/4]

agx::RigidBody::RigidBody ( agxCollide::Geometry geometry)

Construct given geometry.

Mass properties will be updated given geometry.

Parameters
geometry- first geometry to add to this rigid body

◆ ~RigidBody()

virtual agx::RigidBody::~RigidBody ( )
protectedvirtual

◆ RigidBody() [3/4]

agx::RigidBody::RigidBody ( const agx::RigidBody )
protected

◆ RigidBody() [4/4]

agx::RigidBody::RigidBody ( const agx::Name name,
agx::Physics::RigidBodyPtr  entity 
)
protected

Member Function Documentation

◆ add() [1/2]

bool agx::RigidBody::add ( agxCollide::Geometry geometry,
bool  incrementalMassCalculation = false 
)

Add a geometry to this rigid body.

The frame of the geometry will be attached as a child to the model frame of this rigid body. The inertia, mass, and center of mass offset will be automatically recalculated using the material and volume of the geometry. However, any parameter explicitly set in the MassProperties (with auto generation flag disabled) will not be recalculated/updated. The local transformation in the geometry (geometry->getLocalTransform()) will be used to transform the geometry relative to the RigidBody.

Note
If the Geometry explicitly has to be added to the Simulation, adding it to a RigidBody (part of a simulation) will NOT add the geometry to the same simulation.
Regarding incrementalMassCalculation: Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead).
Currently, automatic mass property calculation (incremental or not) assumes all geometries and shapes to be disjoint (non-overlapping). If they overlap, the effect of this assumption is that the overlapping volume will be counted twice into mass and inertia computation. It is recommended to set the mass properties manually in this case.
Parameters
geometry- the geometry to add
incrementalMassCalculation- false for full recalculation of mass properties, true for incremental calculation (see note)
Returns
false if the given geometry already has a body associated to it and override is set to false.

◆ add() [2/2]

bool agx::RigidBody::add ( agxCollide::Geometry geometry,
const agx::AffineMatrix4x4 localTransform,
bool  incrementalMassCalculation = false 
)

Connect a geometry to this rigid body.

The frame of the geometry will be attached as a child to the model frame of the rigid body. The inertia, mass, and center of mass offset will be automatically recalculated using the material and volume of the geometry. However, any parameter explicitly set in the MassProperties (with auto generation flag disabled) will not be recalculated/updated.

Note
If the Geometry explicitly has to be added to the Simulation, adding it to a RigidBody (part of a simulation) will NOT add the geometry to the same simulation.
Regarding incrementalMassCalculation: Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead).
Parameters
geometry- the geometry to add
localTransform- the relative transform to where the geometry should be placed relative model coordinate frame of this rigid body
incrementalMassCalculation- false for full recalculation of mass properties, true for incremental calculation (see note)
Returns
true if successful - false if not added (0, geometry is part of another rigid body or already added)

Referenced by agxVehicle::utils::createGeometryBox().

◆ addAttachment()

bool agx::RigidBody::addAttachment ( agx::Frame frame,
const agx::String name 
)

Add a named attachment frame to this rigid body.

Returns
false if the name is non-unique, true if successfully added

◆ addForce() [1/2]

void agx::RigidBody::addForce ( agx::Real  fx,
agx::Real  fy,
agx::Real  fz 
)
inline

Add the specified force, fx fy fz, given in world coordinate frame, that will be affecting this body in the next solve.

The force will be applied to the Center of Mass.

Parameters
fx,fy,fz- the force, given in world coordinate frame

Definition at line 1286 of file RigidBody.h.

◆ addForce() [2/2]

void agx::RigidBody::addForce ( const agx::Vec3 force)

Add the specified force, given in world coordinate frame, that will be affecting this body in the next solve.

The force will be applied to the Center of Mass.

Parameters
force- the force, given in world coordinate frame

◆ addForceAtLocalCmPosition() [1/2]

void agx::RigidBody::addForceAtLocalCmPosition ( agx::Real  fx,
agx::Real  fy,
agx::Real  fz,
agx::Real  px,
agx::Real  py,
agx::Real  pz 
)
inline

Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame.

If the position is different from (0,0,0) (CoM), this method will also introduce a torque.

Parameters
fx,fy,fz- the force, given in world coordinate frame, to be added to the already previously added forces
px,py,pz- the position in local center of mass coordinate frame where the force should be applied

Definition at line 1301 of file RigidBody.h.

◆ addForceAtLocalCmPosition() [2/2]

void agx::RigidBody::addForceAtLocalCmPosition ( const agx::Vec3 force,
const agx::Vec3 position 
)

Add a force given in world coordinate frame, applied at a point specified in the local Center of Mass coordinate frame.

If the position is different from (0,0,0) (CoM), this method will also introduce a torque.

Parameters
force- the force, given in world coordinate frame, to be added to the already previously added forces
position- the position in local center of mass coordinate frame where the force should be applied

◆ addForceAtLocalPosition() [1/2]

void agx::RigidBody::addForceAtLocalPosition ( agx::Real  fx,
agx::Real  fy,
agx::Real  fz,
agx::Real  px,
agx::Real  py,
agx::Real  pz 
)
inline

Add a force given in world coordinate frame, applied at a point specified in local coordinate model frame.

If the position is different from the center of mass, a torque will be calculated and added as well.

Parameters
fx,fy,fz- the force, given in world coordinate frame, to be added to the already previously added forces
px,py,pz- the position given in local coordinate frame where the force should be applied

Definition at line 1296 of file RigidBody.h.

◆ addForceAtLocalPosition() [2/2]

void agx::RigidBody::addForceAtLocalPosition ( const agx::Vec3 force,
const agx::Vec3 position 
)

Add a force, given in the world coordinate frame, applied at a point specified in the local Model coordinate frame.

If the position is different from the center of mass, a torque will be calculated and added as well.

Parameters
force- the force, given in world coordinate frame, to be added to the already previously added forces
position- the position given in local coordinate frame where the force should be applied

◆ addForceAtPosition() [1/2]

void agx::RigidBody::addForceAtPosition ( agx::Real  fx,
agx::Real  fy,
agx::Real  fz,
agx::Real  px,
agx::Real  py,
agx::Real  pz 
)
inline

Add a force, given in the world coordinate frame, applied at a point specified in the world coordinate frame.

If the position is different from the center of mass, a torque will be calculated and added as well.

Parameters
fx,fy,fz- the force, given in world coordinate frame, to be added to the already previously added forces
px,py,pz- the position given in world coordinate frame where the force should be applied

Definition at line 1291 of file RigidBody.h.

◆ addForceAtPosition() [2/2]

void agx::RigidBody::addForceAtPosition ( const agx::Vec3 force,
const agx::Vec3 position 
)

Add a force, given in the World coordinate frame, applied at a point specified in world coordinate frame.

If the position is different from the center of mass, a torque will be calculated and added as well.

Parameters
force- the force, given in world coordinate frame, to be added to the already previously added forces
position- the position given in world coordinate frame where the force should be applied

◆ addLocalTorque() [1/2]

void agx::RigidBody::addLocalTorque ( agx::Real  tx,
agx::Real  ty,
agx::Real  tz 
)
inline

Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body in the next solve.

Parameters
tx,ty,tz- the torque, given in local coordinate frame

Definition at line 1311 of file RigidBody.h.

◆ addLocalTorque() [2/2]

void agx::RigidBody::addLocalTorque ( const agx::Vec3 torque)

Adds the specified torque, given in Center of Mass coordinate frame that will be affecting this body in the next solve.

Parameters
torque- the torque

◆ addTorque() [1/2]

void agx::RigidBody::addTorque ( agx::Real  tx,
agx::Real  ty,
agx::Real  tz 
)
inline

Adds the specified torque, given in world coordinate frame, that will be affecting this body in the next solve.

Parameters
tx,ty,tz- the torque, given in world coordinate frame

Definition at line 1306 of file RigidBody.h.

◆ addTorque() [2/2]

void agx::RigidBody::addTorque ( const agx::Vec3 torque)

Adds the specified torque, given in world coordinate frame, that will be affecting this body in the next solve.

Parameters
torque- the torque, given in world coordinate frame

◆ AGXSTREAM_DECLARE_SERIALIZABLE_BASE()

agx::RigidBody::AGXSTREAM_DECLARE_SERIALIZABLE_BASE ( agx::RigidBody  )

◆ calculateCenterOfMassOffset()

agx::Vec3 agx::RigidBody::calculateCenterOfMassOffset ( agx::Real  mass = agx::Real()) const

Calculate the center of mass offset of this rigid body using the volume and density of the added geometries.

Parameters
mass- if 0, the mass will be recalculated given the added geometries density and volume
Returns
the center of mass offset given in local model coordinate frame

◆ calculateMass()

agx::Real agx::RigidBody::calculateMass ( ) const

Calculate the mass of this rigid body using the volume and density of added geometries.

Note
This calculated mass isn't necessary the same as getMassProperties()->getMass() since the mass in mass properties could be assigned (i.e., explicit).
Returns
the total mass of this rigid body, calculated given volume and density of added geometries

◆ clone()

RigidBody * agx::RigidBody::clone ( bool  shallowCopyRenderData = false) const

Create a clone of the rigid body.

◆ create()

static agxStream::Serializable * agx::RigidBody::create ( agxStream::InputArchive )
inlinestatic

Definition at line 1047 of file RigidBody.h.

◆ getAcceleration()

Vec3 agx::RigidBody::getAcceleration ( ) const

Will always be 0 for KINEMATIC and STATIC bodies.

Returns
the linear acceleration as the difference in linear velocity between this and the previous time step

Definition at line 1231 of file RigidBody.h.

◆ getAngularAcceleration()

Vec3 agx::RigidBody::getAngularAcceleration ( ) const

Will always be 0 for KINEMATIC and STATIC bodies.

Returns
the angular acceleration as the difference in linear velocity between this and the previous time step

Definition at line 1236 of file RigidBody.h.

◆ getAngularMomentum()

agx::Vec3 agx::RigidBody::getAngularMomentum ( ) const
Returns
the angular momentum for this body

◆ getAngularVelocity()

Vec3 agx::RigidBody::getAngularVelocity ( ) const

Angular velocity in world coordinate frame.

Note
Angular velocity is independent of the point it is measured in. I.e., methods like getModelAngularVelocity are redundant.
Returns
angular velocity in world coordinate frame

Definition at line 1196 of file RigidBody.h.

Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().

◆ getAngularVelocityDamping()

agx::Vec3f agx::RigidBody::getAngularVelocityDamping ( ) const
Returns
the linear velocity damping, given in local body coordinate frame

◆ getAngularVelocityZeroDamping()

agx::Vec3f agx::RigidBody::getAngularVelocityZeroDamping ( ) const
Returns
the zero damping vector (in local body coordinate frame) which points out the direction in which no angular velocity damping should be applied

◆ getAttachment()

Frame * agx::RigidBody::getAttachment ( const agx::String name)

Access a named attachment frame.

Parameters
name- name of the attachment
Returns
the attachment frame with name if it exist - otherwise null

◆ getCmFrame() [1/2]

Frame * agx::RigidBody::getCmFrame ( )

Return the center of mass (CM) frame of this rigid body.

The CM frame is a child frame of the model frame. The center of mass offset is automatically calculated as geometries are added/removed, but this can be disabled in the mass properties of the rigid body.

Returns
the center of mass frame of this rigid body

Definition at line 1176 of file RigidBody.h.

◆ getCmFrame() [2/2]

const Frame * agx::RigidBody::getCmFrame ( ) const

Return the center of mass (CM) frame of this rigid body.

The CM frame is a child frame of the model frame. The center of mass offset is automatically calculated as geometries are added/removed, but this can be disabled in the mass properties of the rigid body.

Returns
the center of mass frame of this rigid body

Definition at line 1181 of file RigidBody.h.

◆ getCmLocalTranslate()

Vec3 agx::RigidBody::getCmLocalTranslate ( ) const
Returns
the local offset of the center of mass position to the model origin (in model frame coordinates).

Definition at line 1201 of file RigidBody.h.

◆ getCmPosition()

Vec3 agx::RigidBody::getCmPosition ( ) const
Returns
the center of mass position in world coordinate frame

Definition at line 1206 of file RigidBody.h.

Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().

◆ getCmRotation()

Quat agx::RigidBody::getCmRotation ( ) const
Returns
the center of mass rotation in world coordinate frame

Definition at line 1211 of file RigidBody.h.

References agx::QuatT< T >::getRotate().

◆ getCmTransform()

const AffineMatrix4x4 & agx::RigidBody::getCmTransform ( ) const

Convenience methods for center of mass frame.

The bool flag of the mutator(set) methods indicates if the update should sync back to the model frame (i.e. the model is updated using the relative change in center of mass while the local center of mass values are unchanged), or if the update only affects the local center of mass frame (which is analogous to the normal frame interface).

Returns
the center of mass transform in world coordinate frame

Definition at line 1186 of file RigidBody.h.

Referenced by agxOSG::ContainerShapeBatchRenderer< ContainerType, TransformType >::findTransform().

◆ getCustomData()

Referenced * agx::RigidBody::getCustomData ( ) const
See also
setCustomData
Returns
user data, if assigned

Definition at line 1251 of file RigidBody.h.

◆ getEnable()

bool agx::RigidBody::getEnable ( ) const

Access the state enable flag.

Returns
true if the body is enabled (default) - otherwise false

Definition at line 1129 of file RigidBody.h.

Referenced by agxCollide::Space::canCollide().

◆ getEntity()

Physics::RigidBodyPtr agx::RigidBody::getEntity ( ) const
inline

Internal method.

Data access.

Returns
the rigid body entity

Definition at line 1156 of file RigidBody.h.

Referenced by agx::MergedBody::isRoot().

◆ getForce()

agx::Vec3 agx::RigidBody::getForce ( ) const
Returns
the current external force applied to the body using the method(s) add/setForce

◆ getFrame() [1/2]

Frame * agx::RigidBody::getFrame ( )

Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.

Returns
model frame of this rigid body

Definition at line 1166 of file RigidBody.h.

Referenced by agxModel::NodeAttachment::createFromWorld().

◆ getFrame() [2/2]

const Frame * agx::RigidBody::getFrame ( ) const

Returns the model frame containing model the transformation and utilities to manipulate position, rotation etc.

Returns
model frame of this rigid body

Definition at line 1171 of file RigidBody.h.

◆ getGeometries()

const agxCollide::GeometryRefVector & agx::RigidBody::getGeometries ( ) const
Returns
container with all geometries that is part of this rigid body

◆ getGeometry() [1/2]

agxCollide::Geometry * agx::RigidBody::getGeometry ( const agx::Name name)

Find (linear search) the first Geometry in the RigidBody with a matching name.

Parameters
name- name of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getGeometry() [2/2]

const agxCollide::Geometry * agx::RigidBody::getGeometry ( const agx::Name name) const

Find (linear search) the first Geometry in the RigidBody with a matching name.

Parameters
name- name of geometry to search for
Returns
a pointer to the found Geometry, null if not found.

◆ getHandleAsParticle()

bool agx::RigidBody::getHandleAsParticle ( ) const
Returns
true if this rigid body is handled like a particle (i.e., rotational degrees of freedom ignored)

Definition at line 1226 of file RigidBody.h.

◆ getId()

UInt32 agx::RigidBody::getId ( ) const

Internal method.

The id this rigid body has in a system. This value may change when any other body is removed from a system.

See also
getUniqueID
Returns
id to this rigid body in a system

Definition at line 1161 of file RigidBody.h.

◆ getLastForce()

agx::Vec3 agx::RigidBody::getLastForce ( ) const

Access the summed force applied to this rigid body last time the system was integrated.

See also
addForce, addForceAtPosition
Note
Forces applied by constraints and/or contacts are NOT included in this value.

◆ getLastTorque()

agx::Vec3 agx::RigidBody::getLastTorque ( ) const

Access the summed torque applied to this rigid body last time the system was integrated.

See also
addTorque
Note
Torques applied by constraints and/or contacts are NOT included in this value.

◆ getLinearMomentum()

agx::Vec3 agx::RigidBody::getLinearMomentum ( ) const
Returns
the linear momentum for this body

◆ getLinearVelocityDamping()

agx::Vec3f agx::RigidBody::getLinearVelocityDamping ( ) const
Returns
the linear velocity damping, given in local body coordinate frame

◆ getLinearVelocityZeroDamping()

agx::Vec3f agx::RigidBody::getLinearVelocityZeroDamping ( ) const
Returns
the zero damping vector (in local body coordinate frame) which points out the direction in which no linear velocity damping should be applied

◆ getLocalPosition()

agx::Vec3 agx::RigidBody::getLocalPosition ( ) const
Returns
- the relative translate to the parent frame of the body's model frame.

◆ getLocalRotation()

agx::Quat agx::RigidBody::getLocalRotation ( ) const
Returns
- the body's rotation relative to its model frame's parent frame.

◆ getLocalTransform()

const agx::AffineMatrix4x4 & agx::RigidBody::getLocalTransform ( ) const
Returns
- the local transformation matrix of the body's model frame, relative to the parent.

◆ getMassProperties() [1/2]

MassProperties * agx::RigidBody::getMassProperties ( )
Returns
mass related properties of this rigid body

Definition at line 1216 of file RigidBody.h.

◆ getMassProperties() [2/2]

const MassProperties * agx::RigidBody::getMassProperties ( ) const
Returns
mass related properties of this rigid body

Definition at line 1221 of file RigidBody.h.

◆ getModelAcceleration()

agx::Vec3 agx::RigidBody::getModelAcceleration ( const agx::Vec3 relPos = agx::Vec3()) const

Calculates the linear acceleration at the given point relPos.

The point relPos must be given in model coordinate frame. The resulting linear acceleration is given in world coordinate frame.

See also
getAcceleration, getModelVelocity
Parameters
relPos- relative position given in model frame coordinates
Returns
linear acceleration in world frame of the point relPos

◆ getModelVelocity()

agx::Vec3 agx::RigidBody::getModelVelocity ( const agx::Vec3 relPos = agx::Vec3()) const

Calculates the linear velocity at the given point relPos.

The point relPos must be given in model coordinate frame. The resulting linear velocity is given in world coordinate frame.

See also
getModelAcceleration, getVelocity
Parameters
relPos- relative position given in model frame coordinates
Returns
linear velocity in world frame of the point relPos

◆ getMotionControl()

RigidBody::MotionControl agx::RigidBody::getMotionControl ( ) const
Returns
the motion control state of this rigid body

Definition at line 1139 of file RigidBody.h.

◆ getName()

const agx::Name & agx::RigidBody::getName ( ) const
Returns
the name of this rigid body

◆ getNumConstraints()

UInt16 agx::RigidBody::getNumConstraints ( ) const
Note
The number of constraints value is updated when the interaction graph is created during the solve process. This means that there are a one time step delay on this value.
Returns
the number of constraints (contacts excluded) connected to this rigid body, the last time step

Definition at line 1246 of file RigidBody.h.

◆ getParentFrame() [1/2]

agx::Frame * agx::RigidBody::getParentFrame ( )
Returns
- the parent frame of the body's model frame, or 0 if this frame has no parent

◆ getParentFrame() [2/2]

const agx::Frame * agx::RigidBody::getParentFrame ( ) const
Returns
- the parent frame of the body's model frame, or 0 if this frame has no parent

◆ getPosition()

agx::Vec3 agx::RigidBody::getPosition ( ) const

Current model frame position, given in world coordinate frame.

Returns
the current model frame position, given in world coordinate frame

Definition at line 1261 of file RigidBody.h.

◆ getPropertyContainer()

agx::PropertyContainer * agx::RigidBody::getPropertyContainer ( ) const

Access property container of this rigid body.

This method will create a new property container object if one hasn't been assigned before. Hence it is recommended to use hasPropertyContainer before calling this method.

Note
This method will create a new property container object if one hasn't been assigned earlier.
See also
hasPropertyContainer
Returns
a reference to the property container

Definition at line 1149 of file RigidBody.h.

◆ getRotation()

agx::Quat agx::RigidBody::getRotation ( ) const

Current model frame rotation, given in world coordinate frame.

Returns
the current model frame rotation, given in world coordinate frame

Definition at line 1266 of file RigidBody.h.

References agx::QuatT< T >::getRotate().

◆ getSystem() [1/2]

agx::DynamicsSystem * agx::RigidBody::getSystem ( )
Returns
a pointer to the DynamicsSystem this rigid body belongs to

◆ getSystem() [2/2]

const agx::DynamicsSystem * agx::RigidBody::getSystem ( ) const
Returns
a pointer to the DynamicsSystem this rigid body belongs to

◆ getTorque()

agx::Vec3 agx::RigidBody::getTorque ( ) const
Returns
the current external torque applied to the body using the method(s) add/setTorque

◆ getTransform()

const agx::AffineMatrix4x4 & agx::RigidBody::getTransform ( ) const

Current model frame transform, given in world coordinate frame.

Returns
the current model transformation of this rigid body, given in world coordinate frame

Definition at line 1256 of file RigidBody.h.

Referenced by agxVehicle::Wheel::attachConstraint(), agxModel::NodeAttachment::createFromWorld(), and agxCable::SegmentAttachment::createFromWorld().

◆ getVelocity()

Vec3 agx::RigidBody::getVelocity ( ) const

Velocity of center of mass frame origin, in world coordinate frame.

See also
getModelVelocity
Returns
linear velocity of the center of mass frame origin, in world coordinate frame

Definition at line 1191 of file RigidBody.h.

Referenced by agxCollide::GeometryContact::calculateRelativeVelocity().

◆ hasConstraints()

bool agx::RigidBody::hasConstraints ( ) const
Note
The number of constraints value is updated when the interaction graph is created during the solve process. This means that there are a one time step delay on this value.
Returns
true if the number of constraints (contacts excluded) was larger than zero, the last time step

Definition at line 1241 of file RigidBody.h.

◆ hasPropertyContainer()

bool agx::RigidBody::hasPropertyContainer ( ) const
Returns
true if it has an initialized property container

Definition at line 1144 of file RigidBody.h.

◆ hasValidEntityIndex()

bool agx::RigidBody::hasValidEntityIndex ( ) const

◆ incrementalMassPropertyUpdate()

void agx::RigidBody::incrementalMassPropertyUpdate ( agx::UInt32  mask,
int  sign,
const agxCollide::Geometry geometry 
)
protected

Will calculate new mass properties for this rigid body as the previously calculated one +/- the specified geometry.

Parameters
mask- Specifies what will be updated
sign- 1 means adding, -1 means removing the geometry.
geometry- The geometry for which the mass properties will be added/removed

References agx::init().

◆ isEnabled()

bool agx::RigidBody::isEnabled ( ) const

Access the state enable flag.

Returns
true if the body is enabled (default) - otherwise false

Definition at line 1134 of file RigidBody.h.

◆ isPowerlineBody()

bool agx::RigidBody::isPowerlineBody ( ) const
inline
Returns
true if body was created by an agxModel::PHysicalDimension.

Definition at line 1326 of file RigidBody.h.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

◆ moveTo() [1/2]

void agx::RigidBody::moveTo ( const agx::AffineMatrix4x4 target,
agx::Real  t 
)

Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.

This is basically only valid if motion control is set to KINEMATICS.

Note
This rigid body will coincide with the target transform given global model frame transform.
This rigid body will not stop at target transform after time t.
Parameters
target- target transform given in world coordinate frame
t- time this rigid body has to reach the target

◆ moveTo() [2/2]

void agx::RigidBody::moveTo ( const agx::Vec3 targetPosition,
const agx::Quat targetRotation,
agx::Real  t 
)

Utility method to calculate and assign linear- and angular velocity given a target transform and the time it should take to get there.

This is basically only valid if motion control is set to KINEMATICS.

Note
This rigid body will coincide with the target transform given global model frame transform.
This rigid body will not stop at target transform after time t.
Parameters
targetPosition- target position given in world coordinate frame
targetRotation- target rotation given in world coordinate frame
t- time this rigid body has to reach the target

◆ operator=()

RigidBody & agx::RigidBody::operator= ( const agx::RigidBody )
inlineprotected

Definition at line 1061 of file RigidBody.h.

◆ remove()

bool agx::RigidBody::remove ( agxCollide::Geometry geometry,
bool  incrementalMassCalculation = false 
)

Remove geometry if geometry is part of this rigid body.

Note
Regarding incrementalMassCalculation: Incremental mass properties calculation is computationally less expensive but may cause numerical drift if this method is used many times. If false, the current set of geometries will be used to calculate the mass properties, which in some extreme cases can be more computationally expensive (or cause general overhead).
Parameters
geometry- geometry to remove
incrementalMassCalculation- false for full recalculation of mass properties, true for incremental calculation (see note)
Returns
true if geometry removed - otherwise false (e.g., geometry not part of this rigid body)

◆ removeAttachment()

bool agx::RigidBody::removeAttachment ( const agx::String name)

Remove an attachment from the rigid body.

Returns
false if the named attachment could not be found, true if successfully removed

◆ setAngularVelocity() [1/2]

void agx::RigidBody::setAngularVelocity ( agx::Real  vx,
agx::Real  vy,
agx::Real  vz 
)
inline

Set the angular velocity of the center of mass of this rigid body.

This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial angular velocity. If motion control is set to STATIC then the angular velocity will be set to zero - independent of the value of angularVelocity. This method is seen as an instantaneous change in angular velocity (infinite acceleration), and will therefore not be represented by getAngularAcceleration().

Parameters
vx,vy,vz- angular velocity given in world coordinate frame

Definition at line 1281 of file RigidBody.h.

◆ setAngularVelocity() [2/2]

void agx::RigidBody::setAngularVelocity ( const agx::Vec3 angularVelocity)

Set the angular velocity of the center of mass of this rigid body.

This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial angular velocity. If motion control is set to STATIC then the angular velocity will be set to zero - independent of the value of angularVelocity. This method is seen as an instantaneous change in angular velocity (infinite acceleration), and will therefore not be represented by getAngularAcceleration().

Parameters
angularVelocity- angular velocity given in world coordinate frame

◆ setAngularVelocityDamping() [1/2]

void agx::RigidBody::setAngularVelocityDamping ( const agx::Vec3f damping)

Give angular velocity damping in each direction, given in local body coordinate frame.

The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).

Parameters
damping- the damping

◆ setAngularVelocityDamping() [2/2]

void agx::RigidBody::setAngularVelocityDamping ( float  damping)

Set angular velocity damping for the body in all directions x, y and z.

The unit of this damping is mass over time. Default: 0 (no damping)

Parameters
damping- the damping

◆ setAngularVelocityZeroDamping()

void agx::RigidBody::setAngularVelocityZeroDamping ( const agx::Vec3f dir)

Specify a vector (in body coordinates) along which no angular velocity damping should occur.

Default: (0, 0, 0)

Parameters
dir- direction, given in local body coordinate frame, in which the angular damping should be zero

◆ setCmLocalTranslate()

void agx::RigidBody::setCmLocalTranslate ( const agx::Vec3 translate)

Sets the local offset of the center of mass position to the model origin (in model frame coordinates).

Parameters
translateThe new offset.

◆ setCmPosition()

void agx::RigidBody::setCmPosition ( const agx::Vec3 p,
bool  synchronizeModel = true 
)

Assign new center of mass position, given in world coordinate frame.

By default the model frame will be updated as well (synchronizeModel).

Parameters
p- new center of mass position given in world coordinate frame
synchronizeModel- default true, if false the model frame will not be updated with this new position

◆ setCmRotation() [1/3]

void agx::RigidBody::setCmRotation ( const agx::EulerAngles e)

Assign new center of mass rotation, given in world coordinate frame.

Note
The center of mass frame MUST, by definition, have the same orientation as the model frame. I.e., it is not defined to call this method with synchronizeModel = false.
Parameters
e- new center of mass rotation (Euler angles)

◆ setCmRotation() [2/3]

void agx::RigidBody::setCmRotation ( const agx::OrthoMatrix3x3 m)

Assign new center of mass rotation, given in world coordinate frame.

Note
The center of mass frame MUST, by definition, have the same orientation as the model frame. I.e., it is not defined to call this method with synchronizeModel = false.
Parameters
m- new center of mass rotation (Orthonormal matrix)

◆ setCmRotation() [3/3]

void agx::RigidBody::setCmRotation ( const agx::Quat q)

Assign new center of mass rotation, given in world coordinate frame.

Note
The center of mass frame MUST, by definition, have the same orientation as the model frame. I.e., it is not defined to call this method with synchronizeModel = false.
Parameters
q- new center of mass rotation (quaternion)

◆ setCmTransform()

void agx::RigidBody::setCmTransform ( const agx::AffineMatrix4x4 matrix,
bool  synchronizeModel = true 
)

Assign new center of mass transform, given in world coordinate frame.

By default the model frame will be updated as well (synchronizeModel).

Note
The center of mass frame MUST, by definition, have the same orientation as the model frame. I.e., it is not defined to call this method with synchronizeModel = false and matrix having a different rotation than the model frame matrix.
Parameters
matrix- new matrix transform given in world coordinate frame
synchronizeModel- default true, if false the model frame will not be updated with this new transform.

◆ setCustomData()

void agx::RigidBody::setCustomData ( agx::Referenced data)

It's possible to derive from agx::Referenced and implement a reference counted object and associate it to this rigid body via this method.

If this rigid body is the only one holding a reference to the data, the data will be deleted when this rigid body is deleted.

See also
getCustomData
Parameters
data- custom data

◆ setEnable()

void agx::RigidBody::setEnable ( bool  enable)

Change state enable of this rigid body.

Default: true.

Parameters
enable- true to enable, false to disable

◆ setEntity()

void agx::RigidBody::setEntity ( agx::Physics::RigidBodyPtr  entity)

Internal method.

Data access.

Parameters
entity- new rigid body entity

◆ setForce() [1/2]

void agx::RigidBody::setForce ( agx::Real  fx,
agx::Real  fy,
agx::Real  fz 
)
inline

Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.

Note
Force added before calling this method will be overwritten. Force added after calling this method will be added to force.
Parameters
fx,fy,fz- the force

Definition at line 1316 of file RigidBody.h.

◆ setForce() [2/2]

void agx::RigidBody::setForce ( const agx::Vec3 force)

Explicitly set the force, given in world coordinate frame, that will be affecting this body in the next solve.

Note
Force added before calling this method will be overwritten. Force added after calling this method will be added to force.
Parameters
force- the force

◆ setHandleAsParticle()

void agx::RigidBody::setHandleAsParticle ( bool  handleAsParticle)

Set this, six degrees of freedom, rigid body to be handled as a three degrees of freedom particle (rotational degrees of freedom ignored).

Default: false

Parameters
handleAsParticle- if true this rigid body will be handled as a particle

◆ setId()

void agx::RigidBody::setId ( agx::UInt32  id)
protected

Assign dynamics system unique id to this rigid body.

Parameters
id- index to this rigid body in dynamics system

◆ setInertiaTensor() [1/2]

void agx::RigidBody::setInertiaTensor ( const agx::SPDMatrix3x3 inertiaTensor,
const agx::AffineMatrix4x4 cmLocalTransform = agx::AffineMatrix4x4(),
bool  autogenerateCmOffset = false,
bool  autogenerateInertia = false 
)

Convenience method for setting the inertia tensor from extern calculations given in local center of mass coordinate frame.

Parameters
inertiaTensor- the externally computed inertia tensor given in local center of mass frame
cmLocalTransform- the frame in which the inertia tensor is given (optional, default: Identity)
autogenerateCmOffset- if true, the center of mass offset will be recalculated when the geometry configuration of the body changes (optional, default: false)
autogenerateInertia- if set to true, the inertia tensor will be recalculated when the geometry configuration of the body changes (optional, default: false)

◆ setInertiaTensor() [2/2]

void agx::RigidBody::setInertiaTensor ( const agx::Vec3 inertiaDiagonal,
const agx::AffineMatrix4x4 cmLocalTransform = agx::AffineMatrix4x4(),
bool  autogenerateCmOffset = false,
bool  autogenerateInertia = false 
)

Convenience method for setting the inertia tensor from extern calculations, in diagonal form, given in local center of mass coordinate frame.

Parameters
inertiaDiagonal- the externally computed inertia tensor in diagonal form given in local center of mass coordinate frame defined by cmLocalTransform
cmLocalTransform- the frame in which the inertia tensor is given (optional, default: Identity)
autogenerateCmOffset- if true, the center of mass offset will be recalculated when the geometry configuration of the body changes (optional, default: false)
autogenerateInertia- if set to true, the inertia tensor will be recalculated when the geometry configuration of the body changes (optional, default: false)

◆ setIsPowerlineBody()

void agx::RigidBody::setIsPowerlineBody ( bool  isHydraulicBody)
inline

Internal method.

Definition at line 1331 of file RigidBody.h.

◆ setLinearVelocityDamping() [1/2]

void agx::RigidBody::setLinearVelocityDamping ( const agx::Vec3f damping)

Give linear velocity damping in each direction, given in local body coordinate frame.

The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).

Parameters
damping- the damping

◆ setLinearVelocityDamping() [2/2]

void agx::RigidBody::setLinearVelocityDamping ( float  damping)

Set linear velocity damping for the body in all directions x, y and z.

The unit of this damping is mass over time. Default: 0 (no damping)

Parameters
damping- the damping

◆ setLinearVelocityZeroDamping()

void agx::RigidBody::setLinearVelocityZeroDamping ( const agx::Vec3f dir)

Specify a vector (in body coordinates) along which no linear velocity damping should occur.

Default: (0, 0, 0)

Parameters
dir- direction, given in local body coordinate frame, in which the linear damping should be zero

◆ setLocalPosition() [1/2]

void agx::RigidBody::setLocalPosition ( agx::Real  x,
agx::Real  y,
agx::Real  z 
)

Set the position of the body relative to its model frame's parent frame.

Parameters
x- local x translate
y- local y translate
z- local z translate

◆ setLocalPosition() [2/2]

void agx::RigidBody::setLocalPosition ( const agx::Vec3 p)

Set the position of the body relative to its model frame's parent frame.

Parameters
p- local translate of body as a 3D vector

◆ setLocalRotation() [1/2]

void agx::RigidBody::setLocalRotation ( const agx::EulerAngles e)

Set the rotation of the body relative to its model frame's parent frame.

Parameters
e- rotation given as Euler angles

◆ setLocalRotation() [2/2]

void agx::RigidBody::setLocalRotation ( const agx::Quat q)

Set the rotation of the body relative to its model frame's parent frame.

Parameters
q- rotation given as a quaternion

◆ setLocalTransform()

void agx::RigidBody::setLocalTransform ( const agx::AffineMatrix4x4 matrix)

Assign the local transformation matrix for this body, ignoring any eventual parent transformation.

Parameters
matrix- transformation matrix relative to parent transform for the body's model frame

◆ setMotionControl()

void agx::RigidBody::setMotionControl ( agx::RigidBody::MotionControl  control)

Assign new motion control state to this rigid body.

If new state is STATIC - linear- and angular velocity will be set to zero. Default: DYNAMICS

Parameters
control- new motion control

◆ setName()

void agx::RigidBody::setName ( const agx::Name name)

Assign new name to this rigid body.

Default: ""

◆ setParentFrame()

bool agx::RigidBody::setParentFrame ( agx::Frame frame)

Set the parent frame of this body's model frame.

Note
This method is not supposed to be used in general. It can result in a bad/erratic behaviour. Only for internal use.

This means that getLocalTranslate, getLocalRotate, getLocalTransform will be given in the parents coordinate frame. I.e., this frame's transformation will be concatenated with the parents.

Parameters
frame- new parent frame, 0 to remove parent
Returns
true if parent is changed (not the same as before) - otherwise false

◆ setPosition() [1/2]

void agx::RigidBody::setPosition ( agx::Real  x,
agx::Real  y,
agx::Real  z 
)

Set the position of the model frame in world coordinates.

Parameters
x- desired x-coordinate in world frame
y- desired y-coordinate in world frame
z- desired z-coordinate in world frame

◆ setPosition() [2/2]

void agx::RigidBody::setPosition ( const agx::Vec3 p)

Set the position of the model frame in world coordinates.

Parameters
p- desired position in world coordinates.

◆ setPropertyContainer()

void agx::RigidBody::setPropertyContainer ( agx::PropertyContainer container)

Assign new property container.

Parameters
container- property container

◆ setRotation() [1/3]

void agx::RigidBody::setRotation ( const agx::EulerAngles e)

Set the rotation of the body relative to world frame.

Parameters
e- rotation given as Euler angles

◆ setRotation() [2/3]

void agx::RigidBody::setRotation ( const agx::OrthoMatrix3x3 m)

Set the rotation of the body relative to world frame.

Parameters
m- rotation given as an orthogonal transformation matrix

◆ setRotation() [3/3]

void agx::RigidBody::setRotation ( const agx::Quat q)

Set the rotation of the body relative to world frame.

Parameters
q- rotation given as a quaternion

◆ setSystem()

void agx::RigidBody::setSystem ( agx::DynamicsSystem system)
protected

Assign dynamics system where this body belongs to.

Parameters
system- dynamics system this body belongs to

◆ setTorque() [1/2]

void agx::RigidBody::setTorque ( agx::Real  tx,
agx::Real  ty,
agx::Real  tz 
)
inline

Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.

Note
Torque added before calling this method will be overwritten. Torque added after calling this method will be added to torque.
Parameters
tx,ty,tz- the torque

Definition at line 1321 of file RigidBody.h.

◆ setTorque() [2/2]

void agx::RigidBody::setTorque ( const agx::Vec3 torque)

Explicitly set the torque, given in world coordinate frame, that will be affecting this body in the next solve.

Note
Torque added before calling this method will be overwritten. Torque added after calling this method will be added to torque.
Parameters
torque- the torque

◆ setTransform()

void agx::RigidBody::setTransform ( const agx::AffineMatrix4x4 matrix)

Set the transform of the body.

The model frame will move to the specified transform, which is given in world coordinate frame.

Parameters
matrix- desired transform for the model frame in world coordinates.

◆ setVelocity() [1/2]

void agx::RigidBody::setVelocity ( agx::Real  vx,
agx::Real  vy,
agx::Real  vz 
)
inline

Set the linear velocity of the center of mass of this rigid body.

This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial velocity. If motion control is set to STATIC then the linear velocity will be set to zero - independent of the value of velocity. This method is seen as an instantaneous change in velocity (infinite acceleration), and will therefore not be represented by getAcceleration().

Parameters
vx,vy,vz- velocity given in world coordinate frame

Definition at line 1276 of file RigidBody.h.

◆ setVelocity() [2/2]

void agx::RigidBody::setVelocity ( const agx::Vec3 velocity)

Set the linear velocity of the center of mass of this rigid body.

This is the preferred way of moving KINEMATIC rigid bodies (a more convenient way is using moveTo(...)). The use for DYNAMIC is discouraged except for setting an initial velocity. If motion control is set to STATIC then the linear velocity will be set to zero - independent of the value of velocity. This method is seen as an instantaneous change in velocity (infinite acceleration), and will therefore not be represented by getAcceleration().

Parameters
velocity- velocity given in world coordinate frame

◆ setVelocityDamping()

void agx::RigidBody::setVelocityDamping ( float  damping)

Set both linear- and angular velocity damping in all directions.

See also
setLinearVelocityDamping, setAngularVelocityDamping
Parameters
damping- the damping

◆ shouldIgnoreGravity()

static bool agx::RigidBody::shouldIgnoreGravity ( agx::RigidBodyState  state)
inlinestatic
Returns
true if the specified body state should not be affected by a gravity field.

Definition at line 1037 of file RigidBody.h.

References DYNAMICS.

◆ transfer()

void agx::RigidBody::transfer ( agxData::EntityStorage storage)

Internal method.

Transfer data from one storage to another.

Parameters
storage- new storage

◆ updateMassProperties() [1/2]

void agx::RigidBody::updateMassProperties ( )

Method to explicitly update mass properties.

E.g., when the density is changed on a material which this rigid body depends on. This method uses the current mass property update mask. I.e., if this rigid body has an explicitly assigned mass, mass will not be updated during this call.

◆ updateMassProperties() [2/2]

void agx::RigidBody::updateMassProperties ( agx::UInt32  mask)

Method to explicitly update mass properties.

E.g., when the density is changed on a material which this rigid body depends on. This method takes the mass property update mask as argument. I.e., if this rigid body has an explicitly assigned mass, and mask contains agx::MassProperties::MASS, a new mass will be calculated and assigned.

Note
The mask passed to this method will not be stored. I.e., the mass property update state is the same before and after calling this method.
Parameters
mask- bit mask of agx::MassProperties::AutoGenerateFlags which mass properties that should be updated

The documentation for this class was generated from the following file: