AGX Dynamics  2.35.0.1
ObserverFrame.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/agx.h>
20 #include <agx/RigidBody.h>
21 #include <agx/Frame.h>
22 
23 #ifdef _MSC_VER
24 # pragma warning(push)
25 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning
26 #endif
27 
28 namespace agx
29 {
30  class DynamicsSystem;
31  class AutoSleep;
32  class MergeSplitBodyStorage;
33 
37 
38 
44  {
45  public:
46 
47 
48  public:
62 
68  agx::Frame* getFrame();
69 
75  const agx::Frame* getFrame() const;
76 
84  void setTransform( const agx::AffineMatrix4x4& matrix );
85 
90 
95  void setLocalTransform( const agx::AffineMatrix4x4& matrix );
96 
101 
106  void setLocalPosition( const agx::Vec3& p );
107 
115 
120  void setRotation( const agx::Quat& q );
121 
126  void setRotation( const agx::EulerAngles& e);
127 
133 
138 
143  void setLocalRotation( const agx::Quat& q );
144 
150 
155 
159  const agx::Frame* getParentFrame() const;
160 
170  bool setParentFrame( agx::Frame* frame );
171 
176  void setPosition( const agx::Vec3& p );
177 
185 
191  void setEnable( bool enable );
192 
197  bool getEnable() const;
198 
203  bool isEnabled() const;
204 
209 
214 
215 
221 
227 
231  agx::Vec3 transformVectorToWorld(const agx::Vec3& vectorLocal) const;
232  agx::Vec3 transformVectorToLocal(const agx::Vec3& vectorWorld) const;
233  agx::Vec3 transformPointToWorld(const agx::Vec3& pointLocal) const;
234  agx::Vec3 transformPointToLocal(const agx::Vec3& pointWorld) const;
235 
240 
245 
250 
255 
260 
265 
270 
275 
280 
285 
290 
295 
300 
305 
312 
319 
323  void detach();
324 
326 
331 
335  const agx::RigidBody* getRigidBody() const;
336 
340  agx::RigidBody* getRigidBody();
341 
346  void setName( const agx::Name& name );
347 
356 
358 
359  protected:
360  friend class DynamicsSystem;
361 
362  virtual ~ObserverFrame();
363 
369 
370  private:
372 
373  private:
374  DynamicsSystem* m_mainSystem;
375 
376  FrameRef m_frame;
377  bool m_enabled;
378  agx::Name m_name;
379  agx::RigidBodyRef m_rigidBody;
380  };
381 
383  {
384  return m_enabled;
385  }
386 
388  {
389  return m_enabled;
390  }
391 
393  {
394  return m_frame.get();
395  }
396 
398  {
399  return m_frame.get();
400  }
401 
403  {
404  return m_rigidBody.get();
405  }
406 
408  {
409  return m_rigidBody.get();
410  }
411 
412 } // namespace agx
413 
414 #ifdef _MSC_VER
415 # pragma warning(pop)
416 #endif
417 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
The complete physical system with bodies, interactions, data layout, time stepper,...
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Definition: EulerAngles.h:70
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Representation of a name string.
Definition: Name.h:33
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:44
bool isEnabled() const
Access the state enable flag.
void setLocalPosition(const agx::Vec3 &p)
Assign the parent relative translate of this frame.
void detach()
Detach the current rigid body, setting the current rigid body to the world and the frame to identity.
void setRotation(const agx::Quat &q)
Set the rotation of the frame relative to world frame.
agx::Vec3 transformPointToWorld(const agx::Vec3 &pointLocal) const
void attach(agx::RigidBody *rb, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
Attach the ObserverFrame to a rigid body.
void setName(const agx::Name &name)
Assign new name to this observer frame.
ObserverFrame(const agx::Name &name="", agx::RigidBody *rb=nullptr, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
Construct given name.
agx::Vec3 getRelativeAngularVelocity(const agx::RigidBody *rb) const
Get the relative angular velocity of a rigid body and the ObserverFrame in the world.
void setPosition(agx::Real x, agx::Real y, agx::Real z)
Assign the final (world) translate of this frame.
agx::Vec3 getRelativePosition(const agx::RigidBody *body) const
Get the relative position (distance) of an observer frame and the RigidBody in the world.
void setLocalRotation(const agx::Quat &q)
Assign the parent relative rotation of this frame.
agx::Vec3 getRelativePosition(const agx::ObserverFrame *obs) const
Get the relative position (distance) of an observer frame and the ObserverFrame in the world.
agx::Vec3 transformVectorToWorld(const agx::Vec3 &vectorLocal) const
Wrapper functions for Frame.
agx::Frame * getParentFrame()
const agx::DynamicsSystem * getSystem() const
agx::Vec3 getRelativeAngularVelocity(const agx::ObserverFrame *obs) const
Get the relative angular velocity of an observer frame and the ObserverFrame in the world.
agx::DynamicsSystem * getSystem()
agx::Vec3 getLocalPosition() const
agx::Vec3 transformPointToLocal(const agx::Vec3 &pointWorld) const
agx::Vec3 getRelativeAcceleration(const agx::RigidBody *rb) const
Get the relative acceleration of a rigid body and the ObserverFrame in the world.
agx::Vec3 getRelativeVelocity(const agx::RigidBody *rb) const
Get the relative velocity of a rigid body and the ObserverFrame in the world.
bool setCmAndInertiaInObserver(agx::RigidBody *rb, const agx::SPDMatrix3x3 &inertia)
Set the specified inertia in the frame of the observer on the rigid body.
agx::Quat getRotation() const
Current model frame rotation, given in world coordinate frame.
agx::Vec3 getPosition() const
Current model frame position, given in world coordinate frame.
void setSystem(agx::DynamicsSystem *system)
Assign dynamics system which this body belongs to.
agx::Name getName() const
agx::Quat getLocalRotation() const
void setRotation(const agx::OrthoMatrix3x3 &m)
Set the rotation of the frame relative to world frame.
agx::Vec3 getRelativeAngularAcceleration(const agx::RigidBody *rb) const
Get the relative angular acceleration of a rigid body and the ObserverFrame in the world.
agx::Vec3 getAngularVelocity() const
Get the angular velocity of the ObserverFrame in the world.
void setRotation(const agx::EulerAngles &e)
Set the rotation of the frame relative to world frame.
agx::Vec3 getAngularAcceleration() const
Get the angular acceleration of the ObserverFrame in the world.
ObserverFrame(agx::RigidBody *rb, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
Construct without name.
const agx::Frame * getParentFrame() const
bool getEnable() const
Access the state enable flag.
agx::Vec3 getVelocity() const
Get the velocity of the ObserverFrame in the world.
const agx::AffineMatrix4x4 & getLocalTransform() const
const agx::RigidBody * getRigidBody() const
bool setParentFrame(agx::Frame *frame)
Set the parent Frame of this ObserverFrame.
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
virtual ~ObserverFrame()
void setLocalTransform(const agx::AffineMatrix4x4 &matrix)
Assign the local transformation matrix for this frame ignoring any eventual parent transformation.
agx::Vec3 getAcceleration() const
Get the acceleration of the ObserverFrame in the world.
agx::RigidBody * getAttachment() const
void setLocalRotation(const agx::EulerAngles &e)
Assign the parent relative rotation of this frame.
void setLocalPosition(agx::Real x, agx::Real y, agx::Real z)
Assign the parent relative translate of this frame.
void setPosition(const agx::Vec3 &p)
Assign the final (world) translate of this frame.
void attachWithWorldTransform(agx::RigidBody *rb, const agx::AffineMatrix4x4 &transform=agx::AffineMatrix4x4())
Attach the ObserverFrame to a rigid body.
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...
agx::Vec3 transformVectorToLocal(const agx::Vec3 &vectorWorld) const
agx::Vec3 getRelativeAngularAcceleration(const agx::ObserverFrame *obs) const
Get the relative angular acceleration of an observer frame and the ObserverFrame in the world.
agx::Vec3 getRelativeAcceleration(const agx::ObserverFrame *obs) const
Get the relative acceleration of an observer frame and the ObserverFrame in the world.
agx::Vec3 getRelativeVelocity(const agx::ObserverFrame *obs) const
Get the relative velocity of an observer frame and the ObserverFrame in the world.
void setEnable(bool enable)
Change state enable of this observer frame.
Specialized types of matrices for holding orthogonal transformation matrices.
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:49
T * get() const
Definition: ref_ptr.h:256
#define CALLABLE
Definition: macros.h:72
#define AGX_FORCE_INLINE
Definition: macros.h:58
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::SetVector< ObserverFrameRef > ObserverFrameRefSetVector
Definition: ObserverFrame.h:36
double Real
Definition: Real.h:42
void AGXPHYSICS_EXPORT init()
Initialize agx.