GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::Sphere< N, T > Struct Template Reference

Generic sphere shape with a center and radius in N-dimensional space. More...

#include <GREM/core/geometry.hpp>

Public Types

using Component = T
 Scalar coordinate component type.

Public Member Functions

template<typename U>
GREM_ALWAYS_INLINE constexpr operator Sphere< N, U > () const noexcept
 Convert this sphere to an equivalent sphere of another scalar type.
constexpr operator Ellipsoid< N, T > () const noexcept
 Convert this sphere to an equivalent ellipsoid.
constexpr operator Ellipse< T > () const noexcept
 Convert this sphere to an equivalent 2D ellipse.
bool operator== (const Sphere &other) const =default
 Compare this sphere to another for equality.
constexpr bool contains (const Point< N, T > &point) const noexcept
 Check if a given point is contained within the extents of this sphere.
constexpr bool intersects (const Ray< N, T > &ray) const noexcept
 Check if this sphere intersects a given ray.
constexpr RaycastResult< N, T > raycast (const Ray< N, T > &ray) const noexcept
 Find the closest intersection of this sphere with a given ray.
constexpr Box< N, T > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the sphere.
constexpr Ellipsoid< N, T > toEllipsoid () const noexcept
 Convert this shape to an equivalent ellipsoid.
constexpr Sphere< N, T > toSphere () const noexcept
 Convert this shape to an equivalent sphere.

Public Attributes

Point< N, T > center
 Position of the center of the sphere.
T radius
 Radius of the sphere.

Static Public Attributes

static constexpr size_t RANK = N
 Number of dimensions of the vector space.

Detailed Description

template<size_t N, typename T>
struct grem::Sphere< N, T >

Generic sphere shape with a center and radius in N-dimensional space.

Template Parameters
Nnumber of vector dimensions.
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<size_t N, typename T>
using grem::Sphere< N, T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ operator Sphere< N, U >()

template<size_t N, typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Sphere< N, T >::operator Sphere< N, U > ( ) const
inlineexplicitconstexprnoexcept

Convert this sphere to an equivalent sphere of another scalar type.

Returns
the converted sphere.

◆ operator Ellipsoid< N, T >()

template<size_t N, typename T>
grem::Sphere< N, T >::operator Ellipsoid< N, T > ( ) const
inlineconstexprnoexcept

Convert this sphere to an equivalent ellipsoid.

Returns
the sphere as an ellipsoid.

◆ operator Ellipse< T >()

template<size_t N, typename T>
grem::Sphere< N, T >::operator Ellipse< T > ( ) const
inlineconstexprnoexcept

Convert this sphere to an equivalent 2D ellipse.

Returns
the sphere as an ellipse.

◆ operator==()

template<size_t N, typename T>
bool grem::Sphere< N, T >::operator== ( const Sphere< N, T > & other) const
nodiscarddefault

Compare this sphere to another for equality.

Parameters
otherthe sphere to compare this sphere to.
Returns
true if the spheres are equal, false otherwise.

◆ contains()

template<size_t N, typename T>
bool grem::Sphere< N, T >::contains ( const Point< N, T > & point) const
inlinenodiscardconstexprnoexcept

Check if a given point is contained within the extents of this sphere.

Parameters
pointpoint to check.
Returns
true if the sphere contains the given point, false otherwise.

◆ intersects()

template<size_t N, typename T>
bool grem::Sphere< N, T >::intersects ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Check if this sphere intersects a given ray.

Parameters
rayray to check.
Returns
true if an intersection was found, false otherwise.

◆ raycast()

template<size_t N, typename T>
RaycastResult< N, T > grem::Sphere< N, T >::raycast ( const Ray< N, T > & ray) const
inlinenodiscardconstexprnoexcept

Find the closest intersection of this sphere with a given ray.

Parameters
rayray to check.
Returns
the result of the raycast.

◆ getBoundingBox()

template<size_t N, typename T>
Box< N, T > grem::Sphere< N, T >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the sphere.

Returns
an axis-aligned box that contains the entire sphere.

◆ toEllipsoid()

template<size_t N, typename T>
Ellipsoid< N, T > grem::Sphere< N, T >::toEllipsoid ( ) const
inlinenodiscardconstexprnoexcept

Convert this shape to an equivalent ellipsoid.

Returns
an ellipsoid that is equivalent to this shape.

◆ toSphere()

template<size_t N, typename T>
Sphere< N, T > grem::Sphere< N, T >::toSphere ( ) const
inlinenodiscardconstexprnoexcept

Convert this shape to an equivalent sphere.

Returns
a sphere that is equivalent to this shape.

Member Data Documentation

◆ RANK

template<size_t N, typename T>
size_t grem::Sphere< N, T >::RANK = N
staticconstexpr

Number of dimensions of the vector space.

◆ center

template<size_t N, typename T>
Point<N, T> grem::Sphere< N, T >::center

Position of the center of the sphere.

◆ radius

template<size_t N, typename T>
T grem::Sphere< N, T >::radius

Radius of the sphere.


The documentation for this struct was generated from the following file: