Manifold 3.0
Robust geometry
 
Loading...
Searching...
No Matches
Rect Struct Reference

Axis-aligned 2D box, primarily for bounding. More...

#include <common.h>

Public Member Functions

constexpr Rect ()
 
constexpr Rect (const vec2 a, const vec2 b)
 

Public Attributes

vec2 min = vec2(std::numeric_limits<double>::infinity())
 
vec2 max = vec2(-std::numeric_limits<double>::infinity())
 

Information

Details of the rectangle

constexpr vec2 Size () const
 
constexpr double Area () const
 
constexpr double Scale () const
 
constexpr vec2 Center () const
 
constexpr bool Contains (const vec2 &p) const
 
constexpr bool Contains (const Rect &rect) const
 
constexpr bool DoesOverlap (const Rect &rect) const
 
constexpr bool IsEmpty () const
 
constexpr bool IsFinite () const
 

Modification

void Union (const vec2 p)
 
constexpr Rect Union (const Rect &rect) const
 
constexpr Rect operator+ (const vec2 shift) const
 
Rectoperator+= (const vec2 shift)
 
constexpr Rect operator* (const vec2 scale) const
 
Rectoperator*= (const vec2 scale)
 
constexpr Rect Transform (const mat2x3 &m) const
 

Detailed Description

Axis-aligned 2D box, primarily for bounding.

Constructor & Destructor Documentation

◆ Rect() [1/2]

Rect ( )
inlineconstexpr

Default constructor is an empty rectangle..

◆ Rect() [2/2]

Rect ( const vec2 a,
const vec2 b )
inlineconstexpr

Create a rectangle that contains the two given points.

Member Function Documentation

◆ Size()

vec2 Size ( ) const
inlineconstexpr

Return the dimensions of the rectangle.

◆ Area()

double Area ( ) const
inlineconstexpr

Return the area of the rectangle.

◆ Scale()

double Scale ( ) const
inlineconstexpr

Returns the absolute-largest coordinate value of any contained point.

◆ Center()

vec2 Center ( ) const
inlineconstexpr

Returns the center point of the rectangle.

◆ Contains() [1/2]

bool Contains ( const vec2 & p) const
inlineconstexpr

Does this rectangle contain (includes on border) the given point?

◆ Contains() [2/2]

bool Contains ( const Rect & rect) const
inlineconstexpr

Does this rectangle contain (includes equal) the given rectangle?

◆ DoesOverlap()

bool DoesOverlap ( const Rect & rect) const
inlineconstexpr

Does this rectangle overlap the one given (including equality)?

◆ IsEmpty()

bool IsEmpty ( ) const
inlineconstexpr

Is the rectangle empty (containing no space)?

◆ IsFinite()

bool IsFinite ( ) const
inlineconstexpr

Does this recangle have finite bounds?

◆ Union() [1/2]

void Union ( const vec2 p)
inline

Expand this rectangle (in place) to include the given point.

◆ Union() [2/2]

Rect Union ( const Rect & rect) const
inlineconstexpr

Expand this rectangle to include the given Rect.

◆ operator+()

Rect operator+ ( const vec2 shift) const
inlineconstexpr

Shift this rectangle by the given vector.

◆ operator+=()

Rect & operator+= ( const vec2 shift)
inline

Shift this rectangle in-place by the given vector.

◆ operator*()

Rect operator* ( const vec2 scale) const
inlineconstexpr

Scale this rectangle by the given vector.

◆ operator*=()

Rect & operator*= ( const vec2 scale)
inline

Scale this rectangle in-place by the given vector.

◆ Transform()

Rect Transform ( const mat2x3 & m) const
inlineconstexpr

Transform the rectangle by the given axis-aligned affine transform.

Ensure the transform passed in is axis-aligned (rotations are all multiples of 90 degrees), or else the resulting rectangle will no longer bound properly.