Game Develop C++ Platform: Polygon2d Class Reference

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Public Attributes | List of all members
Polygon2d Class Reference
Game engine

Represents a polygon. Usually used for collisions masks. More...

`#include <Polygon.h>`

## Public Member Functions

void | Move (float x, float y)
void | Rotate (float angle)
void | ComputeEdges () const
bool | IsConvex () const
sf::Vector2f | ComputeCenter () const

## Static Public Member Functions

Tools
Tool functions
static Polygon2d | CreateRectangle (float width, float height)

## Public Attributes

std::vector< sf::Vector2f > | vertices
| The vertices composing the polygon.
std::vector< sf::Vector2f > | edges
| Can be computed from vertices using ComputeEdges()

## Detailed Description

Represents a polygon. Usually used for collisions masks.

This class stores the vertices of the polygon. It can also compute and store the edges ( needed by some collisions algorithms ) if ComputeEdges is called.

## Member Function Documentation

sf::Vector2f Polygon2d::ComputeCenter | ( | ) |  | const

Return the position of the center of the polygon

void Polygon2d::ComputeEdges | ( | ) |  | const

Automatically fill edges vector using vertices.

Polygon2d Polygon2d::CreateRectangle | ( | float | width,
|  | float | height
| ) |  |

static

Create a rectangle

bool Polygon2d::IsConvex | ( | ) |  | const

Check if the polygon is convex.

Returns
  true if the polygon is convex

Here is the call graph for this function:

void Polygon2d::Move | ( | float | x,
|  | float | y
| ) |  |

Moves each vertices from the given amount.

Note
  Edges are updated, there is no need to call ComputeEdges after calling Move.

Here is the call graph for this function:

void Polygon2d::Rotate | ( | float | angle) |  |

Rotate the polygon.

Parameters

  angle | Angle in radians

Warning
  Rotation is made clockwise
  edges vector is not updated, you have to call ComputeEdges if needed.

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

- Polygon.h
- Polygon.cpp