ReactPhysics3D  v0.10.1
C++ Physics engine library
reactphysics3d::SphereShape Class Reference

This class represents a sphere collision shape that is centered at the origin and defined by its radius. More...

#include <include/reactphysics3d/collision/shapes/SphereShape.h>

Inheritance diagram for reactphysics3d::SphereShape:
reactphysics3d::ConvexShape reactphysics3d::CollisionShape

Public Member Functions

 SphereShape (const SphereShape &shape)=delete
 Deleted copy-constructor.
 
SphereShapeoperator= (const SphereShape &shape)=delete
 Deleted assignment operator.
 
decimal getRadius () const
 Return the radius of the sphere. More...
 
void setRadius (decimal radius)
 Set the radius of the sphere. More...
 
virtual bool isPolyhedron () const override
 Return true if the collision shape is a polyhedron. More...
 
virtual AABB getLocalBounds () const override
 Return the local bounds of the shape in x, y and z directions. More...
 
virtual Vector3 getLocalInertiaTensor (decimal mass) const override
 Return the local inertia tensor of the collision shape. More...
 
virtual decimal getVolume () const override
 Compute and return the volume of the collision shape.
 
virtual AABB computeTransformedAABB (const Transform &transform) const override
 Compute the transformed AABB. More...
 
virtual std::string to_string () const override
 Return the string representation of the shape.
 
- Public Member Functions inherited from reactphysics3d::ConvexShape
 ConvexShape (CollisionShapeName name, CollisionShapeType type, MemoryAllocator &allocator, decimal margin=decimal(0.0))
 Constructor.
 
virtual ~ConvexShape () override=default
 Destructor.
 
 ConvexShape (const ConvexShape &shape)=delete
 Deleted copy-constructor.
 
ConvexShapeoperator= (const ConvexShape &shape)=delete
 Deleted assignment operator.
 
decimal getMargin () const
 Return the current object margin. More...
 
virtual bool isConvex () const override
 Return true if the collision shape is convex, false if it is concave.
 
- Public Member Functions inherited from reactphysics3d::CollisionShape
 CollisionShape (CollisionShapeName name, CollisionShapeType type, MemoryAllocator &allocator)
 Constructor.
 
virtual ~CollisionShape ()=default
 Destructor.
 
 CollisionShape (const CollisionShape &shape)=delete
 Deleted copy-constructor.
 
CollisionShapeoperator= (const CollisionShape &shape)=delete
 Deleted assignment operator.
 
CollisionShapeName getName () const
 Return the name of the collision shape. More...
 
CollisionShapeType getType () const
 Return the type of the collision shape. More...
 
uint32 getId () const
 Return the id of the shape.
 

Detailed Description

This class represents a sphere collision shape that is centered at the origin and defined by its radius.

This collision shape does not have an explicit object margin distance. The margin is implicitly the radius of the sphere. Therefore, no need to specify an object margin for a sphere shape.

Member Function Documentation

◆ computeTransformedAABB()

AABB SphereShape::computeTransformedAABB ( const Transform transform) const
overridevirtual

Compute the transformed AABB.

Parameters
transformTransform used to for the space conversion
Returns
aabb The transformed axis-aligned bounding box (AABB) of the collision shape

Reimplemented from reactphysics3d::CollisionShape.

◆ getLocalBounds()

RP3D_FORCE_INLINE AABB reactphysics3d::SphereShape::getLocalBounds ( ) const
overridevirtual

Return the local bounds of the shape in x, y and z directions.

Returns
The AABB with the min/max bounds of the shape

Implements reactphysics3d::CollisionShape.

◆ getLocalInertiaTensor()

RP3D_FORCE_INLINE Vector3 reactphysics3d::SphereShape::getLocalInertiaTensor ( decimal  mass) const
overridevirtual

Return the local inertia tensor of the collision shape.

Parameters
massMass to use to compute the inertia tensor of the collision shape

Implements reactphysics3d::CollisionShape.

◆ getRadius()

RP3D_FORCE_INLINE decimal reactphysics3d::SphereShape::getRadius ( ) const

Return the radius of the sphere.

Returns
Radius of the sphere

◆ isPolyhedron()

RP3D_FORCE_INLINE bool reactphysics3d::SphereShape::isPolyhedron ( ) const
overridevirtual

Return true if the collision shape is a polyhedron.

Returns
False because the sphere shape is not a polyhedron

Implements reactphysics3d::CollisionShape.

◆ setRadius()

RP3D_FORCE_INLINE void reactphysics3d::SphereShape::setRadius ( decimal  radius)

Set the radius of the sphere.

Note that you might want to recompute the inertia tensor and center of mass of the body after changing the radius of the collision shape.

Parameters
radiusRadius of the sphere

The documentation for this class was generated from the following files: