10#define M_PI 3.14159265358979323846
26 Cylinder(
double radius,
double halfHeight);
52 : m_radius(radius), m_halfHeight(halfHeight) {}
57 return M_PI * m_radius * m_radius * 2.0 * m_halfHeight;
61 double r2 = m_radius * m_radius;
62 double h2 = 4.0 * m_halfHeight * m_halfHeight;
63 double ixz = (1.0 / 12.0) * mass * (3.0 * r2 + h2);
64 double iy = 0.5 * mass * r2;
double GetHalfHeight() const
Gets the half-height of the cylinder.
Definition cylinder.hpp:69
Vector3 CalculateLocalInertia(double mass) const override
Computes the diagonal of the local inertia tensor for this shape given a mass.
Definition cylinder.hpp:60
virtual ~Cylinder()=default
double CalculateVolume() const override
Calculates the volume of the specific shape.
Definition cylinder.hpp:56
Cylinder(double radius, double halfHeight)
Constructs a new Cylinder.
Definition cylinder.hpp:51
double GetRadius() const
Gets the radius of the cylinder.
Definition cylinder.hpp:68
ShapeType GetType() const override
Gets the exact type of this shape.
Definition cylinder.hpp:54
Base class for all collision geometries in the physics engine.
Definition shape.hpp:28
ShapeType
Enum identifying the specific types of collision shapes available.
Definition shape.hpp:14
@ CYLINDER
Definition shape.hpp:17
#define M_PI
Definition sphere.hpp:9
3D vector utility used throughout JSim physics.
Definition vector.hpp:22