|
| constexpr | Circle () noexcept |
| | Default constructor.
|
| constexpr | Circle (const math::Vector2< T > ¢er, const T &radius) noexcept |
| | Constructs a circle with the given center and radius.
|
| constexpr T | area () const noexcept |
| | Returns the area (π * radius²).
|
| constexpr void | reset () noexcept |
| | Puts the circle in reset state (center zero, radius zero).
|
| constexpr bool | isReset () const noexcept |
| | Returns true if the circle is in reset state (center zero, radius zero).
|
| constexpr bool | isValid () const noexcept |
| | Returns true if the circle has valid state (radius > 0).
|
| constexpr bool | isContain (const math::Vector2< T > &vector) const noexcept |
| | Returns true if vector lies inside or on the circle.
|
template<CircleComponent T>
class toy::geometry::Circle< T >
Circle in 2D with center and radius.
Represents a circle by center (toy::math::Vector2) and radius. Default-constructed circle is in reset state; use reset() to clear or construct with (center, radius) for a valid circle. operator== compares center and radius (tolerance-based for float, exact for fixed-point).
- Template Parameters
-
Key Features
- Center and radius: center and radius are public; T is floating-point or fixed-point.
- Reset state: reset() sets center to zero and radius to zero; isReset() detects it.
- Validity: isValid() is
true when radius > 0; constructor asserts radius > 0 in debug.
- Containment: isContain() tests whether a point lies inside or on the circle (squared distance).
- Constexpr: All operations are constexpr and noexcept.
Usage Example
auto a = c.area();
Circle in 2D with center and radius.
Definition circle.hpp:92
2D vector with floating-point or fixed-point components for positions, movement, and physics.
Definition vector2.hpp:96
Umbrella header for the geometry module.
Performance Characteristics
Operations are O(1). No allocations.
Safety Guarantees
- Preconditions: Constructor (center, radius) requires radius >
0 (assert in debug).
- Exception safety: All operations are noexcept.
- See also
- CircleComponent
-
toy::math::Vector2