Manifold 1.0
Robust computational geometry
 
Loading...
Searching...
No Matches
Rect Struct Reference

#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 rectangular bounds.

Constructor & Destructor Documentation

◆ Rect() [1/2]

constexpr Rect ( )
inlineconstexpr

Default constructor is an empty rectangle..

◆ Rect() [2/2]

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

Create a rectangle that contains the two given points.

Member Function Documentation

◆ Size()

constexpr vec2 Size ( ) const
inlineconstexpr

Return the dimensions of the rectangle.

◆ Area()

constexpr double Area ( ) const
inlineconstexpr

Return the area of the rectangle.

◆ Scale()

constexpr double Scale ( ) const
inlineconstexpr

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

◆ Center()

constexpr vec2 Center ( ) const
inlineconstexpr

Returns the center point of the rectangle.

◆ Contains() [1/2]

constexpr bool Contains ( const vec2 p) const
inlineconstexpr

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

◆ Contains() [2/2]

constexpr bool Contains ( const Rect rect) const
inlineconstexpr

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

◆ DoesOverlap()

constexpr bool DoesOverlap ( const Rect rect) const
inlineconstexpr

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

◆ IsEmpty()

constexpr bool IsEmpty ( ) const
inlineconstexpr

Is the rectangle empty (containing no space)?

◆ IsFinite()

constexpr 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]

constexpr Rect Union ( const Rect rect) const
inlineconstexpr

Expand this rectangle to include the given Rect.

◆ operator+()

constexpr 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*()

constexpr 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()

constexpr 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.