AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxCollide/Line.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXCOLLIDE_LINE_H
18#define AGXCOLLIDE_LINE_H
19
21#include <agx/SPDMatrix3x3.h>
23#include <agxCollide/Shape.h>
25
26namespace agxCollide
27{
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
137 agx::Physics::Geometry::LinePtr getEntity() const;
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
163 AGX_FORCE_INLINE BoundingAABB Line::calculateBound(const agx::AffineMatrix4x4& transform, const agx::Vec3& firstPoint, const agx::Vec3& secondPoint)
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
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:38
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
A line shape for intersection tests, mostly for depth sensing and picking.
virtual ~Line(void)
agx::Vec3 getFirstPoint() const
Returns the first point, in local coordinates.
static BoundingAABB calculateBound(const agx::AffineMatrix4x4 &transform, const agx::Vec3 &firstPoint, const agx::Vec3 &secondPoint)
Calculate a bounding volume for line shape from parameters.
Line(const agx::Vec3 p1, const agx::Vec3 p2)
Constructor.
virtual agx::Real getVolume() const override
Volume of line-shape, will return 0.0 for line objects.
void set(const agx::Vec3 &p1, const agx::Vec3 &p2)
Set first and second point, in local coordinates.
void setFirstPoint(const agx::Vec3 &p)
Set first point (start point), in local coordinates.
virtual const BoundingAABB & updateBoundingVolume() override
Update the bounding volume for shape.
virtual agx::Vec3 getSupportPoint(const agx::Vec3 &supportDirection) const override
Gets support point.
virtual bool hasSupportFunction() const override
Checks if line shape has support function, will return true for line object.
virtual BoundingAABB calculateLocalBound() const override
Calculate a local bounding volume for shape.
agx::Vec3 getSecondPoint() const
Returns the second point, in local coordinates.
void setSecondPoint(const agx::Vec3 &p)
Set second point (end point), in local coordinates.
agx::Physics::Geometry::LinePtr getEntity() const
virtual agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override
Calculate inertia for line shape, will return identity matrix for line object.
Base class for a shape.
Definition: Shape.h:58
agx::Physics::Geometry::ShapeRef m_entity
Definition: Shape.h:295
const T & min() const
Definition: Bound.h:252
const T & max() const
Definition: Bound.h:255
Pointer to a entity instance of type Physics.Geometry.Line.
Definition: LineEntity.h:161
AGXPHYSICS_EXPORT agx::Line & line()
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
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
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
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41