HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends
hi::v1::geo::extent< T, D > Class Template Reference

#include <hikogui/geometry/extent.hpp>

Public Types

using value_type = T
 
using array_type = numeric_array<value_type, 4>
 

Public Member Functions

constexpr extent (extent const &) noexcept=default
 
constexpr extent (extent &&) noexcept=default
 
constexpr extentoperator= (extent const &) noexcept=default
 
constexpr extentoperator= (extent &&) noexcept=default
 
template<int E>
requires (E < D)
constexpr extent (extent< value_type, E > const &other) noexcept
 Construct a extent from a lower dimension extent.
 
constexpr operator array_type () const noexcept
 Convert a extent to its array_type-nummeric_array.
 
constexpr extent (array_type const &other) noexcept
 
constexpr operator bool () const noexcept
 
template<int E>
requires (E >= D)
constexpr operator vector< value_type, E > () const noexcept
 
constexpr extent () noexcept
 Construct a empty extent / zero length.
 
constexpr extent (value_type width, value_type height) noexcept
 Construct a 2D extent from the width and height.
 
constexpr extent (value_type width, value_type height, value_type depth=value_type{0}) noexcept
 Construct a 3D extent from width, height and depth.
 
constexpr value_type & width () noexcept
 Access the x-as-width element from the extent.
 
constexpr value_type & height () noexcept
 Access the y-as-height element from the extent.
 
constexpr value_type & depth () noexcept
 Access the z-as-depth element from the extent.
 
constexpr value_type const & width () const noexcept
 Access the x-as-width element from the extent.
 
constexpr value_type const & height () const noexcept
 Access the y-as-height element from the extent.
 
constexpr value_type const & depth () const noexcept
 Access the z-as-depth element from the extent.
 
constexpr vector< value_type, D > right () const noexcept
 
constexpr vector< value_type, D > up () const noexcept
 
constexpr extentoperator+= (extent const &rhs) noexcept
 
constexpr bool holds_invariant () const noexcept
 Check if the extent is valid.
 

Static Public Member Functions

static constexpr extent large () noexcept
 
static constexpr extent infinity () noexcept
 
static constexpr extent infinity () noexcept
 
static constexpr extent large () noexcept
 
static constexpr extent large () noexcept
 
static constexpr extent nan () noexcept
 
static constexpr extent nan () noexcept
 

Friends

constexpr friend extent operator+ (extent const &lhs, extent const &rhs) noexcept
 Add two extents from each other.
 
constexpr friend extent operator- (extent const &lhs, extent const &rhs) noexcept
 Subtract two extents from each other.
 
constexpr friend scale< D > operator/ (extent const &lhs, extent const &rhs) noexcept
 
constexpr friend extent operator* (extent const &lhs, value_type const &rhs) noexcept
 Scale the extent by a scaler.
 
template<int E>
constexpr friend auto operator+ (extent const &lhs, vector< value_type, E > const &rhs) noexcept
 
template<int E>
constexpr friend auto operator+ (vector< value_type, E > const &lhs, extent const &rhs) noexcept
 
constexpr friend extent operator+ (extent const &lhs, value_type const &rhs) noexcept
 Add a scaler to the extent.
 
constexpr friend extent operator* (value_type const &lhs, extent const &rhs) noexcept
 Scale the extent by a scaler.
 
constexpr friend bool operator== (extent const &lhs, extent const &rhs) noexcept
 Compare if two extents are equal.
 
constexpr friend std::partial_ordering operator<=> (extent const &lhs, extent const &rhs) noexcept
 
constexpr friend std::partial_ordering operator<=> (extent const &lhs, extent const &rhs) noexcept
 
hi_force_inline constexpr friend value_type squared_hypot (extent const &rhs) noexcept
 Get the squared length of the extent.
 
constexpr friend value_type hypot (extent const &rhs) noexcept
 Get the length of the extent.
 
constexpr friend value_type rcp_hypot (extent const &rhs) noexcept
 Get the length of the extent.
 
constexpr friend extent normalize (extent const &rhs) noexcept
 Normalize a extent to a unit extent.
 
constexpr friend extent ceil (extent const &rhs) noexcept
 
constexpr friend extent floor (extent const &rhs) noexcept
 
constexpr friend extent round (extent const &rhs) noexcept
 
constexpr friend extent min (extent const &lhs, extent const &rhs) noexcept
 
constexpr friend extent max (extent const &lhs, extent const &rhs) noexcept
 
constexpr friend extent clamp (extent const &value, extent const &min, extent const &max) noexcept
 
std::string to_string (extent const &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &lhs, extent const &rhs) noexcept
 

Detailed Description

template<typename T, int D>
class hi::v1::geo::extent< T, D >

A high-level geometric extent.

A extent, for both 2D or 3D is internally represented as a 4D homogeneous extent. Which can be efficiently implemented as a __m128 SSE register.

Constructor & Destructor Documentation

◆ extent() [1/4]

template<typename T , int D>
template<int E>
requires (E < D)
constexpr hi::v1::geo::extent< T, D >::extent ( extent< value_type, E > const & other)
inlineconstexprnoexcept

Construct a extent from a lower dimension extent.

◆ extent() [2/4]

template<typename T , int D>
constexpr hi::v1::geo::extent< T, D >::extent ( )
inlineconstexprnoexcept

Construct a empty extent / zero length.

◆ extent() [3/4]

template<typename T , int D>
constexpr hi::v1::geo::extent< T, D >::extent ( value_type width,
value_type height )
inlineconstexprnoexcept

Construct a 2D extent from the width and height.

Parameters
widthThe width element.
heightThe height element.

◆ extent() [4/4]

template<typename T , int D>
constexpr hi::v1::geo::extent< T, D >::extent ( value_type width,
value_type height,
value_type depth = value_type{0} )
inlineconstexprnoexcept

Construct a 3D extent from width, height and depth.

Parameters
widthThe width element.
heightThe height element.
depthThe depth element.

Member Function Documentation

◆ depth() [1/2]

template<typename T , int D>
constexpr value_type const & hi::v1::geo::extent< T, D >::depth ( ) const
inlineconstexprnoexcept

Access the z-as-depth element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the z element.

◆ depth() [2/2]

template<typename T , int D>
constexpr value_type & hi::v1::geo::extent< T, D >::depth ( )
inlineconstexprnoexcept

Access the z-as-depth element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the z element.

◆ height() [1/2]

template<typename T , int D>
constexpr value_type const & hi::v1::geo::extent< T, D >::height ( ) const
inlineconstexprnoexcept

Access the y-as-height element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the y element.

◆ height() [2/2]

template<typename T , int D>
constexpr value_type & hi::v1::geo::extent< T, D >::height ( )
inlineconstexprnoexcept

Access the y-as-height element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the y element.

◆ holds_invariant()

template<typename T , int D>
constexpr bool hi::v1::geo::extent< T, D >::holds_invariant ( ) const
inlineconstexprnoexcept

Check if the extent is valid.

Extends must be positive. This function will check if w is zero, and with 2D extent is z is zero.

◆ operator array_type()

template<typename T , int D>
constexpr hi::v1::geo::extent< T, D >::operator array_type ( ) const
inlineexplicitconstexprnoexcept

Convert a extent to its array_type-nummeric_array.

◆ width() [1/2]

template<typename T , int D>
constexpr value_type const & hi::v1::geo::extent< T, D >::width ( ) const
inlineconstexprnoexcept

Access the x-as-width element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the x element.

◆ width() [2/2]

template<typename T , int D>
constexpr value_type & hi::v1::geo::extent< T, D >::width ( )
inlineconstexprnoexcept

Access the x-as-width element from the extent.

A extent can be seen as having a width, height and depth, these accessors are aliases for x, y, and z.

Returns
a reference to the x element.

Friends And Related Symbol Documentation

◆ hypot

template<typename T , int D>
constexpr friend value_type hypot ( extent< T, D > const & rhs)
friend

Get the length of the extent.

Parameters
rhsThe extent.
Returns
The length of the extent.

◆ normalize

template<typename T , int D>
constexpr friend extent normalize ( extent< T, D > const & rhs)
friend

Normalize a extent to a unit extent.

Parameters
rhsThe extent.
Returns
A extent with the same direction as the given extent, but its length is 1.0.

◆ operator* [1/2]

template<typename T , int D>
constexpr friend extent operator* ( extent< T, D > const & lhs,
value_type const & rhs )
friend

Scale the extent by a scaler.

Parameters
lhsThe extent to scale.
rhsThe scaling factor.
Returns
The scaled extent.

◆ operator* [2/2]

template<typename T , int D>
constexpr friend extent operator* ( value_type const & lhs,
extent< T, D > const & rhs )
friend

Scale the extent by a scaler.

Parameters
lhsThe extent to scale.
rhsThe scaling factor.
Returns
The scaled extent.

◆ operator+ [1/2]

template<typename T , int D>
constexpr friend extent operator+ ( extent< T, D > const & lhs,
extent< T, D > const & rhs )
friend

Add two extents from each other.

Parameters
lhsThe first extent.
rhsThe second extent.
Returns
A new extent.

◆ operator+ [2/2]

template<typename T , int D>
constexpr friend extent operator+ ( extent< T, D > const & lhs,
value_type const & rhs )
friend

Add a scaler to the extent.

Parameters
lhsThe extent to scale.
rhsThe scaling factor.
Returns
The scaled extent.

◆ operator-

template<typename T , int D>
constexpr friend extent operator- ( extent< T, D > const & lhs,
extent< T, D > const & rhs )
friend

Subtract two extents from each other.

Parameters
lhsThe first extent.
rhsThe second extent.
Returns
A new extent.

◆ operator==

template<typename T , int D>
constexpr friend bool operator== ( extent< T, D > const & lhs,
extent< T, D > const & rhs )
friend

Compare if two extents are equal.

Parameters
lhsThe first extent.
rhsThe second extent.
Returns
True if both extents are completely equal to each other.

◆ rcp_hypot

template<typename T , int D>
constexpr friend value_type rcp_hypot ( extent< T, D > const & rhs)
friend

Get the length of the extent.

Parameters
rhsThe extent.
Returns
One over the length of the extent.

◆ squared_hypot

template<typename T , int D>
hi_force_inline constexpr friend value_type squared_hypot ( extent< T, D > const & rhs)
friend

Get the squared length of the extent.

Parameters
rhsThe extent.
Returns
The length of the extent.

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