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

#include <objects_geometry.h>

Inheritance diagram for TriangleGeometry:
ObjectGeometry

Public Member Functions

 TriangleGeometry (float _side_length)
 Construct an equilateral TriangleGeometry.
void create_box2d_shape (b2BodyId body_id, b2ShapeDef &shape_def) override
 Create a Box2D shape based on this geometry.
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 triangle.
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 triangle on the given SDL renderer.
float get_side_length () const
 Returns the side length of the equilateral triangle.
BoundingDisk compute_bounding_disk () const override
 Computes the bounding disk that completely encloses the geometry.
BoundingBox compute_bounding_box () const override
 Computes the axis-aligned bounding box that completely encloses the geometry.
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.

Additional Inherited Members

Protected Attributes inherited from ObjectGeometry
bool shape_created = false
b2ShapeId shape_id
 Box2D shape identifier.

Constructor & Destructor Documentation

◆ TriangleGeometry()

TriangleGeometry::TriangleGeometry ( float _side_length)
inlineexplicit

Construct an equilateral TriangleGeometry.

The triangle is centered at (0,0) in local coordinates (its centroid).

Parameters
_side_lengthThe side length of the equilateral triangle.

Member Function Documentation

◆ compute_bounding_box()

BoundingBox TriangleGeometry::compute_bounding_box ( ) const
overridevirtual

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

Implements ObjectGeometry.

◆ compute_bounding_disk()

BoundingDisk TriangleGeometry::compute_bounding_disk ( ) const
overridevirtual

Computes the bounding disk that completely encloses the geometry.

Implements ObjectGeometry.

◆ create_box2d_shape()

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

Create a Box2D shape based on this geometry.

Implements ObjectGeometry.

◆ export_geometry_grid()

std::vector< std::vector< bool > > TriangleGeometry::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 triangle.

Implements ObjectGeometry.

◆ generate_contours()

arena_polygons_t TriangleGeometry::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.

Implements ObjectGeometry.

◆ get_side_length()

float TriangleGeometry::get_side_length ( ) const
inline

Returns the side length of the equilateral triangle.

◆ render()

void TriangleGeometry::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 triangle on the given SDL renderer.

Implements ObjectGeometry.


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