30#ifndef LSST_SPHGEOM_BOX_H_
31#define LSST_SPHGEOM_BOX_H_
106 _enforceInvariants();
116 _enforceInvariants();
125 _enforceInvariants();
134 _enforceInvariants();
139 return _lon ==
b._lon && _lat ==
b._lat;
227 _enforceInvariants();
237 _enforceInvariants();
336 return ((r1 & r2) & (CONTAINS | WITHIN)) | ((r1 | r2) & DISJOINT);
354 static constexpr size_t ENCODED_SIZE = 33;
356 void _enforceInvariants() {
365 _lat = AngleInterval();
369 NormalizedAngleInterval _lon;
This file defines a class for representing angle intervals.
This file contains a class representing spherical coordinates.
This file declares a class representing closed intervals of normalized angles, i.e.
This file defines an interface for spherical regions.
This file declares a class for representing unit vectors in ℝ³.
Angle represents an angle in radians.
AngleInterval represents closed intervals of arbitrary angles.
static AngleInterval fromDegrees(double x, double y)
static AngleInterval fromRadians(double x, double y)
Box3d represents a box in ℝ³.
Box represents a rectangle in spherical coordinate space that contains its boundary.
Relationship relate(Box const &b) const override
Box erodedBy(Angle w, Angle h) const
Box clippedTo(LonLat const &x) const
clippedTo returns the intersection of this box and x.
Box getBoundingBox() const override
getBoundingBox returns a bounding-box for this region.
bool operator==(LonLat const &p) const
A box is equal to a point p if it contains only p.
AngleInterval const & getLat() const
getLat returns the latitude interval of this box.
Box dilatedBy(Angle r) const
static NormalizedAngle halfWidthForCircle(Angle r, Angle lat)
halfWidthForCircle computes the half-width of bounding boxes for circles with radius r and centers at...
Box()
This constructor creates an empty box.
bool operator!=(LonLat const &p) const
std::vector< uint8_t > encode() const override
encode serializes this region into an opaque byte string.
NormalizedAngle getWidth() const
getWidth returns the width in longitude angle of this box.
double getArea() const
getArea returns the area of this box in steradians.
Box3d getBoundingBox3d() const override
getBoundingBox3d returns a 3-dimensional bounding-box for this region.
static Box fromRadians(double lon1, double lat1, double lon2, double lat2)
bool isWithin(Box const &x) const
Box expandedTo(LonLat const &x) const
bool operator==(Box const &b) const
Two boxes are equal if they contain the same points.
Box dilatedBy(Angle w, Angle h) const
Box(LonLat const &p1, LonLat const &p2)
This constructor creates a box spanning the longitude interval [p1.getLon(), p2.getLon()] and latitud...
NormalizedAngleInterval const & getLon() const
getLon returns the longitude interval of this box.
bool operator!=(Box const &b) const
bool contains(UnitVector3d const &v) const override
contains tests whether the given unit vector is inside this region.
Relationship relate(LonLat const &p) const
static std::unique_ptr< Box > decode(std::vector< uint8_t > const &s)
bool isDisjointFrom(LonLat const &x) const
Box(LonLat const &p)
This constructor creates a box containing a single point.
Box & expandTo(Box const &x)
bool isFull() const
isFull returns true if this box contains all points on the unit sphere.
Box expandedTo(Box const &x) const
Box & erodeBy(Angle w, Angle h)
static constexpr uint8_t TYPE_CODE
Box & dilateBy(Angle r)
dilateBy minimally expands this Box to include all points within angular separation r of its boundary...
Angle getHeight() const
getHeight returns the height in latitude angle of this box.
LonLat getCenter() const
getCenter returns the center of this box.
Box(LonLat const &p, Angle w, Angle h)
This constructor creates a box with center p, half-width (in longitude angle) w and half-height (in l...
std::unique_ptr< Region > clone() const override
clone returns a deep copy of this region.
static NormalizedAngleInterval allLongitudes()
allLongitudes returns a normalized angle interval containing all valid longitude angles.
bool isDisjointFrom(Box const &x) const
Box & clipTo(Box const &x)
x.clipTo(y) sets x to the smallest box containing the intersection of x and y.
Box(NormalizedAngleInterval const &lon, AngleInterval const &lat)
This constructor creates a box spanning the given longitude and latitude intervals.
bool isWithin(LonLat const &x) const
Relationship relate(Region const &r) const override
Box clippedTo(Box const &x) const
clippedTo returns the smallest box containing the intersection of this box and x.
bool intersects(Box const &x) const
Box erodedBy(Angle r) const
Box & expandTo(LonLat const &x)
static AngleInterval allLatitudes()
allLatitudes returns an angle interval containing all valid latitude angles.
bool contains(LonLat const &x) const
static Box fromDegrees(double lon1, double lat1, double lon2, double lat2)
bool isEmpty() const
isEmpty returns true if this box does not contain any points.
Box & clipTo(LonLat const &x)
clipTo shrinks this box until it contains only x.
bool contains(Box const &x) const
bool intersects(LonLat const &x) const
Circle getBoundingCircle() const override
getBoundingCircle returns a bounding-circle for this region.
Circle is a circular region on the unit sphere that contains its boundary.
ConvexPolygon is a closed convex polygon on the unit sphere.
Ellipse is an elliptical region on the sphere.
bool isWithin(Scalar x) const
Scalar getSize() const
getSize returns the size (length, width) of this interval.
Interval & clipTo(Scalar x)
bool isEmpty() const
isEmpty returns true if this interval does not contain any points.
Relationship relate(Scalar x) const
bool intersects(Scalar x) const
Scalar getCenter() const
getCenter returns the center of this interval.
Interval & expandTo(Scalar x)
bool contains(Scalar x) const
LonLat represents a spherical coordinate (longitude/latitude angle) pair.
NormalizedAngle getLon() const
NormalizedAngle is an angle that lies in the range [0, 2π), with one exception - a NormalizedAngle ca...
NormalizedAngleInterval represents closed intervals of normalized angles, i.e.
bool isFull() const
isFull returns true if this interval contains all normalized angles.
NormalizedAngleInterval & clipTo(NormalizedAngle x)
clipTo shrinks this interval until all its points are in x.
NormalizedAngle getCenter() const
getCenter returns the center of this interval.
Relationship relate(NormalizedAngle x) const
NormalizedAngle getSize() const
getSize returns the size (length, width) of this interval.
NormalizedAngleInterval & expandTo(NormalizedAngle x)
bool intersects(NormalizedAngle x) const
static NormalizedAngleInterval fromDegrees(double a, double b)
bool isWithin(NormalizedAngle x) const
static NormalizedAngleInterval fromRadians(double a, double b)
static NormalizedAngleInterval full()
bool contains(NormalizedAngle x) const
bool isEmpty() const
isEmpty returns true if this interval does not contain any normalized angles.
Region is a minimal interface for 2-dimensional regions on the unit sphere.
virtual Relationship relate(Region const &) const =0
virtual bool contains(UnitVector3d const &) const =0
contains tests whether the given unit vector is inside this region.
UnitVector3d is a unit vector in ℝ³ with components stored in double precision.
std::ostream & operator<<(std::ostream &, Angle const &)
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.