AGX Dynamics  2.38.0.2
ollide/Line.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 #ifndef AGXCOLLIDE_LINE_H
18 #define AGXCOLLIDE_LINE_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agx/SPDMatrix3x3.h>
23 #include <agxCollide/Shape.h>
24 #include <agxStream/Serializable.h>
25 
26 namespace agxCollide
27 {
55  class AGXPHYSICS_EXPORT Line : public Shape
56  {
57  public:
63  Line( const agx::Vec3 p1, const agx::Vec3 p2 );
64 
69  virtual agx::Real getVolume() const override;
70 
75  void setFirstPoint( const agx::Vec3& p );
76 
81  void setSecondPoint( const agx::Vec3& p );
82 
88  void set(const agx::Vec3& p1, const agx::Vec3& p2);
89 
91  agx::Vec3 getFirstPoint() const;
92 
94  agx::Vec3 getSecondPoint() const;
95 
100  virtual bool hasSupportFunction() const override;
101 
107  virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
108 
114  virtual agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override;
115 
120  virtual const BoundingAABB& updateBoundingVolume() override;
121 
126  virtual BoundingAABB calculateLocalBound() const override;
127 
135  static BoundingAABB calculateBound(const agx::AffineMatrix4x4& transform, const agx::Vec3& firstPoint, const agx::Vec3& secondPoint);
136 
138 
140 
141  protected:
142  virtual ~Line( void );
143  Line() : Shape(LINE, agx::Physics::Geometry::LineModel::createInstance()) {}
144  };
145 
146 
147  /* Implementation */
149  {
150  return m_entity;
151  }
152 
154  {
155  return getEntity().line().p1;
156  }
157 
159  {
160  return getEntity().line().p2;
161  }
162 
164  {
165  BoundingAABB bound;
166  const agx::Vec3 p0 = firstPoint * transform;
167  const agx::Vec3 p1 = secondPoint * transform;
168  bound.min() = agx::Vec3::componentMin(p0, p1);
169  bound.max() = agx::Vec3::componentMax(p0, p1);
170  return bound;
171  }
172 }
173 
174 #endif
agxPhysics_export.h
Shape.h
SPDMatrix3x3.h
agx::Real
double Real
Definition: Real.h:42
agx::LineT::p1
T p1
Definition: Line.h:31
agxData::transform
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
agxCollide::Line::getEntity
agx::Physics::Geometry::LinePtr getEntity() const
Definition: ollide/Line.h:148
agx::AffineMatrix4x4T< Real >
LineEntity.h
agx::LineT::p2
T p2
Definition: Line.h:32
agxCollide::BoundingAABB
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:37
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agxCollide::Shape::m_entity
agx::Physics::Geometry::ShapeRef m_entity
Definition: Shape.h:266
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::Vec3T< Real >::componentMin
static Vec3T componentMin(const Vec3T &v1, const Vec3T &v2)
Creates a new vector where each component is the minimum of this and the other vector.
Definition: Vec3Template.h:379
agxCollide::Shape
Base class for a shape.
Definition: Shape.h:53
agxCollide::Line::getFirstPoint
agx::Vec3 getFirstPoint() const
Returns the first point, in local coordinates.
Definition: ollide/Line.h:153
agxCollide::Line
A line shape for intersection tests, mostly for depth sensing and picking.
Definition: ollide/Line.h:55
agx::BoundT::max
const T & max() const
Definition: Bound.h:255
agx::Vec3T< Real >::componentMax
static Vec3T componentMax(const Vec3T &v1, const Vec3T &v2)
Creates a new vector where each component is the maximum of this and the other vector.
Definition: Vec3Template.h:385
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:91
agx::BoundT::min
const T & min() const
Definition: Bound.h:252
agx::SPDMatrix3x3
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
Serializable.h
agx::Physics::Geometry::LinePtr::line
AGXPHYSICS_EXPORT agx::Line & line()
agx::Line
LineT< Vec3 > Line
Definition: Line.h:39
agxCollide::Line::calculateBound
static BoundingAABB calculateBound(const agx::AffineMatrix4x4 &transform, const agx::Vec3 &firstPoint, const agx::Vec3 &secondPoint)
Calculate a bounding volume for line shape from parameters.
Definition: ollide/Line.h:163
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxCollide::Line::getSecondPoint
agx::Vec3 getSecondPoint() const
Returns the second point, in local coordinates.
Definition: ollide/Line.h:158
agxCollide::AGX_DECLARE_POINTER_TYPES
AGX_DECLARE_POINTER_TYPES(SpaceListener)
agxCollide::Line::Line
Line()
Definition: ollide/Line.h:143
agx::Vec3T< Real >
agx::Physics::Geometry::LinePtr
Pointer to a entity instance of type Physics.Geometry.Line.
Definition: LineEntity.h:160
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxData::getEntity
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.