Gamedev Framework (gf)  0.14.0
A C++14 framework for 2D games
Public Member Functions | Public Attributes | Related Functions | List of all members
gf::Ball< T, N > Struct Template Reference

A n-dimension ball. More...

#include <gf/Ball.h>

Public Member Functions

constexpr Ball () noexcept
 Default constructor. More...
 
constexpr Ball (const Vector< T, N > &ballCenter, T ballRadius) noexcept
 Construct the ball from center and radius. More...
 
constexpr Vector< T, NgetCenter () const noexcept
 Get the center of the ball. More...
 
constexpr T getRadius () const noexcept
 Get the radius of the ball. More...
 
constexpr bool isEmpty () const noexcept
 Check if the ball is empty. More...
 
bool contains (const Vector< T, N > &point) const noexcept
 Check if a point is insied a ball's area. More...
 
bool intersects (const Ball< T, N > &other) const noexcept
 Check the intersection between two balls. More...
 

Public Attributes

Vector< T, Ncenter
 Center of the ball. More...
 
T radius
 Radius of the ball. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T , std::size_t N>
constexpr bool operator== (const Ball< T, N > &lhs, const Ball< T, N > &rhs)
 Equality operator. More...
 
template<typename T , std::size_t N>
constexpr bool operator!= (const Ball< T, N > &lhs, const Ball< T, N > &rhs)
 Inequality operator. More...
 
template<typename Archive , typename T , std::size_t N>
Archive & operator| (Archive &ar, Ball< T, N > &ball)
 Serialize a ball. More...
 

Detailed Description

template<typename T, std::size_t N>
struct gf::Ball< T, N >

A n-dimension ball.

A ball is defined by its center and its radius. It is a very simple class defined for convenience, so its member variables (center and radius) are public and can be accessed directly.

Constructor & Destructor Documentation

◆ Ball() [1/2]

template<typename T, std::size_t N>
constexpr gf::Ball< T, N >::Ball ( )
inlinenoexcept

Default constructor.

Creates an empty ball.

◆ Ball() [2/2]

template<typename T, std::size_t N>
constexpr gf::Ball< T, N >::Ball ( const Vector< T, N > &  ballCenter,
T  ballRadius 
)
inlinenoexcept

Construct the ball from center and radius.

Parameters
ballCenterCenter of the ball
ballRadiusRadius of the ball

Member Function Documentation

◆ contains()

template<typename T, std::size_t N>
bool gf::Ball< T, N >::contains ( const Vector< T, N > &  point) const
inlinenoexcept

Check if a point is insied a ball's area.

Parameters
pointThe point to test
Returns
True if the point is inside, false otherwise
See also
intersects()

◆ getCenter()

template<typename T, std::size_t N>
constexpr Vector<T, N> gf::Ball< T, N >::getCenter ( ) const
inlinenoexcept

Get the center of the ball.

It is a synonym for the center member

Returns
The center of the ball
See also
getRadius()

◆ getRadius()

template<typename T, std::size_t N>
constexpr T gf::Ball< T, N >::getRadius ( ) const
inlinenoexcept

Get the radius of the ball.

It is a synonym for the radius member

Returns
The radius of the ball
See also
getCenter()

◆ intersects()

template<typename T, std::size_t N>
bool gf::Ball< T, N >::intersects ( const Ball< T, N > &  other) const
inlinenoexcept

Check the intersection between two balls.

Parameters
otherThe ball to test
Returns
True if balls overlap, false otherwise
See also
contains()

◆ isEmpty()

template<typename T, std::size_t N>
constexpr bool gf::Ball< T, N >::isEmpty ( ) const
inlinenoexcept

Check if the ball is empty.

An empty ball is a ball with a zero radius.

Returns
True if the ball is empty

Friends And Related Function Documentation

◆ operator!=()

template<typename T , std::size_t N>
constexpr bool operator!= ( const Ball< T, N > &  lhs,
const Ball< T, N > &  rhs 
)
related

Inequality operator.

Parameters
lhsFirst ball
rhsSecond ball
Returns
True if the two balls are different

◆ operator==()

template<typename T , std::size_t N>
constexpr bool operator== ( const Ball< T, N > &  lhs,
const Ball< T, N > &  rhs 
)
related

Equality operator.

Parameters
lhsFirst ball
rhsSecond ball
Returns
True if the two balls are the same

◆ operator|()

template<typename Archive , typename T , std::size_t N>
Archive & operator| ( Archive &  ar,
Ball< T, N > &  ball 
)
related

Serialize a ball.

Parameters
arThe archive
ballThe ball to serialize
See also
gf::Serializer, gf::Deserializer

Member Data Documentation

◆ center

template<typename T, std::size_t N>
Vector<T, N> gf::Ball< T, N >::center

Center of the ball.

◆ radius

template<typename T, std::size_t N>
T gf::Ball< T, N >::radius

Radius of the ball.