Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
spat::Rect< Valtype > Struct Template Reference

Axis aligned rectangle. More...

#include <C:/Trend/Development/Trax3/Code/spat/Rect.h>

Public Types

typedef Valtype value_type

Public Member Functions

bool Normal () const noexcept
 is bottom <= top and left <= right
RectNormalize () noexcept
 make bottom <= top and left <= right
Valtype Left () const noexcept
Valtype Top () const noexcept
Valtype Right () const noexcept
Valtype Bottom () const noexcept
RectLeft (Valtype val) noexcept
 Sets left edge of this rect.
RectTop (Valtype val) noexcept
 Sets top edge of this rect.
RectRight (Valtype val) noexcept
 Sets right edge of this rect.
RectBottom (Valtype val) noexcept
 Sets bottom edge of this rect.
Position2D< Valtype > LeftTop () const noexcept
Position2D< Valtype > LeftBottom () const noexcept
Position2D< Valtype > RightBottom () const noexcept
Position2D< Valtype > RightTop () const noexcept
Position2D< Valtype > Center () const noexcept
Valtype Width () const noexcept
Valtype Height () const noexcept
auto Area () const noexcept -> decltype(Valtype{} *Valtype{})
Valtype Diagonal () const noexcept
bool IsArea () const noexcept
 Is non zero area?
RectUnion (const Rect &r1, const Rect &r2) noexcept
 Calculates the union of the two rects.
RectUnion (const Rect &rect) noexcept
 Calculates the union of this and rect.
RectIntersection (const Rect &r1, const Rect &r2) noexcept
 Calculates the intersection rect of r1 and r2.
RectIntersection (const Rect &rect) noexcept
 Calculates the intersection of this and rect.
bool Includes (Valtype x, Valtype y) const noexcept
bool Includes (const Position2D< Valtype > &pt) const noexcept
RectExpand (Valtype x, Valtype y) noexcept
 Expands the rect so that it touches (being included or laying on border) the point.
RectExpand (const Position2D< Valtype > &pt) noexcept
 Expands the rect so that it touches (being included or laying on border) the point.
RectInflate (Valtype dx, Valtype dy) noexcept
 Moves the edges to the outside of the rect, thereyby inflating it.
RectDeflate (Valtype dx, Valtype dy) noexcept
 Moves the edges to the inward side of the rect, thereyby deflating it.
Construction
Parameters
lefttop
rightbottom
left
top
right
bottom
 Rect () noexcept=default
 Does not initialize the members.
 Rect (Valtype width, Valtype height) noexcept
 Does not initialize the members.
 Rect (const common::Interval< Valtype > &width, const common::Interval< Valtype > &height) noexcept
 Does not initialize the members.
 Rect (const Vector2D< Valtype > &diagonal) noexcept
 Does not initialize the members.
 Rect (const Position2D< Valtype > &lefttop, const Position2D< Valtype > &rightbottom) noexcept
 Does not initialize the members.
 Rect (Valtype left, Valtype top, Valtype right, Valtype bottom) noexcept
 Does not initialize the members.
Initialisation

Initializes the interval to origin.

Parameters
leftLeft edge of the Rect.
topRight edge of the Rect.
widthWidth of the Rect.
heightHeight of the Rect.
RectInit () noexcept
RectInit (Valtype left, Valtype top, Valtype width, Valtype height) noexcept
Translation

Moves the edges in one direction, thereby moving the rect.

Parameters
dxDistance to move horizontal edges.
dyDistance to move vertical edges.
offsetDistance to move the rect.
RectMove (Valtype dx, Valtype dy) noexcept
RectMove (const Vector2D< Valtype > &offset) noexcept

Public Attributes

common::Interval< Valtype > m_Width
 X dimension.
common::Interval< Valtype > m_Height
 Y dimension.

Detailed Description

template<typename Valtype>
struct spat::Rect< Valtype >

Axis aligned rectangle.

Member Function Documentation

◆ Area()

template<typename Valtype>
auto spat::Rect< Valtype >::Area ( ) const->decltype(Valtype{} *Valtype{})
inlinenoexcept
Returns
Area of rect.

◆ Bottom()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Bottom ( ) const
inlinenoexcept
Returns
The bottom value of this rect.

◆ Center()

template<typename Valtype>
Position2D< Valtype > spat::Rect< Valtype >::Center ( ) const
inlinenoexcept
Returns
Center of this rect.

◆ Deflate()

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Deflate ( Valtype dx,
Valtype dy )
inlinenoexcept

Moves the edges to the inward side of the rect, thereyby deflating it.

Parameters
dxDistance to move horizontal edges.
dyDistance to move vertical edges.

◆ Diagonal()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Diagonal ( ) const
inlinenoexcept
Returns
The length of the diagonal.

◆ Expand() [1/2]

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Expand ( const Position2D< Valtype > & pt)
inlinenoexcept

Expands the rect so that it touches (being included or laying on border) the point.

If the point is allready included in the rect, no changes are made. If val becomes m_Far Includes() will not return the value as beeing included.

◆ Expand() [2/2]

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Expand ( Valtype x,
Valtype y )
inlinenoexcept

Expands the rect so that it touches (being included or laying on border) the point.

If the point is allready included in the rect, no changes are made. If val becomes m_Far Includes() will not return the value as beeing included.

◆ Height()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Height ( ) const
inlinenoexcept
Returns
Height of rect.

◆ Includes() [1/2]

template<typename Valtype>
bool spat::Rect< Valtype >::Includes ( const Position2D< Valtype > & pt) const
inlinenoexcept
Returns
True if the point lays inside the rect.

The left and top edges are inside the rect; the right and bottom edges are not

◆ Includes() [2/2]

template<typename Valtype>
bool spat::Rect< Valtype >::Includes ( Valtype x,
Valtype y ) const
inlinenoexcept
Returns
True if the point lays inside the rect.

The left and top edges are inside the rect; the right and bottom edges are not

◆ Inflate()

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Inflate ( Valtype dx,
Valtype dy )
inlinenoexcept

Moves the edges to the outside of the rect, thereyby inflating it.

Parameters
dxDistance to move horizontal edges.
dyDistance to move vertical edges.

◆ Intersection() [1/2]

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Intersection ( const Rect< Valtype > & r1,
const Rect< Valtype > & r2 )
inlinenoexcept

Calculates the intersection rect of r1 and r2.

If these rects are not in touch, the resulting rect will not be normal.

◆ Intersection() [2/2]

template<typename Valtype>
Rect< Valtype > & spat::Rect< Valtype >::Intersection ( const Rect< Valtype > & rect)
inlinenoexcept

Calculates the intersection of this and rect.

If the rects are not in touch, the resulting rect will not be normal.

◆ Left()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Left ( ) const
inlinenoexcept
Returns
The left value of this rect.

◆ LeftBottom()

template<typename Valtype>
Position2D< Valtype > spat::Rect< Valtype >::LeftBottom ( ) const
inlinenoexcept
Returns
LeftBottom of this rect.

◆ LeftTop()

template<typename Valtype>
Position2D< Valtype > spat::Rect< Valtype >::LeftTop ( ) const
inlinenoexcept
Returns
LeftTop of this rect.

◆ Right()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Right ( ) const
inlinenoexcept
Returns
The right value of this rect.

◆ RightBottom()

template<typename Valtype>
Position2D< Valtype > spat::Rect< Valtype >::RightBottom ( ) const
inlinenoexcept
Returns
RightBottom of this rect.

◆ RightTop()

template<typename Valtype>
Position2D< Valtype > spat::Rect< Valtype >::RightTop ( ) const
inlinenoexcept
Returns
RightTop of this rect.

◆ Top()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Top ( ) const
inlinenoexcept
Returns
The top value of this rect.

◆ Width()

template<typename Valtype>
Valtype spat::Rect< Valtype >::Width ( ) const
inlinenoexcept
Returns
Width of rect.

The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/spat/Rect.h