AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Cylinder.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_CYLINDER_H
18#define AGXCOLLIDE_CYLINDER_H
19
21
23#include <agxCollide/Shape.h>
24#include <agxCollide/Capsule.h>
25
26namespace agxCollide
27{
28
35 {
36 public:
42 Cylinder( const agx::Real radius, const agx::Real height );
43
48 void setHeight( const agx::Real height );
49
54 void setRadius( const agx::Real radius );
55
61 void set( const agx::Real radius, const agx::Real height );
62
64 agx::Real getHeight() const;
65
67 agx::Real getRadius() const;
68
74
79 virtual agx::Real getVolume() const override;
80
81 virtual bool hasSupportFunction() const override;
82 virtual Shape *clone() const override;
83
84 virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
85 virtual const BoundingAABB& updateBoundingVolume() override;
86 virtual BoundingAABB calculateLocalBound() const override;
87 static BoundingAABB calculateBound(const agx::AffineMatrix4x4& transform, const agx::Real radius, const agx::Real height);
88
90
91
92 agx::Physics::Geometry::CylinderPtr getEntity() const;
93
96
97 protected:
98
101
103 Cylinder(agx::Real radius, agx::Real height, agxCollide::Shape::Type type, agx::Physics::Geometry::ShapePtr entity);
104
106 virtual ~Cylinder();
107 };
108
109 /* Implementation */
110 inline agx::Physics::Geometry::CylinderPtr Cylinder::getEntity() const
111 {
112 return m_entity;
113 }
114 AGX_FORCE_INLINE agx::Real Cylinder::getHeight() const
115 {
116 return getEntity().height();
117 }
118 AGX_FORCE_INLINE agx::Real Cylinder::getRadius() const
119 {
120 return getEntity().radius();
121 }
122 AGX_FORCE_INLINE agx::Real Cylinder::getVolume() const
123 {
124 return getRadius() * getRadius() * getHeight() * agx::PI;
125 }
126
127 AGX_FORCE_INLINE BoundingAABB Cylinder::calculateBound(const agx::AffineMatrix4x4& transform, const agx::Real radius, const agx::Real height)
128 {
129 return Capsule::calculateBound(transform, radius, height); // TODO The cylinder bound can be further optimized
130 }
131
132 inline bool Cylinder::hasSupportFunction() const
133 {
134 return true;
135 }
136
137}
138
139#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
A cylinder shape for geometric intersection tests.
Definition: Cylinder.h:35
virtual Shape * clone() const override
Create a clone.
agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override
Calculate the inertia of this Cylinder.
virtual agx::Vec3 getSupportPoint(const agx::Vec3 &supportDirection) const override
Returns the support point on face of the shape.
virtual const BoundingAABB & updateBoundingVolume() override
Calculate the bounding volume based on the current Shape parameters including transformation.
virtual BoundingAABB calculateLocalBound() const override
Calculate the bounding volume in the local coordinate system.
void setRadius(const agx::Real radius)
Set the radius of a cylinder.
void setHeight(const agx::Real height)
Set the height of a cylinder.
Cylinder(const agx::Real radius, const agx::Real height)
Constructor.
void set(const agx::Real radius, const agx::Real height)
Set the radius and height of a cylinder.
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Base class for a shape.
Definition: Shape.h:58
Type
Define the type of a Shape.
Definition: Shape.h:62
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#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.
static constexpr Real PI
Definition: Math.h:63
double Real
Definition: Real.h:41