Pogosim
Loading...
Searching...
No Matches
DiskGeometry Class Reference

Disk-shaped geometry. More...

#include <objects_geometry.h>

Inheritance diagram for DiskGeometry:
ObjectGeometry

Public Member Functions

 DiskGeometry (float _radius)
 Construct an ObjectGeometry.
virtual void create_box2d_shape (b2BodyId body_id, b2ShapeDef &shape_def) override
 Create Box2D shape based on this geometry.
float get_radius () const
 Return radius of the disk.
virtual std::vector< std::vector< bool > > export_geometry_grid (size_t num_bins_x, size_t num_bins_y, float bin_width, float bin_height, float obj_x, float obj_y) const override
 Exports a boolean 2D grid showing which bins are covered by the geometry.
virtual void render (SDL_Renderer *renderer, b2WorldId world_id, float x, float y, float theta, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255) const override
 Renders the object on the given SDL renderer.
virtual BoundingDisk compute_bounding_disk () const override
 Computes the bounding disk that completely encloses the geometry.
virtual BoundingBox compute_bounding_box () const override
 Computes the axis-aligned bounding box that completely encloses the geometry.
virtual arena_polygons_t generate_contours (std::size_t points_per_contour=0, b2Vec2 position={0.0f, 0.0f}) const override
 Return one or more polygonal contours that approximate / represent this geometry.
Public Member Functions inherited from ObjectGeometry
 ObjectGeometry ()
 Construct an ObjectGeometry.
virtual ~ObjectGeometry ()
 Destructor.
b2ShapeId get_shape_id () const
 Return Box2D shape_id.
virtual float get_distance_to (b2Vec2 orig, b2Vec2 point) const
 Compute the distance from a given point to the geometry.

Protected Attributes

float radius
 Radius of the disk.
Protected Attributes inherited from ObjectGeometry
bool shape_created = false
b2ShapeId shape_id
 Box2D shape identifier.

Detailed Description

Disk-shaped geometry.

Constructor & Destructor Documentation

◆ DiskGeometry()

DiskGeometry::DiskGeometry ( float _radius)
inline

Construct an ObjectGeometry.

Member Function Documentation

◆ compute_bounding_box()

BoundingBox DiskGeometry::compute_bounding_box ( ) const
overridevirtual

Computes the axis-aligned bounding box that completely encloses the geometry.

Returns
A BoundingBox with top-left corner (x,y) and width and height.

Implements ObjectGeometry.

◆ compute_bounding_disk()

BoundingDisk DiskGeometry::compute_bounding_disk ( ) const
overridevirtual

Computes the bounding disk that completely encloses the geometry.

Returns
A BoundingDisk with center (x,y) and radius.

Implements ObjectGeometry.

◆ create_box2d_shape()

void DiskGeometry::create_box2d_shape ( b2BodyId body_id,
b2ShapeDef & shape_def )
overridevirtual

Create Box2D shape based on this geometry.

Implements ObjectGeometry.

◆ export_geometry_grid()

std::vector< std::vector< bool > > DiskGeometry::export_geometry_grid ( size_t num_bins_x,
size_t num_bins_y,
float bin_width,
float bin_height,
float obj_x,
float obj_y ) const
overridevirtual

Exports a boolean 2D grid showing which bins are covered by the geometry.

Parameters
num_bins_xNumber of bins along the X-axis.
num_bins_yNumber of bins along the Y-axis.
bin_widthWidth (size) of each bin.
bin_heightHeight (size) of each bin.
obj_xThe x-coordinate of the object (geometry center).
obj_yThe y-coordinate of the object (geometry center).
Returns
A 2D vector of booleans. True in a given cell indicates that the geometry covers that bin.

Implements ObjectGeometry.

◆ generate_contours()

arena_polygons_t DiskGeometry::generate_contours ( std::size_t points_per_contour = 0,
b2Vec2 position = {0.0f, 0.0f} ) const
overridevirtual

Return one or more polygonal contours that approximate / represent this geometry.

Parameters
points_per_contourDesired number of vertices for each contour (a rectangle has one contour, a disk has one, an arena may have many – one per wall).
Returns
arena_polygons_t A vector of closed polygons (counter‑clockwise, last vertex different from the first – the caller may close the loop if needed).

Implements ObjectGeometry.

◆ get_radius()

float DiskGeometry::get_radius ( ) const
inline

Return radius of the disk.

◆ render()

void DiskGeometry::render ( SDL_Renderer * renderer,
b2WorldId world_id,
float x,
float y,
float theta,
uint8_t r,
uint8_t g,
uint8_t b,
uint8_t alpha = 255 ) const
overridevirtual

Renders the object on the given SDL renderer.

Parameters
rendererPointer to the SDL_Renderer.
world_idThe Box2D world identifier (unused in rendering).
xX coordinate
yY coordinate
rRed color component
gGreen color component
bBlue color component
alphaAlpha color component

Implements ObjectGeometry.

Member Data Documentation

◆ radius

float DiskGeometry::radius
protected

Radius of the disk.


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