AGX Dynamics 2.41.2.0
Loading...
Searching...
No Matches
agx::ObserverFrame Class Reference

With this class you can attach an ObserverFrame object relative to a RigidBody. More...

#include <ObserverFrame.h>

+ Inheritance diagram for agx::ObserverFrame:

Public Member Functions

 ObserverFrame (agx::RigidBody *body, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
 Construct without name.
 
 ObserverFrame (const agx::Name &name="", agx::RigidBody *body=nullptr, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
 Construct given name.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agx::ObserverFrame)
 
void attach (agx::RigidBody *body, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
 Attach the ObserverFrame to a rigid body.
 
void attachWithWorldTransform (agx::RigidBody *body, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
 Attach the ObserverFrame to a rigid body.
 
void detach ()
 Detach the current rigid body, setting the current rigid body to the world and the frame to identity.
 
agx::Vec3 getAcceleration () const
 
agx::Vec3 getAngularAcceleration () const
 
agx::Vec3 getAngularVelocity () const
 
agx::RigidBodygetAttachment () const
 
bool getEnable () const
 Access the state enable flag.
 
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.
 
agx::Vec3 getLocalPosition () const
 
agx::Quat getLocalRotation () const
 
const agx::AffineMatrix4x4getLocalTransform () const
 
agx::Name getName () const
 
agx::FramegetParentFrame ()
 
const agx::FramegetParentFrame () const
 
agx::Vec3 getPosition () const
 Current model frame position, given in world coordinate frame.
 
agx::Vec3 getRelativeAcceleration (const agx::ObserverFrame *obs) const
 
agx::Vec3 getRelativeAcceleration (const agx::RigidBody *body) const
 
agx::Vec3 getRelativeAngularAcceleration (const agx::ObserverFrame *obs) const
 
agx::Vec3 getRelativeAngularAcceleration (const agx::RigidBody *body) const
 
agx::Vec3 getRelativeAngularVelocity (const agx::ObserverFrame *obs) const
 
agx::Vec3 getRelativeAngularVelocity (const agx::RigidBody *body) const
 
agx::Vec3 getRelativePosition (const agx::ObserverFrame *obs) const
 
agx::Vec3 getRelativePosition (const agx::RigidBody *body) const
 
agx::Quat getRelativeRotation (const agx::ObserverFrame *obs) const
 
agx::Quat getRelativeRotation (const agx::RigidBody *body) const
 
agx::Vec3 getRelativeVelocity (const agx::ObserverFrame *obs) const
 
agx::Vec3 getRelativeVelocity (const agx::RigidBody *body) const
 
agx::RigidBodygetRigidBody ()
 
const agx::RigidBodygetRigidBody () const
 
agx::Quat getRotation () const
 Current model frame rotation, given in world coordinate frame.
 
agx::DynamicsSystemgetSystem ()
 
const agx::DynamicsSystemgetSystem () const
 
agx::Vec3 getVelocity () const
 
bool isEnabled () const
 Access the state enable flag.
 
bool setCmAndInertiaInObserver (agx::RigidBody *body, const agx::SPDMatrix3x3 &inertia)
 Set the specified inertia in the frame of the observer on the rigid body.
 
void setEnable (bool enable)
 Change state enable of this ObserverFrame.
 
void setLocalPosition (agx::Real x, agx::Real y, agx::Real z)
 Assign the parent relative translate of this frame.
 
void setLocalPosition (const agx::Vec3 &p)
 Assign the parent relative translate of this frame.
 
void setLocalRotation (const agx::EulerAngles &e)
 Assign the parent relative rotation of this frame.
 
void setLocalRotation (const agx::Quat &q)
 Assign the parent relative rotation of this frame.
 
void setLocalTransform (const agx::AffineMatrix4x4 &matrix)
 Assign the local transformation matrix for this frame ignoring any eventual parent transformation.
 
void setName (const agx::Name &name)
 Assign new name to this ObserverFrame.
 
bool setParentFrame (agx::Frame *frame)
 Set the parent Frame of this ObserverFrame.
 
void setPosition (agx::Real x, agx::Real y, agx::Real z)
 Assign the final (world) translate of this frame.
 
void setPosition (const agx::Vec3 &p)
 Assign the final (world) translate of this frame.
 
void setRotation (const agx::EulerAngles &e)
 Set the rotation of the frame relative to world frame.
 
void setRotation (const agx::OrthoMatrix3x3 &m)
 Set the rotation of the frame relative to world frame.
 
void setRotation (const agx::Quat &q)
 Set the rotation of the frame relative to world frame.
 
void setTransform (const agx::AffineMatrix4x4 &matrix)
 This method will set the local matrix of this frame to be the matrix m multiplied with the inverse of the parents matrix: M = m * inv(parent) I.e., assign the final (world) transform of this frame.
 
agx::Vec3 transformPointToLocal (const agx::Vec3 &pointWorld) const
 
agx::Vec3 transformPointToWorld (const agx::Vec3 &pointLocal) const
 
agx::Vec3 transformVectorToLocal (const agx::Vec3 &vectorWorld) const
 
agx::Vec3 transformVectorToWorld (const agx::Vec3 &vectorLocal) const
 
- 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 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

virtual ~ObserverFrame ()
 
void setSystem (agx::DynamicsSystem *system)
 Assign dynamics system which 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

With this class you can attach an ObserverFrame object relative to a RigidBody.

It allows for queering position/rotation/velocity in a coordinate system that is local to this ObserverFrame.

Definition at line 41 of file ObserverFrame.h.

Constructor & Destructor Documentation

◆ ObserverFrame() [1/2]

agx::ObserverFrame::ObserverFrame ( const agx::Name name = "",
agx::RigidBody body = nullptr,
const agx::AffineMatrix4x4 transform = agx::AffineMatrix4x4() 
)

Construct given name.

Default: rigid body = nullptr/world, transform = identity

Parameters
name- name of this ObserverFrame (default: "")
body- the rigid body to attach to, by default world
transform- the frame of reference of the ObserverFrame

◆ ObserverFrame() [2/2]

agx::ObserverFrame::ObserverFrame ( agx::RigidBody body,
const agx::AffineMatrix4x4 transform = agx::AffineMatrix4x4() 
)

Construct without name.

Default: transform = identity

Parameters
body- the rigid body to attach to, null if world
transform- the frame of reference of the ObserverFrame

◆ ~ObserverFrame()

virtual agx::ObserverFrame::~ObserverFrame ( )
protectedvirtual

Member Function Documentation

◆ AGXSTREAM_DECLARE_SERIALIZABLE_BASE()

agx::ObserverFrame::AGXSTREAM_DECLARE_SERIALIZABLE_BASE ( agx::ObserverFrame  )

◆ attach()

void agx::ObserverFrame::attach ( agx::RigidBody body,
const agx::AffineMatrix4x4 transform = agx::AffineMatrix4x4() 
)

Attach the ObserverFrame to a rigid body.

This will remove previous attachments.

  • body The rigid body to attach to, null if world
  • transform The transform relative to the body

◆ attachWithWorldTransform()

void agx::ObserverFrame::attachWithWorldTransform ( agx::RigidBody body,
const agx::AffineMatrix4x4 transform = agx::AffineMatrix4x4() 
)

Attach the ObserverFrame to a rigid body.

This will remove previous attachments.

  • body The rigid body to attach to, null if world
  • transform The transform in the world

◆ create()

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

Definition at line 377 of file ObserverFrame.h.

◆ detach()

void agx::ObserverFrame::detach ( )

Detach the current rigid body, setting the current rigid body to the world and the frame to identity.

◆ getAcceleration()

agx::Vec3 agx::ObserverFrame::getAcceleration ( ) const
Returns
the acceleration of the ObserverFrame in the world

◆ getAngularAcceleration()

agx::Vec3 agx::ObserverFrame::getAngularAcceleration ( ) const
Returns
the angular acceleration of the ObserverFrame in the world

◆ getAngularVelocity()

agx::Vec3 agx::ObserverFrame::getAngularVelocity ( ) const
Returns
the angular velocity of the ObserverFrame in the world

◆ getAttachment()

agx::RigidBody * agx::ObserverFrame::getAttachment ( ) const

◆ getEnable()

bool agx::ObserverFrame::getEnable ( ) const

Access the state enable flag.

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

Definition at line 402 of file ObserverFrame.h.

◆ getFrame() [1/2]

Frame * agx::ObserverFrame::getFrame ( )

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

Returns
model frame of this ObserverFrame

Definition at line 412 of file ObserverFrame.h.

References agx::ref_ptr< T >::get().

◆ getFrame() [2/2]

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

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

Returns
model frame of this ObserverFrame

Definition at line 417 of file ObserverFrame.h.

References agx::ref_ptr< T >::get().

◆ getLocalPosition()

agx::Vec3 agx::ObserverFrame::getLocalPosition ( ) const
Returns
the relative translate to this frame's parent frame

◆ getLocalRotation()

agx::Quat agx::ObserverFrame::getLocalRotation ( ) const
Returns
the relative rotation to this frame's parent frame

◆ getLocalTransform()

const agx::AffineMatrix4x4 & agx::ObserverFrame::getLocalTransform ( ) const
Returns
the local transformation matrix (i.e., the transformation relative to the parent)

◆ getName()

agx::Name agx::ObserverFrame::getName ( ) const
Returns
the name of this ObserverFrame

◆ getParentFrame() [1/2]

agx::Frame * agx::ObserverFrame::getParentFrame ( )
Returns
a pointer to the parent frame, 0 if this frame has no parent

◆ getParentFrame() [2/2]

const agx::Frame * agx::ObserverFrame::getParentFrame ( ) const
Returns
a pointer to the parent frame, 0 if this frame has no parent

◆ getPosition()

agx::Vec3 agx::ObserverFrame::getPosition ( ) const

Current model frame position, given in world coordinate frame.

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

◆ getRelativeAcceleration() [1/2]

agx::Vec3 agx::ObserverFrame::getRelativeAcceleration ( const agx::ObserverFrame obs) const
Returns
the relative acceleration of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativeAcceleration() [2/2]

agx::Vec3 agx::ObserverFrame::getRelativeAcceleration ( const agx::RigidBody body) const
Returns
the relative acceleration of this ObserverFrame and a RigidBody body in the world coordinate frame

◆ getRelativeAngularAcceleration() [1/2]

agx::Vec3 agx::ObserverFrame::getRelativeAngularAcceleration ( const agx::ObserverFrame obs) const
Returns
the relative angular acceleration of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativeAngularAcceleration() [2/2]

agx::Vec3 agx::ObserverFrame::getRelativeAngularAcceleration ( const agx::RigidBody body) const
Returns
the relative angular acceleration of this ObserverFrame and a RigidBody body in the world coordinate frame

◆ getRelativeAngularVelocity() [1/2]

agx::Vec3 agx::ObserverFrame::getRelativeAngularVelocity ( const agx::ObserverFrame obs) const
Returns
the relative angular velocity of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativeAngularVelocity() [2/2]

agx::Vec3 agx::ObserverFrame::getRelativeAngularVelocity ( const agx::RigidBody body) const
Returns
the relative angular velocity of this ObserverFrame and a RigidBody body in the world coordinate frame

◆ getRelativePosition() [1/2]

agx::Vec3 agx::ObserverFrame::getRelativePosition ( const agx::ObserverFrame obs) const
Returns
the relative position of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativePosition() [2/2]

agx::Vec3 agx::ObserverFrame::getRelativePosition ( const agx::RigidBody body) const
Returns
the relative position of this ObserverFrame and a RigidBody body in the world coordinate frame

◆ getRelativeRotation() [1/2]

agx::Quat agx::ObserverFrame::getRelativeRotation ( const agx::ObserverFrame obs) const
Returns
the relative rotation of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativeRotation() [2/2]

agx::Quat agx::ObserverFrame::getRelativeRotation ( const agx::RigidBody body) const
Returns
the relative rotation (distance) of a RigidBody body and this ObserverFrame in the world

◆ getRelativeVelocity() [1/2]

agx::Vec3 agx::ObserverFrame::getRelativeVelocity ( const agx::ObserverFrame obs) const
Returns
the relative velocity of this ObserverFrame and an ObserverFrame obs in the world coordinate frame

◆ getRelativeVelocity() [2/2]

agx::Vec3 agx::ObserverFrame::getRelativeVelocity ( const agx::RigidBody body) const
Returns
the relative velocity of this ObserverFrame and a RigidBody body in the world coordinate frame

◆ getRigidBody() [1/2]

agx::RigidBody * agx::ObserverFrame::getRigidBody ( )
inline
Returns
the rigid body this ObserverFrame is attached to

Definition at line 427 of file ObserverFrame.h.

References agx::ref_ptr< T >::get().

◆ getRigidBody() [2/2]

const agx::RigidBody * agx::ObserverFrame::getRigidBody ( ) const
inline
Returns
the rigid body this ObserverFrame is attached to

Definition at line 422 of file ObserverFrame.h.

References agx::ref_ptr< T >::get().

◆ getRotation()

agx::Quat agx::ObserverFrame::getRotation ( ) const

Current model frame rotation, given in world coordinate frame.

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

◆ getSystem() [1/2]

agx::DynamicsSystem * agx::ObserverFrame::getSystem ( )
Returns
a pointer to the DynamicsSystem this ObserverFrame belongs to

◆ getSystem() [2/2]

const agx::DynamicsSystem * agx::ObserverFrame::getSystem ( ) const
Returns
a pointer to the DynamicsSystem this ObserverFrame belongs to

◆ getVelocity()

agx::Vec3 agx::ObserverFrame::getVelocity ( ) const
Returns
the velocity of the ObserverFrame in the world

◆ isEnabled()

bool agx::ObserverFrame::isEnabled ( ) const

Access the state enable flag.

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

Definition at line 407 of file ObserverFrame.h.

◆ setCmAndInertiaInObserver()

bool agx::ObserverFrame::setCmAndInertiaInObserver ( agx::RigidBody body,
const agx::SPDMatrix3x3 inertia 
)

Set the specified inertia in the frame of the observer on the rigid body.

Also set the center of mass to the origin of the observer

Parameters
bodyThe rigid body to change the inertia on
inertiaThe inertia in the frame of the observer
Returns
False if fails. This means that an invalid inertia is used. Otherwise True

◆ setEnable()

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

Change state enable of this ObserverFrame.

Default: true.

Parameters
enable- true to enable, false to disable

◆ setLocalPosition() [1/2]

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

Assign the parent relative translate of this frame.

Parameters
x- parent relative x translate
y- parent relative y translate
z- parent relative z translate

◆ setLocalPosition() [2/2]

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

Assign the parent relative translate of this frame.

Parameters
p- parent relative translate

◆ setLocalRotation() [1/2]

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

Assign the parent relative rotation of this frame.

Parameters
e- rotation given as Euler angles

◆ setLocalRotation() [2/2]

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

Assign the parent relative rotation of this frame.

Parameters
q- rotation given as a quaternion

◆ setLocalTransform()

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

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

Parameters
matrix- relative to parent transform for this frame

◆ setName()

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

Assign new name to this ObserverFrame.

Default: ""

◆ setParentFrame()

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

Set the parent Frame of this ObserverFrame.

This means that getTranslate, getRotate, getTransform 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::ObserverFrame::setPosition ( agx::Real  x,
agx::Real  y,
agx::Real  z 
)

Assign the final (world) translate of this frame.

Parameters
x- final (world) x translate of this frame
y- final (world) y translate of this frame
z- final (world) z translate of this frame

◆ setPosition() [2/2]

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

Assign the final (world) translate of this frame.

Parameters
p- final (world) translate of this frame

◆ setRotation() [1/3]

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

Set the rotation of the frame relative to world frame.

Parameters
e- rotation given as Euler angles

◆ setRotation() [2/3]

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

Set the rotation of the frame relative to world frame.

Parameters
m- rotation given as an orthogonal transformation matrix

◆ setRotation() [3/3]

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

Set the rotation of the frame relative to world frame.

Parameters
q- rotation given as a quaternion

◆ setSystem()

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

Assign dynamics system which this body belongs to.

Parameters
system- dynamics system which this body belongs to

References agx::init().

◆ setTransform()

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

This method will set the local matrix of this frame to be the matrix m multiplied with the inverse of the parents matrix: M = m * inv(parent) I.e., assign the final (world) transform of this frame.

Parameters
matrix- final transform for this frame (leads to local transform = matrix * inv(parent))

◆ transformPointToLocal()

agx::Vec3 agx::ObserverFrame::transformPointToLocal ( const agx::Vec3 pointWorld) const
Returns
the point pointWorld transformed to the local coordinate system of the ObserverFrame.

◆ transformPointToWorld()

agx::Vec3 agx::ObserverFrame::transformPointToWorld ( const agx::Vec3 pointLocal) const
Returns
the point pointLocal transformed to the world.

◆ transformVectorToLocal()

agx::Vec3 agx::ObserverFrame::transformVectorToLocal ( const agx::Vec3 vectorWorld) const
Returns
the point pointLocal transformed to the local coordinate system of the ObserverFrame.

◆ transformVectorToWorld()

agx::Vec3 agx::ObserverFrame::transformVectorToWorld ( const agx::Vec3 vectorLocal) const
Returns
the vector vectorLocal transformed to the world.

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