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

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]

constexpr CesiumGeometry::Rectangle::Rectangle ( )
inlineconstexprnoexcept

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

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

Definition at line 23 of file Rectangle.h.

◆ Rectangle() [2/2]

constexpr 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 38 of file Rectangle.h.

Member Function Documentation

◆ computeHeight()

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

Computes the height of this rectangle.

Returns
The height.

Definition at line 184 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()

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

Computes the width of this rectangle.

Returns
The width.

Definition at line 175 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()

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

Returns a point at the center of this rectangle.

Returns
The center point.

Definition at line 164 of file Rectangle.h.

◆ getLowerLeft()

constexpr 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 122 of file Rectangle.h.

◆ getLowerRight()

constexpr 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 133 of file Rectangle.h.

◆ getUpperLeft()

constexpr 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 144 of file Rectangle.h.

◆ getUpperRight()

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

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