Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Public Member Functions | Protected Member Functions | List of all members
gf::PointSequence Class Reference

A sequence of points. More...

#include <gf/PointSequence.h>

Inheritance diagram for gf::PointSequence:
Inheritance graph
[legend]

Public Member Functions

 PointSequence ()=default
 Default constructor. More...
 
 PointSequence (Span< const Vector2f > points)
 Constructor from an array. More...
 
template<typename Iterator >
 PointSequence (Iterator first, Iterator last)
 Constructor from points. More...
 
bool isEmpty () const
 Check if the sequence is empty. More...
 
void addPoint (Vector2f point)
 Add a point to the sequence. More...
 
std::size_t getPointCount () const
 Get the number of points of the sequence. More...
 
Vector2f getPoint (std::size_t index) const
 Get the i-th point of the sequence. More...
 
Vector2f getCenter () const
 Get the center of the sequence. More...
 
const Vector2fbegin () const
 Get an iterator to the first point. More...
 
Vector2fbegin ()
 Get an iterator to the first point. More...
 
const Vector2fend () const
 Get an iterator past the last point. More...
 
Vector2fend ()
 Get an iterator past the last point. More...
 
Vector2f getFirstPoint () const
 Get the first point of the sequence. More...
 
Vector2f getLastPoint () const
 Get the last point of the sequence. More...
 
void applyTransform (const Matrix3f &mat)
 Apply a transformation to the sequence. More...
 
void simplify (float distance=Epsilon)
 Simplify the sequence. More...
 
void reverse ()
 Reverse the points in the sequence. More...
 

Protected Member Functions

std::vector< Vector2f > & getRawPoints ()
 Get the raw container of points. More...
 
const std::vector< Vector2f > & getRawPoints () const
 Get the raw container of points. More...
 

Detailed Description

A sequence of points.

See also
gf::Polygon, gf::Polyline

Constructor & Destructor Documentation

◆ PointSequence() [1/3]

gf::PointSequence::PointSequence ( )
default

Default constructor.

◆ PointSequence() [2/3]

gf::PointSequence::PointSequence ( Span< const Vector2f points)

Constructor from an array.

Parameters
pointsThe array of points

◆ PointSequence() [3/3]

template<typename Iterator >
gf::PointSequence::PointSequence ( Iterator  first,
Iterator  last 
)
inline

Constructor from points.

Parameters
firstIterator to the first point
lastIterator after the last point

Member Function Documentation

◆ addPoint()

void gf::PointSequence::addPoint ( Vector2f  point)
inline

Add a point to the sequence.

Parameters
pointThe point to add to the sequence

◆ applyTransform()

void gf::PointSequence::applyTransform ( const Matrix3f mat)

Apply a transformation to the sequence.

Parameters
matThe transformation matrix

◆ begin() [1/2]

Vector2f * gf::PointSequence::begin ( )
inline

Get an iterator to the first point.

Returns
A pointer to the first point
See also
end()

◆ begin() [2/2]

const Vector2f * gf::PointSequence::begin ( ) const
inline

Get an iterator to the first point.

Returns
A pointer to the first point
See also
end()

◆ end() [1/2]

Vector2f * gf::PointSequence::end ( )
inline

Get an iterator past the last point.

Returns
A pointer past the last point
See also
begin()

◆ end() [2/2]

const Vector2f * gf::PointSequence::end ( ) const
inline

Get an iterator past the last point.

Returns
A pointer past the last point
See also
begin()

◆ getCenter()

Vector2f gf::PointSequence::getCenter ( ) const

Get the center of the sequence.

As the sequence is convex, the center is inside the sequence

Returns
The center of the sequence

◆ getFirstPoint()

Vector2f gf::PointSequence::getFirstPoint ( ) const
inline

Get the first point of the sequence.

Returns
The first point of the sequence

◆ getLastPoint()

Vector2f gf::PointSequence::getLastPoint ( ) const
inline

Get the last point of the sequence.

Returns
The last point of the sequence

◆ getPoint()

Vector2f gf::PointSequence::getPoint ( std::size_t  index) const

Get the i-th point of the sequence.

Parameters
indexThe index of the point

◆ getPointCount()

std::size_t gf::PointSequence::getPointCount ( ) const
inline

Get the number of points of the sequence.

Returns
The number of points of the sequence

◆ getRawPoints() [1/2]

std::vector< Vector2f > & gf::PointSequence::getRawPoints ( )
inlineprotected

Get the raw container of points.

◆ getRawPoints() [2/2]

const std::vector< Vector2f > & gf::PointSequence::getRawPoints ( ) const
inlineprotected

Get the raw container of points.

◆ isEmpty()

bool gf::PointSequence::isEmpty ( ) const
inline

Check if the sequence is empty.

An empty sequence has no points.

Returns
True if the sequence is empty

◆ reverse()

void gf::PointSequence::reverse ( )

Reverse the points in the sequence.

◆ simplify()

void gf::PointSequence::simplify ( float  distance = Epsilon)

Simplify the sequence.

Parameters
distanceThe maximum authorized distance between the original points and the simplified points