LuciadCPillar 2023.1.04
luciad::Rectangle Struct Referencefinal

A "POD" for a 2D rectangle. More...

#include <luciad/cartesian/Rectangle.h>

Public Member Functions

constexpr Rectangle ()
 Creates a Rectangle at the origin, with width and height 0. More...
 
 Rectangle (const Rectangle &other)=default
 
 Rectangle (Coordinate corner1, Coordinate corner2)
 Creates a Rectangle with the given corners. More...
 
constexpr Rectangle (double x, double y, double width, double height)
 Creates a Rectangle with the provided x, y, width, and height values. More...
 
Coordinate getCenter () const
 Returns the coordinate in the center of this rectangle. More...
 
std::size_t getHash () const
 Returns the hash for this rectangle. More...
 
Coordinate getLowerLeftCorner () const
 Returns the coordinate at the lower left corner of this rectangle. More...
 
Coordinate getLowerRightCorner () const
 Returns the coordinate at the lower right corner of this rectangle. More...
 
Coordinate getUpperLeftCorner () const
 Returns the coordinate at the upper left corner of this rectangle. More...
 
Coordinate getUpperRightCorner () const
 Returns the coordinate at the upper right corner of this rectangle. More...
 
void grow (double margin)
 Grows this rectangle by the given margin. More...
 
bool isValid () const
 Returns whether all fields are neither not-a-number nor infinite and the width and height are non-negative. More...
 
bool operator!= (const Rectangle &other) const
 
Rectangleoperator= (const Rectangle &other)=default
 
bool operator== (const Rectangle &other) const
 

Public Attributes

double height
 The rectangle's height. More...
 
double width
 The rectangle's width. More...
 
double x
 The lower left corner's x-ordinate. More...
 
double y
 The lower left corner's y-ordinate. More...
 

Detailed Description

A "POD" for a 2D rectangle.

Not a geometry, to be used for communicating 2D cartesian rectangles.

Constructor & Destructor Documentation

◆ Rectangle() [1/4]

constexpr luciad::Rectangle::Rectangle ( )
inlineconstexpr

Creates a Rectangle at the origin, with width and height 0.

◆ Rectangle() [2/4]

constexpr luciad::Rectangle::Rectangle ( double  x,
double  y,
double  width,
double  height 
)
inlineconstexpr

Creates a Rectangle with the provided x, y, width, and height values.

Parameters
xthe lower left corner's x-ordinate
ythe lower left corner's y-ordinate
widththe rectangle's width
heightthe rectangle's height

◆ Rectangle() [3/4]

luciad::Rectangle::Rectangle ( Coordinate  corner1,
Coordinate  corner2 
)

Creates a Rectangle with the given corners.

The corners do not need to have any particular relation to each other. Only the x and y ordinates of the corners are considered.

Parameters
corner1one corner position
corner2another corner position

◆ Rectangle() [4/4]

luciad::Rectangle::Rectangle ( const Rectangle other)
default

Member Function Documentation

◆ getCenter()

Coordinate luciad::Rectangle::getCenter ( ) const
inline

Returns the coordinate in the center of this rectangle.

Returns
the coordinate in the center of this rectangle.

◆ getHash()

std::size_t luciad::Rectangle::getHash ( ) const

Returns the hash for this rectangle.

Returns
the hash for this rectangle.

◆ getLowerLeftCorner()

Coordinate luciad::Rectangle::getLowerLeftCorner ( ) const
inline

Returns the coordinate at the lower left corner of this rectangle.

Returns
the coordinate at the lower left corner of this rectangle.

◆ getLowerRightCorner()

Coordinate luciad::Rectangle::getLowerRightCorner ( ) const
inline

Returns the coordinate at the lower right corner of this rectangle.

Returns
the coordinate at the lower right corner of this rectangle.

◆ getUpperLeftCorner()

Coordinate luciad::Rectangle::getUpperLeftCorner ( ) const
inline

Returns the coordinate at the upper left corner of this rectangle.

Returns
the coordinate at the upper left corner of this rectangle.

◆ getUpperRightCorner()

Coordinate luciad::Rectangle::getUpperRightCorner ( ) const
inline

Returns the coordinate at the upper right corner of this rectangle.

Returns
the coordinate at the upper right corner of this rectangle.

◆ grow()

void luciad::Rectangle::grow ( double  margin)

Grows this rectangle by the given margin.

The lower left corner is moved in the direction of negative x and y by margin. The upper right corner is moved in the direction of positive x and y by margin.

Parameters
margina margin

◆ isValid()

bool luciad::Rectangle::isValid ( ) const

Returns whether all fields are neither not-a-number nor infinite and the width and height are non-negative.

Returns
whether all fields are neither not-a-number nor infinite and the width and height are non-negative.

◆ operator!=()

bool luciad::Rectangle::operator!= ( const Rectangle other) const
inline

◆ operator=()

Rectangle & luciad::Rectangle::operator= ( const Rectangle other)
default

◆ operator==()

bool luciad::Rectangle::operator== ( const Rectangle other) const
inline

Member Data Documentation

◆ height

double luciad::Rectangle::height

The rectangle's height.

◆ width

double luciad::Rectangle::width

The rectangle's width.

◆ x

double luciad::Rectangle::x

The lower left corner's x-ordinate.

◆ y

double luciad::Rectangle::y

The lower left corner's y-ordinate.