cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumGeometry::Rectangle Struct Referencefinal

A 2D rectangle. More...

#include <CesiumGeometry/Rectangle.h>

Public Member Functions

constexpr Rectangle () noexcept
 Creates a new instance with all coordinate values set to 0.0.
 
constexpr Rectangle (double minimumX_, double minimumY_, double maximumX_, double maximumY_) noexcept
 Creates a new instance.
 
bool contains (const glm::dvec2 &position) const noexcept
 Checks whether this rectangle contains the given position.
 
bool overlaps (const Rectangle &other) const noexcept
 Checks whether this rectangle overlaps the given rectangle.
 
bool fullyContains (const Rectangle &other) const noexcept
 Checks whether this rectangle fully contains the given rectangle.
 
double computeSignedDistance (const glm::dvec2 &position) const noexcept
 Computes the signed distance from a position to the edge of the rectangle.
 
constexpr glm::dvec2 getLowerLeft () const noexcept
 Returns a point at the lower left of this rectangle.
 
constexpr glm::dvec2 getLowerRight () const noexcept
 Returns a point at the lower right of this rectangle.
 
constexpr glm::dvec2 getUpperLeft () const noexcept
 Returns a point at the upper left of this rectangle.
 
constexpr glm::dvec2 getUpperRight () const noexcept
 Returns a point at the upper right of this rectangle.
 
constexpr glm::dvec2 getCenter () const noexcept
 Returns a point at the center of this rectangle.
 
constexpr double computeWidth () const noexcept
 Computes the width of this rectangle.
 
constexpr double computeHeight () const noexcept
 Computes the height of this rectangle.
 
std::optional< RectanglecomputeIntersection (const Rectangle &other) const noexcept
 
Rectangle computeUnion (const Rectangle &other) const noexcept
 Computes the union of this rectangle with another.
 

Public Attributes

double minimumX
 The minimum x-coordinate.
 
double minimumY
 The minimum y-coordinate.
 
double maximumX
 The maximum x-coordinate.
 
double maximumY
 The maximum y-coordinate.
 

Detailed Description

A 2D rectangle.

Definition at line 14 of file Rectangle.h.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

CesiumGeometry::Rectangle::Rectangle ( )
inlineconstexprnoexcept

Creates a new instance with all coordinate values set to 0.0.

Definition at line 18 of file Rectangle.h.

◆ Rectangle() [2/2]

CesiumGeometry::Rectangle::Rectangle ( double minimumX_,
double minimumY_,
double maximumX_,
double maximumY_ )
inlineconstexprnoexcept

Creates a new instance.

Creates a new rectangle from the given coordinates. This implicitly assumes that the given coordinates form a valid rectangle, meaning that minimumX <= maximumX and minimumY <= maximumY.

Parameters
minimumX_The minimum x-coordinate.
minimumY_The minimum y-coordinate.
maximumX_The maximum x-coordinate.
maximumY_The maximum y-coordinate.

Definition at line 33 of file Rectangle.h.

Member Function Documentation

◆ computeHeight()

double CesiumGeometry::Rectangle::computeHeight ( ) const
inlineconstexprnoexcept

Computes the height of this rectangle.

Returns
The height.

Definition at line 179 of file Rectangle.h.

◆ computeIntersection()

std::optional< Rectangle > CesiumGeometry::Rectangle::computeIntersection ( const Rectangle & other) const
noexcept

Computes the intersection of this rectangle with another.

Parameters
otherThe other rectangle to intersect with this one.
Returns
The intersection rectangle, or std::nullopt if there is no intersection.

◆ computeSignedDistance()

double CesiumGeometry::Rectangle::computeSignedDistance ( const glm::dvec2 & position) const
noexcept

Computes the signed distance from a position to the edge of the rectangle.

If the position is inside the rectangle, the distance is negative. If it is outside the rectangle, it is positive.

Parameters
positionThe position.
Returns
The signed distance.

◆ computeUnion()

Rectangle CesiumGeometry::Rectangle::computeUnion ( const Rectangle & other) const
noexcept

Computes the union of this rectangle with another.

Parameters
otherThe other rectangle to union with this one.
Returns
The union rectangle, which fully contains both rectangles.

◆ computeWidth()

double CesiumGeometry::Rectangle::computeWidth ( ) const
inlineconstexprnoexcept

Computes the width of this rectangle.

Returns
The width.

Definition at line 170 of file Rectangle.h.

◆ contains()

bool CesiumGeometry::Rectangle::contains ( const glm::dvec2 & position) const
noexcept

Checks whether this rectangle contains the given position.

This means that the x- and y coordinates of the given position are not smaller than the minimum and not larger than the maximum coordinates of this rectangle.

Parameters
positionThe position.
Returns
Whether this rectangle contains the given position.

◆ fullyContains()

bool CesiumGeometry::Rectangle::fullyContains ( const Rectangle & other) const
noexcept

Checks whether this rectangle fully contains the given rectangle.

This means that this rectangle contains all four corner points of the given rectangle, as defined in Rectangle::contains.

Parameters
otherThe other rectangle.
Returns
Whether this rectangle fully contains the given rectangle.

◆ getCenter()

glm::dvec2 CesiumGeometry::Rectangle::getCenter ( ) const
inlineconstexprnoexcept

Returns a point at the center of this rectangle.

Returns
The center point.

Definition at line 159 of file Rectangle.h.

◆ getLowerLeft()

glm::dvec2 CesiumGeometry::Rectangle::getLowerLeft ( ) const
inlineconstexprnoexcept

Returns a point at the lower left of this rectangle.

This is the point that consists of the minimum x- and y-coordinate.

Returns
The lower left point.

Definition at line 117 of file Rectangle.h.

◆ getLowerRight()

glm::dvec2 CesiumGeometry::Rectangle::getLowerRight ( ) const
inlineconstexprnoexcept

Returns a point at the lower right of this rectangle.

This is the point that consists of the maximum x- and minimum y-coordinate.

Returns
The lower right point.

Definition at line 128 of file Rectangle.h.

◆ getUpperLeft()

glm::dvec2 CesiumGeometry::Rectangle::getUpperLeft ( ) const
inlineconstexprnoexcept

Returns a point at the upper left of this rectangle.

This is the point that consists of the minimum x- and maximum y-coordinate.

Returns
The upper left point.

Definition at line 139 of file Rectangle.h.

◆ getUpperRight()

glm::dvec2 CesiumGeometry::Rectangle::getUpperRight ( ) const
inlineconstexprnoexcept

Returns a point at the upper right of this rectangle.

This is the point that consists of the maximum x- and y-coordinate.

Returns
The upper right point.

Definition at line 150 of file Rectangle.h.

◆ overlaps()

bool CesiumGeometry::Rectangle::overlaps ( const Rectangle & other) const
noexcept

Checks whether this rectangle overlaps the given rectangle.

This means that this rectangle and the given rectangle have a non-empty intersection. If either of the rectangles is empty, then this will always return false.

Parameters
otherThe other rectangle.
Returns
Whether this rectangle overlaps the given rectangle.

Member Data Documentation

◆ maximumX

double CesiumGeometry::Rectangle::maximumX

The maximum x-coordinate.

Definition at line 56 of file Rectangle.h.

◆ maximumY

double CesiumGeometry::Rectangle::maximumY

The maximum y-coordinate.

Definition at line 61 of file Rectangle.h.

◆ minimumX

double CesiumGeometry::Rectangle::minimumX

The minimum x-coordinate.

Definition at line 46 of file Rectangle.h.

◆ minimumY

double CesiumGeometry::Rectangle::minimumY

The minimum y-coordinate.

Definition at line 51 of file Rectangle.h.


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