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

Flat 2D axis-aligned square shape with a position and width. 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 Square< U > () const noexcept
 Convert this square to an equivalent square of another scalar type.
constexpr operator Rectangle< T > () const noexcept
 Convert this square to an equivalent rectangle.
constexpr operator Box< 2, T > () const noexcept
 Convert this square to an equivalent 2D axis-aligned box.
bool operator== (const Square &other) const =default
 Compare this square to another for equality.
constexpr bool contains (const Point< 2, T > &point) const noexcept
 Check if a given point is contained within the extents of this square.
constexpr bool intersects (const Ray< 2, T > &ray) const noexcept
 Check if this square intersects a given ray.
constexpr RaycastResult< 2, T > raycast (const Ray< 2, T > &ray) const noexcept
 Find the closest intersection of this square with a given ray.
constexpr Box< 2, T > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the square.
constexpr Box< 2, T > toBox () const noexcept
 Convert this shape to an equivalent axis-aligned bounding box.

Public Attributes

Point< 2, T > position
 Position of the bottom left corner of the square.
T width
 Width and height of the square.

Static Public Attributes

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

Detailed Description

template<typename T>
struct grem::Square< T >

Flat 2D axis-aligned square shape with a position and width.

Template Parameters
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<typename T>
using grem::Square< T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ operator Square< U >()

template<typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Square< T >::operator Square< U > ( ) const
inlineexplicitconstexprnoexcept

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

Returns
the converted square.

◆ operator Rectangle< T >()

template<typename T>
grem::Square< T >::operator Rectangle< T > ( ) const
inlineconstexprnoexcept

Convert this square to an equivalent rectangle.

Returns
the square as a rectangle.

◆ operator Box< 2, T >()

template<typename T>
grem::Square< T >::operator Box< 2, T > ( ) const
inlineconstexprnoexcept

Convert this square to an equivalent 2D axis-aligned box.

Returns
the square as an axis-aligned box.

◆ operator==()

template<typename T>
bool grem::Square< T >::operator== ( const Square< T > & other) const
nodiscarddefault

Compare this square to another for equality.

Parameters
otherthe square to compare this square to.
Returns
true if the squares are equal, false otherwise.

◆ contains()

template<typename T>
bool grem::Square< T >::contains ( const Point< 2, T > & point) const
inlinenodiscardconstexprnoexcept

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

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

◆ intersects()

template<typename T>
bool grem::Square< T >::intersects ( const Ray< 2, T > & ray) const
inlinenodiscardconstexprnoexcept

Check if this square intersects a given ray.

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

◆ raycast()

template<typename T>
RaycastResult< 2, T > grem::Square< T >::raycast ( const Ray< 2, T > & ray) const
inlinenodiscardconstexprnoexcept

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

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

◆ getBoundingBox()

template<typename T>
Box< 2, T > grem::Square< T >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the square.

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

◆ toBox()

template<typename T>
Box< 2, T > grem::Square< T >::toBox ( ) const
inlinenodiscardconstexprnoexcept

Convert this shape to an equivalent axis-aligned bounding box.

Returns
an axis-aligned box that is equivalent to this shape.

Member Data Documentation

◆ RANK

template<typename T>
size_t grem::Square< T >::RANK = 2
staticconstexpr

Number of dimensions of the vector space.

◆ position

template<typename T>
Point<2, T> grem::Square< T >::position

Position of the bottom left corner of the square.

◆ width

template<typename T>
T grem::Square< T >::width

Width and height of the square.


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