|
Momentum Scripting v1
|
#include <RigidBody.h>
Public Types | |
| enum | MotionControl { STATIC = 1 , KINEMATICS = 2 , DYNAMICS = 3 } |
Public Member Functions | |
| void | addForce (const Vec3 &force) |
| void | addForce (double fx, double fy, double fz) |
| void | addForceAtLocalCmPosition (const Vec3 &force, const Vec3 &position) |
| void | addForceAtLocalCmPosition (double fx, double fy, double fz, double px, double py, double pz) |
| void | addForceAtLocalPosition (const Vec3 &force, const Vec3 &position) |
| void | addForceAtLocalPosition (double fx, double fy, double fz, double px, double py, double pz) |
| void | addForceAtPosition (const Vec3 &force, const Vec3 &position) |
| void | addForceAtPosition (double fx, double fy, double fz, double px, double py, double pz) |
| void | addLocalTorque (const Vec3 &torque) |
| void | addLocalTorque (double tx, double ty, double tz) |
| void | addTorque (const Vec3 &torque) |
| void | addTorque (double tx, double ty, double tz) |
| agx::RigidBody * | body () const |
| Vec3 | getAngularAcceleration () const |
| Vec3 | getAngularMomentum () const |
| Vec3 | getAngularVelocity () const |
| Vec3 | getAngularVelocityDamping () const |
| Vec3 | getCmLocalTranslate () const |
| Vec3 | getCmPosition () const |
| AffineMatrix4x4 | getCmTransform () const |
| ContactPointVector | getContacts () const |
| bool | getEnable () const |
| Vec3 | getForce () const |
| GeometryVector | getGeometries () const |
| Matrix3x3 | getInertia () |
| Vec3 | getLastForce () const |
| Vec3 | getLastTorque () const |
| Vec3 | getLinearAcceleration () const |
| Vec3 | getLinearMomentum () const |
| Vec3 | getLinearVelocity () const |
| Vec3 | getLinearVelocityDamping () const |
| double | getMass () |
| Vec3 | getModelAcceleration (const Vec3 &relPos=Vec3()) const |
| Vec3 | getModelVelocity (const Vec3 &relPos=Vec3()) const |
| RigidBody::MotionControl | getMotionControl () const |
| std::string | getName () const |
| size_t | getNumConstraints () const |
| Vec3 | getPosition () const |
| Quat | getRotation () const |
| double | getRotationalEnergy () const |
| Vec3 | getTorque () const |
| double | getTotalEnergy () const |
| AffineMatrix4x4 | getTransform () const |
| double | getTranslationalEnergy () const |
| bool | is (agx::RigidBody *body) const |
| bool | isEmittedBody () const |
| void | moveTo (const AffineMatrix4x4 &target, double t) |
| void | moveTo (const Vec3 &targetPosition, const Quat &targetRotation, double dt) |
| bool | operator== (const RigidBody &other) const |
| void | setAngularVelocity (const Vec3 &angularVelocity) |
| void | setAngularVelocity (double vx, double vy, double vz) |
| void | setAngularVelocityDamping (const Vec3 &damping) |
| void | setAngularVelocityDamping (double damping) |
| bool | setCmAndInertiaInObserver (const Observer &observer, const Matrix3x3 &inertia) |
| void | setCmLocalTranslate (const Vec3 &translate) |
| void | setCmPosition (const Vec3 &p) |
| void | setCmTransform (const AffineMatrix4x4 &matrix) |
| void | setEnable (bool enable) |
| void | setForce (const Vec3 &force) |
| void | setForce (double fx, double fy, double fz) |
| bool | setInertia (Matrix3x3 inertia) |
| void | setLinearVelocity (const Vec3 &velocity) |
| void | setLinearVelocity (double vx, double vy, double vz) |
| void | setLinearVelocityDamping (const Vec3 &damping) |
| void | setLinearVelocityDamping (double damping) |
| void | setMass (double mass) |
| void | setMotionControl (RigidBody::MotionControl control) |
| void | setPosition (const Vec3 &p) |
| void | setPosition (double x, double y, double z) |
| void | setRotation (const EulerAngles *e) |
| void | setRotation (const Quat &q) |
| void | setTorque (const Vec3 &torque) |
| void | setTorque (double tx, double ty, double tz) |
| void | setTransform (const AffineMatrix4x4 &matrix) |
| void | setVelocityDamping (double damping) |
A rigid body is a moving (translation/rotation) object with a mass and a inertia.
It can contain zero or more geometries.
The MotionControl enumeration indicates what makes a RigidBody move.
There are three forms of motion allowed:
| void MOMENTUM_NAMESPACE::RigidBody::addForce | ( | const Vec3 & | force | ) |
Adds the force, given in world coordinate system, that will be affecting this body in the next solve.
| force | - the force, given in world coordinate system, |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForce | ( | double | fx, |
| double | fy, | ||
| double | fz | ||
| ) |
Adds the force, given in world coordinate system, that will be affecting this body in the next solve.
| fx,fy,fz | - the force, given in world coordinate system, |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtLocalCmPosition | ( | const Vec3 & | force, |
| const Vec3 & | position | ||
| ) |
Add a force, given in world coordinate system, applied at a position relative to the center of mass.
Whenever the position is different from (0,0,0), this method will also introduce a torque.
| force | - the force, given in world coordinate system, to be added to the already previously added forces |
| position | - the position in local center of mass coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtLocalCmPosition | ( | double | fx, |
| double | fy, | ||
| double | fz, | ||
| double | px, | ||
| double | py, | ||
| double | pz | ||
| ) |
Add a force, given in world coordinate system, applied at a position relative to the center of mass.
Whenever the position is different from (0,0,0), this method will also introduce a torque.
| fx,fy,fz | - the force, given in world coordinate system, to be added to the already previously added forces |
| px,py,pz | - the position in local center of mass coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtLocalPosition | ( | const Vec3 & | force, |
| const Vec3 & | position | ||
| ) |
Add a force, given in world coordinate system, applied at a position given in local rigid body coordinate system.
If the position is different from the center of mass, a torque will be calculated and added as well.
| force | - the force, given in world coordinate system, to be added to the already previously added forces |
| position | - the position given in local coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtLocalPosition | ( | double | fx, |
| double | fy, | ||
| double | fz, | ||
| double | px, | ||
| double | py, | ||
| double | pz | ||
| ) |
Add a force, given in world coordinate system, applied at a position given in local rigid body coordinate system.
If the position is different from the center of mass, a torque will be calculated and added as well.
| fx,fy,fz | - the force, given in world coordinate system, to be added to the already previously added forces |
| px,py,pz | - the position given in local coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtPosition | ( | const Vec3 & | force, |
| const Vec3 & | position | ||
| ) |
Add a force, given in world coordinate system, applied at a position given in world coordinate system.
If the position is different from the center of mass, a torque will be calculated and added as well.
| force | - the force, given in world coordinate system, to be added to the already previously added forces |
| position | - the position given in world coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addForceAtPosition | ( | double | fx, |
| double | fy, | ||
| double | fz, | ||
| double | px, | ||
| double | py, | ||
| double | pz | ||
| ) |
Add a force, given in world coordinate system, applied at a position given in world coordinate system.
If the position is different from the center of mass, a torque will be calculated and added as well.
| fx,fy,fz | - the force, given in world coordinate system, to be added to the already previously added forces |
| px,py,pz | - the position given in world coordinate system where the force should be applied |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addLocalTorque | ( | const Vec3 & | torque | ) |
Adds the torque, given in local coordinate system, that will be affecting this body in the next solve.
| torque | - the torque |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addLocalTorque | ( | double | tx, |
| double | ty, | ||
| double | tz | ||
| ) |
Adds the torque, given in local coordinate system, that will be affecting this body in the next solve.
| tx,ty,tz | - the torque, given in local coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addTorque | ( | const Vec3 & | torque | ) |
Adds the torque, given in world coordinate system, that will be affecting this body in the next solve.
| torque | - the torque, given in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::addTorque | ( | double | tx, |
| double | ty, | ||
| double | tz | ||
| ) |
Adds the torque, given in world coordinate system, that will be affecting this body in the next solve.
| tx,ty,tz | - the torque, given in world coordinate system |
Only available in simulation mode
| agx::RigidBody * MOMENTUM_NAMESPACE::RigidBody::body | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getAngularAcceleration | ( | ) | const |
Will always be 0 for KINEMATIC and STATIC bodies.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getAngularMomentum | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getAngularVelocity | ( | ) | const |
Angular velocity in world coordinate system.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getAngularVelocityDamping | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getCmLocalTranslate | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getCmPosition | ( | ) | const |
| AffineMatrix4x4 MOMENTUM_NAMESPACE::RigidBody::getCmTransform | ( | ) | const |
| ContactPointVector MOMENTUM_NAMESPACE::RigidBody::getContacts | ( | ) | const |
Get all contacts in which this rigid body is involved.
| bool MOMENTUM_NAMESPACE::RigidBody::getEnable | ( | ) | const |
Access the state enable flag.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getForce | ( | ) | const |
| GeometryVector MOMENTUM_NAMESPACE::RigidBody::getGeometries | ( | ) | const |
Get all geometries of the rigid body.
| Matrix3x3 MOMENTUM_NAMESPACE::RigidBody::getInertia | ( | ) |
Get the inertia of the rigid body in the specified coordinate system.
| frame | the frame in which to read the inertia |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLastForce | ( | ) | const |
Access the summed force applied to this rigid body last time the system was integrated.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLastTorque | ( | ) | const |
Access the summed torque applied to this rigid body last time the system was integrated.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLinearAcceleration | ( | ) | const |
Will always be 0 for KINEMATIC and STATIC bodies.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLinearMomentum | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLinearVelocity | ( | ) | const |
Velocity of center of mass in world coordinate system.
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getLinearVelocityDamping | ( | ) | const |
| double MOMENTUM_NAMESPACE::RigidBody::getMass | ( | ) |
Get the mass of the rigid body in kilograms.
Calculates the linear acceleration at the given point relPos.
The point relPos must be given in model coordinate system. The resulting linear acceleration is given in world coordinate system.
| relPos | - relative position given in model frame coordinates |
relPos Calculates the linear velocity at the given point relPos.
The point relPos must be given in model coordinate system. The resulting linear velocity is given in world coordinate system.
| relPos | - relative position given in model frame coordinates |
relPos | RigidBody::MotionControl MOMENTUM_NAMESPACE::RigidBody::getMotionControl | ( | ) | const |
| std::string MOMENTUM_NAMESPACE::RigidBody::getName | ( | ) | const |
| size_t MOMENTUM_NAMESPACE::RigidBody::getNumConstraints | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getPosition | ( | ) | const |
Current rigid body position, given in world coordinate system.
| Quat MOMENTUM_NAMESPACE::RigidBody::getRotation | ( | ) | const |
Current rigid body rotation, given in world coordinate system.
| double MOMENTUM_NAMESPACE::RigidBody::getRotationalEnergy | ( | ) | const |
| Vec3 MOMENTUM_NAMESPACE::RigidBody::getTorque | ( | ) | const |
| double MOMENTUM_NAMESPACE::RigidBody::getTotalEnergy | ( | ) | const |
| AffineMatrix4x4 MOMENTUM_NAMESPACE::RigidBody::getTransform | ( | ) | const |
Current rigid body transformation, given in world coordinate system.
| double MOMENTUM_NAMESPACE::RigidBody::getTranslationalEnergy | ( | ) | const |
| bool MOMENTUM_NAMESPACE::RigidBody::is | ( | agx::RigidBody * | body | ) | const |
Check if this a representation of the specified agx::RigidBody.
| body | the body to check |
| bool MOMENTUM_NAMESPACE::RigidBody::isEmittedBody | ( | ) | const |
| void MOMENTUM_NAMESPACE::RigidBody::moveTo | ( | const AffineMatrix4x4 & | target, |
| double | 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.
| target | - target transform given in world coordinate system |
| t | - time this rigid body has to reach the target |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::moveTo | ( | const Vec3 & | targetPosition, |
| const Quat & | targetRotation, | ||
| double | dt | ||
| ) |
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.
| targetPosition | - target position given in world coordinate system |
| targetRotation | - target rotation given in world coordinate system |
| t | - time this rigid body has to reach the target |
Only available in simulation mode
| bool MOMENTUM_NAMESPACE::RigidBody::operator== | ( | const RigidBody & | other | ) | const |
| void MOMENTUM_NAMESPACE::RigidBody::setAngularVelocity | ( | const 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().
| angularVelocity | - angular velocity given in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setAngularVelocity | ( | double | vx, |
| double | vy, | ||
| double | vz | ||
| ) |
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().
| vx,vy,vz | - angular velocity given in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setAngularVelocityDamping | ( | const Vec3 & | damping | ) |
Give angular velocity damping in each direction, given in local body coordinate system.
The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).
| damping | - the damping |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setAngularVelocityDamping | ( | double | 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)
| damping | - the damping |
Only available in simulation mode
| bool MOMENTUM_NAMESPACE::RigidBody::setCmAndInertiaInObserver | ( | const Observer & | observer, |
| const Matrix3x3 & | inertia | ||
| ) |
Assign a new center of mass and inertia tensor using an observer.
The center of mass is set to the location of the Observer, and the inertia is specified in the frame of the Observer.
| observer | the observer to set the cm to and base the inertia on |
| inertia | the new inertia of the body in the frame of the observer |
Only availible in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setCmLocalTranslate | ( | const Vec3 & | translate | ) |
Sets the local offset of the center of mass position to the model origin (in the local rigid body coordinate system).
| translate | The new offset. |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setCmPosition | ( | const Vec3 & | p | ) |
Assign new center of mass position, given in world coordinate frame.
By default the rigid body position will be updated as well (synchronizeModel).
| matrix | - new center of mass position given in world coordinate system |
| synchronizeModel | - default true, if false the rigid body positition will not be updated with this new position |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setCmTransform | ( | const AffineMatrix4x4 & | matrix | ) |
Assign new center of mass transform, given in world coordinate frame.
By default the model frame will be updated as well (synchronizeModel).
| matrix | - new matrix transform given in world coordinate system |
| synchronizeModel | - default true, if false the model frame will not be updated with this new transform. |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setEnable | ( | bool | enable | ) |
Change state enable of this rigid body.
Default: true.
| enable | - true to enable, false to disable |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setForce | ( | const Vec3 & | force | ) |
Explicitly set the force, given in world coordinate system, that will be affecting this body in the next solve.
force. | force | - the force |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setForce | ( | double | fx, |
| double | fy, | ||
| double | fz | ||
| ) |
Explicitly set the force, given in world coordinate system, that will be affecting this body in the next solve.
force. | fx,fy,fz | - the force |
Only available in simulation mode
| bool MOMENTUM_NAMESPACE::RigidBody::setInertia | ( | Matrix3x3 | inertia | ) |
Set the inertia of the rigid body in the specified coordinate system.
| inertia | the inertia matrix to set. |
| frame | the frame in which to write the inertia |
| void MOMENTUM_NAMESPACE::RigidBody::setLinearVelocity | ( | const 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().
| velocity | - velocity given in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setLinearVelocity | ( | double | vx, |
| double | vy, | ||
| double | vz | ||
| ) |
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().
| vx,vy,vz | - velocity given in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setLinearVelocityDamping | ( | const Vec3 & | damping | ) |
Give linear velocity damping in each direction, given in local body coordinate system.
The unit of this damping is mass over time. Default: (0, 0, 0) (no damping).
| damping | - the damping |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setLinearVelocityDamping | ( | double | 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)
| damping | - the damping |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setMass | ( | double | mass | ) |
Set the mass of the rigid body in kilograms.
| mass | the new mass |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setMotionControl | ( | 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
| control | - new motion control |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setPosition | ( | const Vec3 & | p | ) |
Set the position of the model frame in world coordinate system.
| p | - desired position in world coordinate system. |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setPosition | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Set the position of the model frame in world coordinate system.
| x | - desired x-coordinate in world coordinate system |
| y | - desired y-coordinate in world coordinate system |
| z | - desired z-coordinate in world coordinate system |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setRotation | ( | const EulerAngles * | e | ) |
Set the rotation of the body relative to world coordinate system.
| e | - rotation given as Euler angles |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setRotation | ( | const Quat & | q | ) |
Set the rotation of the body relative to world coordinate system.
| q | - rotation given as a quaternion |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setTorque | ( | const Vec3 & | torque | ) |
Explicitly set the torque, given in world coordinate system, that will be affecting this body in the next solve.
torque. | torque | - the torque |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setTorque | ( | double | tx, |
| double | ty, | ||
| double | tz | ||
| ) |
Explicitly set the torque, given in world coordinate system, that will be affecting this body in the next solve.
torque. | tx,ty,tz | - the torque |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setTransform | ( | const AffineMatrix4x4 & | matrix | ) |
Set the transformation of the body in world coordinate system.
| matrix | - desired transform for the model frame in world coordinates. |
Only available in simulation mode
| void MOMENTUM_NAMESPACE::RigidBody::setVelocityDamping | ( | double | damping | ) |
Set both linear- and angular velocity damping in all directions.
| damping | - the damping |
Only available in simulation mode