HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Friends
hi::v1::rectangle Class Reference

#include <hikogui/geometry/rectangle.hpp>

Public Member Functions

constexpr rectangle (rectangle const &rhs) noexcept=default
 
constexpr rectangleoperator= (rectangle const &rhs) noexcept=default
 
constexpr rectangle (rectangle &&rhs) noexcept=default
 
constexpr rectangleoperator= (rectangle &&rhs) noexcept=default
 
constexpr rectangle (point3 origin, vector3 right, vector3 up) noexcept
 Create a rectangle from a corner point and two vectors.
 
constexpr rectangle (point3 origin, point3 right_bottom, point3 left_top, point3 right_top) noexcept
 Create a rectangle from 4 corner points.
 
constexpr rectangle (aarectangle rhs) noexcept
 
constexpr rectangle (extent2 size) noexcept
 
constexpr rectangleoperator= (aarectangle rhs) noexcept
 
constexpr rectangle (point3 origin, extent2 extent) noexcept
 
 operator bool () const noexcept
 Check if the rectangle has an area.
 
constexpr bool is_rectangle () const noexcept
 Check if this is a rectangle.
 
constexpr bool is_axis_aligned () const noexcept
 Check if this is an axis aligned rectangle.
 
float width () const noexcept
 The width, or length of the right vector.
 
float height () const noexcept
 The height, or length of the up vector.
 
constexpr extent2 size () const noexcept
 The size, or length of the right and up vectors.
 
float area () const noexcept
 
constexpr point3 operator[] (std::size_t i) const noexcept
 

Data Fields

point3 origin
 
vector3 right
 
vector3 up
 

Friends

constexpr friend aarectangle bounding_rectangle (rectangle const &rhs) noexcept
 Return the axis-aligned bounding rectangle of this rectangle.
 
template<std::size_t I>
constexpr point3 get (rectangle const &rhs) noexcept
 
constexpr rectangle operator+ (rectangle const &lhs, extent2 rhs) noexcept
 Expand the rectangle by adding an absolute distance on each side.
 
constexpr rectangle operator- (rectangle const &lhs, extent2 rhs) noexcept
 Shrink the rectangle by subtracting an absolute distance from each side.
 
constexpr rectangle operator+ (rectangle const &lhs, float rhs) noexcept
 Expand the rectangle by adding an absolute distance on each side.
 
constexpr rectangle operator- (rectangle const &lhs, float rhs) noexcept
 Shrink the rectangle by subtracting an absolute distance from each side.
 

Detailed Description

A rectangle / parallelogram in 3D space.

This class actually describes a parallelogram in 3D space using a point to the left bottom corner and a right & up vector.

Constructor & Destructor Documentation

◆ rectangle() [1/2]

constexpr hi::v1::rectangle::rectangle ( point3 origin,
vector3 right,
vector3 up )
inlineconstexprnoexcept

Create a rectangle from a corner point and two vectors.

Parameters
originThe left-bottom corner.
rightThe right vector.
upThe up vector.

◆ rectangle() [2/2]

constexpr hi::v1::rectangle::rectangle ( point3 origin,
point3 right_bottom,
point3 left_top,
point3 right_top )
inlineconstexprnoexcept

Create a rectangle from 4 corner points.

Parameters
originThe left-bottom corner.
right_bottomThe right-bottom corner.
left_topThe left-top corner.
right_topThe right-top corner.

Member Function Documentation

◆ height()

float hi::v1::rectangle::height ( ) const
inlinenoexcept

The height, or length of the up vector.

◆ is_axis_aligned()

constexpr bool hi::v1::rectangle::is_axis_aligned ( ) const
inlineconstexprnoexcept

Check if this is an axis aligned rectangle.

Returns
True if this is a axis aligned rectangle.

◆ is_rectangle()

constexpr bool hi::v1::rectangle::is_rectangle ( ) const
inlineconstexprnoexcept

Check if this is a rectangle.

Returns
True if rectangle, false if another parallelogram.

◆ operator bool()

hi::v1::rectangle::operator bool ( ) const
inlineexplicitnoexcept

Check if the rectangle has an area.

Returns
True is there is a area.

◆ size()

constexpr extent2 hi::v1::rectangle::size ( ) const
inlineconstexprnoexcept

The size, or length of the right and up vectors.

◆ width()

float hi::v1::rectangle::width ( ) const
inlinenoexcept

The width, or length of the right vector.

Friends And Related Symbol Documentation

◆ bounding_rectangle

constexpr friend aarectangle bounding_rectangle ( rectangle const & rhs)
friend

Return the axis-aligned bounding rectangle of this rectangle.

◆ operator+ [1/2]

constexpr rectangle operator+ ( rectangle const & lhs,
extent2 rhs )
friend

Expand the rectangle by adding an absolute distance on each side.

The expansion is done by:

  • translating the origin point in opposite direction of the right and up vectors.
  • increase the size of the right and up vectors twice.

It is possible for the rectangle to flip, when the right-hand-side is negative.

Parameters
lhsThe rectangle to expand.
rhsThe size in 2D to expand the rectangle
Returns
A new rectangle expanded in each side.

◆ operator+ [2/2]

constexpr rectangle operator+ ( rectangle const & lhs,
float rhs )
friend

Expand the rectangle by adding an absolute distance on each side.

The expansion is done by:

  • translating the origin point in opposite direction of the right and up vectors.
  • increase the size of the right and up vectors twice.

It is possible for the rectangle to flip, when the right-hand-side is negative.

Parameters
lhsThe rectangle to expand.
rhsThe scalar value which is added to the rectangle in each side.
Returns
A new rectangle expanded in each side.

◆ operator- [1/2]

constexpr rectangle operator- ( rectangle const & lhs,
extent2 rhs )
friend

Shrink the rectangle by subtracting an absolute distance from each side.

The shrinking is done by:

  • translating the origin point in the same direction of the right and up vectors.
  • decrease the size of the right and up vectors twice.

It is possible for the rectangle to flip, when the right-hand-side is negative.

Parameters
lhsThe rectangle to shrink.
rhsThe size in 2D to shrink the rectangle
Returns
A new rectangle expanded in each side.

◆ operator- [2/2]

constexpr rectangle operator- ( rectangle const & lhs,
float rhs )
friend

Shrink the rectangle by subtracting an absolute distance from each side.

The shrinking is done by:

  • translating the origin point in the same direction of the right and up vectors.
  • decrease the size of the right and up vectors twice.

It is possible for the rectangle to flip, when the right-hand-side is negative.

Parameters
lhsThe rectangle to shrink.
rhsThe scalar value which is added to the rectangle in each side.
Returns
A new rectangle expanded in each side.

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