|
| constexpr | Ellipse () noexcept=default |
| | Default constructor.
|
| constexpr | Ellipse (const math::Vector2< T > ¢er, const math::Vector2< T > &radiuses) noexcept |
| | Constructs an ellipse with the given center and semi-axes.
|
| constexpr T | area () const noexcept |
| | Returns the area (π × radiuses.x × radiuses.y).
|
| constexpr void | reset () noexcept |
| | Puts the ellipse in reset state (center zero, radiuses zero).
|
| constexpr bool | isReset () const noexcept |
| | Returns true if the ellipse is in reset state (center zero, radiuses zero).
|
| constexpr bool | isValid () const noexcept |
| | Returns true if the ellipse has valid state (both semi-axes positive).
|
| constexpr bool | isContain (const math::Vector2< T > &vector) const noexcept |
| | Returns true if vector lies inside or on the ellipse.
|
template<EllipseComponent T>
class toy::geometry::Ellipse< T >
Axis-aligned ellipse in 2D with center and semi-axes.
Represents an ellipse by center (toy::math::Vector2) and radiuses (semi-axes: radiuses.x along x, radiuses.y along y). Default-constructed ellipse is in reset state; use reset() to clear or construct with (center, radiuses) for a valid ellipse. operator== compares center and radiuses (tolerance-based for float, exact for fixed-point).
- Template Parameters
-
Key Features
- Center and semi-axes: center and radiuses are public; radiuses.x and radiuses.y must be positive for a valid ellipse.
- Reset state: reset() sets center and radiuses to zero; isReset() detects it.
- Validity: isValid() is
true when both radiuses.x and radiuses.y are > 0; constructor asserts in debug.
- Containment: isContain() tests whether a point lies inside or on the ellipse using the normalized equation
.
- Constexpr: All operations are constexpr and noexcept.
Usage Example
auto a = e.area();
Axis-aligned ellipse in 2D with center and semi-axes.
Definition ellipse.hpp:97
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, radiuses) requires both radiuses.x and radiuses.y
> 0 (assert in debug).
- Exception safety: All operations are noexcept.
- See also
- EllipseComponent
-
toy::math::Vector2