![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
Utility class for manipulating circles. More...
#include <gf/Circ.h>
Public Member Functions | |
constexpr | Circ () noexcept |
Default constructor. More... | |
constexpr | Circ (const Vector< T, 2 > &circCenter, T circRadius) noexcept |
Construct the circle from center and radius. More... | |
constexpr Vector< T, 2 > | getCenter () const noexcept |
Get the center of the circle. More... | |
constexpr T | getRadius () const noexcept |
Get the radius of the circle. More... | |
constexpr bool | isEmpty () const noexcept |
Check if the circle is empty. More... | |
bool | contains (const Vector< T, 2 > &point) const noexcept |
Check if a point is insied a circle's area. More... | |
bool | intersects (const Circ &other) const noexcept |
Check the intersection between two circles. More... | |
constexpr Vector< T, 2 > | getTop () const noexcept |
Get the top of the circle. More... | |
constexpr Vector< T, 2 > | getBottom () const noexcept |
Get the bottom of the circle. More... | |
constexpr Vector< T, 2 > | getLeft () const noexcept |
Get the left of the circle. More... | |
constexpr Vector< T, 2 > | getRight () const noexcept |
Get the right of the circle. More... | |
Public Attributes | |
Vector< T, 2 > | center |
Center of the circle. More... | |
T | radius |
Radius of the circle. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
bool | operator== (const Circ< T > &lhs, const Circ< T > &rhs) |
Equality operator. More... | |
template<typename T > | |
bool | operator!= (const Circ< T > &lhs, const Circ< T > &rhs) |
Inequality operator. More... | |
template<typename Archive , typename T > | |
Archive & | operator| (Archive &ar, Circ< T > &circ) |
Serialize a circle. More... | |
Utility class for manipulating circles.
A circle 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.
gf::Circ is a template and may be used with any numeric type, but for simplicity, some common typedef are defined:
int
as T
unsigned
as T
std::size_t
as T
float
as T
double
as T
So that you don't have to care about the template syntax.
Usage example:
|
inlineconstexprnoexcept |
Default constructor.
Creates an empty circle (it is equivalent to calling Circ({ 0, 0 }, 0
).
|
inlineconstexprnoexcept |
Construct the circle from center and radius.
circCenter | Center of the circle |
circRadius | Radius of the circle |
|
inlinenoexcept |
Check if a point is insied a circle's area.
point | The point to test |
|
inlineconstexprnoexcept |
Get the bottom of the circle.
|
inlineconstexprnoexcept |
Get the center of the circle.
It is a synonym for the center
member
|
inlineconstexprnoexcept |
Get the left of the circle.
|
inlineconstexprnoexcept |
Get the radius of the circle.
It is a synonym for the radius
member
|
inlineconstexprnoexcept |
Get the right of the circle.
|
inlineconstexprnoexcept |
Get the top of the circle.
|
inlinenoexcept |
Check the intersection between two circles.
other | The circle to test |
|
inlineconstexprnoexcept |
Check if the circle is empty.
An empty circle is a circle with a zero radius.
Inequality operator.
lhs | First circle |
rhs | Second circle |
Equality operator.
lhs | First circle |
rhs | Second circle |
|
related |
Serialize a circle.
ar | The archive |
circ | The circle to serialize |
T gf::Circ< T >::radius |
Radius of the circle.