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

Description of a sphere in world space. More...

#include <GREM/physics/Shape.hpp>

Public Types

using Unit = typename Position<N>::Unit
 Unit type.
using DimensionType = typename Unit::DimensionType
 Unit dimension type.
using MagnitudeType = typename Unit::MagnitudeType
 Unit magnitude type.

Public Member Functions

template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Sphere< N, Scalar > in (OtherUnitT unit) const noexcept
 Convert this physical sphere to a unitless sphere given a desired unit.
bool operator== (const Sphere &other) const =default
 Compare this sphere to another for equality.
GREM_ALWAYS_INLINE constexpr bool contains (const Position< N > &point) const noexcept
 Check if a given point is contained within the extents of this sphere.
GREM_ALWAYS_INLINE constexpr bool intersects (const Ray< N > &ray) const noexcept
 Check if this sphere intersects a given ray.
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast (const Ray< N > &ray) const noexcept
 Find the closest intersection of this sphere with a given ray.
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the sphere.

Static Public Member Functions

template<typename T>
static GREM_ALWAYS_INLINE constexpr Sphere reinterpret (const grem::Sphere< N, T > &sphere) noexcept
 Reinterpret a unitless sphere as a physical sphere in default units.

Public Attributes

Position< N > center
 Position of the center of the sphere.
Distance radius
 Radius of the sphere.

Static Public Attributes

static constexpr Unit UNIT {}
 Unit.
static constexpr DimensionType DIMENSION {}
 Unit dimension.
static constexpr MagnitudeType MAGNITUDE {}
 Unit magnitude.

Friends

GREM_ALWAYS_INLINE friend constexpr bool intersects (const Sphere &a, const Sphere &b) noexcept
 Check if two spheres intersect.

Detailed Description

template<size_t N>
struct grem::physics::Sphere< N >

Description of a sphere in world space.

Member Typedef Documentation

◆ Unit

template<size_t N>
using grem::physics::Sphere< N >::Unit = typename Position<N>::Unit

Unit type.

◆ DimensionType

template<size_t N>
using grem::physics::Sphere< N >::DimensionType = typename Unit::DimensionType

Unit dimension type.

◆ MagnitudeType

template<size_t N>
using grem::physics::Sphere< N >::MagnitudeType = typename Unit::MagnitudeType

Unit magnitude type.

Member Function Documentation

◆ reinterpret()

template<size_t N>
template<typename T>
GREM_ALWAYS_INLINE constexpr Sphere grem::physics::Sphere< N >::reinterpret ( const grem::Sphere< N, T > & sphere)
inlinestaticnodiscardconstexprnoexcept

Reinterpret a unitless sphere as a physical sphere in default units.

Parameters
spheresphere to reinterpret.
Returns
the corresponding physical sphere.

◆ in()

template<size_t N>
template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Sphere< N, Scalar > grem::physics::Sphere< N >::in ( OtherUnitT unit) const
inlinenodiscardconstexprnoexcept

Convert this physical sphere to a unitless sphere given a desired unit.

Parameters
unitunit to get the sphere in.
Returns
the corresponding sphere in the given unit.

◆ operator==()

template<size_t N>
bool grem::physics::Sphere< N >::operator== ( const Sphere< N > & 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>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Sphere< N >::contains ( const Position< N > & 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>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Sphere< N >::intersects ( const Ray< N > & 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>
GREM_ALWAYS_INLINE constexpr RaycastResult< N > grem::physics::Sphere< N >::raycast ( const Ray< N > & 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>
GREM_ALWAYS_INLINE constexpr Box< N > grem::physics::Sphere< N >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the sphere.

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

◆ intersects

template<size_t N>
GREM_ALWAYS_INLINE friend constexpr bool intersects ( const Sphere< N > & a,
const Sphere< N > & b )
friend

Check if two spheres intersect.

Parameters
afirst sphere.
bsecond sphere.
Returns
true if the first and second spheres are colliding with each other, false otherwise.

Member Data Documentation

◆ UNIT

template<size_t N>
Unit grem::physics::Sphere< N >::UNIT {}
staticconstexpr

Unit.

◆ DIMENSION

template<size_t N>
DimensionType grem::physics::Sphere< N >::DIMENSION {}
staticconstexpr

Unit dimension.

◆ MAGNITUDE

template<size_t N>
MagnitudeType grem::physics::Sphere< N >::MAGNITUDE {}
staticconstexpr

Unit magnitude.

◆ center

template<size_t N>
Position<N> grem::physics::Sphere< N >::center

Position of the center of the sphere.

◆ radius

template<size_t N>
Distance grem::physics::Sphere< N >::radius

Radius of the sphere.


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