lsst.sphgeom g1081da9e2a+62d12e78cb
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lsst::sphgeom::Circle Class Reference

#include <Circle.h>

Inheritance diagram for lsst::sphgeom::Circle:
lsst::sphgeom::Region

Public Member Functions

 Circle ()
 This constructor creates an empty circle.
 
 Circle (UnitVector3d const &c)
 
 Circle (UnitVector3d const &c, Angle a)
 
 Circle (UnitVector3d const &c, double cl2)
 
bool operator== (Circle const &c) const
 
bool operator!= (Circle const &c) const
 
bool isEmpty () const
 
bool isFull () const
 
UnitVector3d const & getCenter () const
 
double getSquaredChordLength () const
 
Angle getOpeningAngle () const
 
bool contains (Circle const &x) const
 
CircledilateBy (Angle r)
 
Circle dilatedBy (Angle r) const
 
CircleerodeBy (Angle r)
 
Circle erodedBy (Angle r) const
 
double getArea () const
 getArea returns the area of this circle in steradians.
 
Circlecomplement ()
 
Circle complemented () const
 complemented returns the closure of the complement of this circle.
 
Relationship relate (UnitVector3d const &v) const
 
std::unique_ptr< Regionclone () const override
 clone returns a deep copy of this region. More...
 
Box getBoundingBox () const override
 getBoundingBox returns a bounding-box for this region. More...
 
Box3d getBoundingBox3d () const override
 getBoundingBox3d returns a 3-dimensional bounding-box for this region. More...
 
Circle getBoundingCircle () const override
 getBoundingCircle returns a bounding-circle for this region. More...
 
bool contains (UnitVector3d const &v) const override
 contains tests whether the given unit vector is inside this region. More...
 
Relationship relate (Region const &r) const override
 
Relationship relate (Box const &) const override
 
Relationship relate (Circle const &) const override
 
Relationship relate (ConvexPolygon const &) const override
 
Relationship relate (Ellipse const &) const override
 
std::vector< uint8_t > encode () const override
 
virtual bool contains (UnitVector3d const &) const=0
 contains tests whether the given unit vector is inside this region. More...
 
bool contains (double x, double y, double z) const
 
bool contains (double lon, double lat) const
 
bool isDisjointFrom (UnitVector3d const &x) const
 
bool isDisjointFrom (Circle const &x) const
 
bool intersects (UnitVector3d const &x) const
 
bool intersects (Circle const &x) const
 
bool isWithin (UnitVector3d const &) const
 
bool isWithin (Circle const &x) const
 
CircleclipTo (UnitVector3d const &x)
 
CircleclipTo (Circle const &x)
 
Circle clippedTo (UnitVector3d const &x) const
 
Circle clippedTo (Circle const &x) const
 
CircleexpandTo (UnitVector3d const &x)
 
CircleexpandTo (Circle const &x)
 
Circle expandedTo (UnitVector3d const &x) const
 
Circle expandedTo (Circle const &x) const
 
- Public Member Functions inherited from lsst::sphgeom::Region
virtual std::unique_ptr< Regionclone () const =0
 clone returns a deep copy of this region. More...
 
virtual Box getBoundingBox () const =0
 getBoundingBox returns a bounding-box for this region. More...
 
virtual Box3d getBoundingBox3d () const =0
 getBoundingBox3d returns a 3-dimensional bounding-box for this region. More...
 
virtual Circle getBoundingCircle () const =0
 getBoundingCircle returns a bounding-circle for this region. More...
 
virtual bool contains (UnitVector3d const &) const =0
 contains tests whether the given unit vector is inside this region. More...
 
bool contains (double x, double y, double z) const
 
bool contains (double lon, double lat) const
 
virtual std::vector< uint8_t > encode () const =0
 

Static Public Member Functions

static Circle empty ()
 
static Circle full ()
 
static double squaredChordLengthFor (Angle openingAngle)
 
static Angle openingAngleFor (double squaredChordLength)
 
static std::unique_ptr< Circledecode (std::vector< uint8_t > const &s)
 
static std::unique_ptr< Circledecode (uint8_t const *buffer, size_t n)
 
- Static Public Member Functions inherited from lsst::sphgeom::Region
static std::unique_ptr< Regiondecode (std::vector< uint8_t > const &s)
 
static std::unique_ptr< Regiondecode (uint8_t const *buffer, size_t n)
 

Static Public Attributes

static constexpr uint8_t TYPE_CODE = 'c'
 

Detailed Description

Circle is a circular region on the unit sphere that contains its boundary. Internally, the circle is represented by its center vector and the squared length of the chords between its center and points on its boundary. This yields a fast point-in-circle test but, unlike a representation that uses the center vector and cosine of the circle opening angle, remains accurate for circles with very small opening angles.

Constructor & Destructor Documentation

◆ Circle() [1/3]

lsst::sphgeom::Circle::Circle ( UnitVector3d const &  c)
inlineexplicit

This constructor creates the circle with center c and squared chord length / opening angle of zero. Because of rounding error, (v - c).squaredNorm() == 0.0 does not imply that v == c. Therefore calling contains(v) on the resulting circle may return true for unit vectors v != c.

◆ Circle() [2/3]

lsst::sphgeom::Circle::Circle ( UnitVector3d const &  c,
Angle  a 
)
inline

This constructor creates a circle with center c and opening angle a. If a is negative or NaN, the circle will be empty, and if a is greater than or equal to PI, the circle will be full.

◆ Circle() [3/3]

lsst::sphgeom::Circle::Circle ( UnitVector3d const &  c,
double  cl2 
)
inline

This constructor creates a circle with center c and squared chord length cl2. If cl2 is negative or NaN, the circle will be empty, and if cl2 is greater than or equal to 4, the circle will be full.

Member Function Documentation

◆ clippedTo()

Circle lsst::sphgeom::Circle::clippedTo ( UnitVector3d const &  x) const
inline

clippedTo returns the minimal bounding circle for the intersection of this circle and x.

◆ clipTo()

Circle & lsst::sphgeom::Circle::clipTo ( UnitVector3d const &  x)

clipTo sets this circle to the minimal bounding circle for the intersection of this circle and x.

◆ clone()

std::unique_ptr< Region > lsst::sphgeom::Circle::clone ( ) const
inlineoverridevirtual

clone returns a deep copy of this region.

Implements lsst::sphgeom::Region.

◆ complement()

Circle & lsst::sphgeom::Circle::complement ( )

complement sets this circle to the closure of its complement. Note that both the empty circle as well as all circles containing a single point are mapped to a full circle, so that taking the complement of a circle twice is not guaranteed to reproduce the original circle, even in the absence of rounding error.

◆ contains() [1/5]

bool lsst::sphgeom::Circle::contains ( Circle const &  x) const

contains returns true if the intersection of this circle and x is equal to x.

◆ contains() [2/5]

bool lsst::sphgeom::Region::contains ( double  lon,
double  lat 
) const

contains tests whether the unit vector defined by the given longitude and latitude coordinates (in radians) is inside this region.

◆ contains() [3/5]

bool lsst::sphgeom::Region::contains ( double  x,
double  y,
double  z 
) const

contains tests whether the unit vector defined by the given (not necessarily normalized) coordinates is inside this region.

◆ contains() [4/5]

virtual bool lsst::sphgeom::Region::contains ( UnitVector3d const &  ) const
virtual

contains tests whether the given unit vector is inside this region.

Implements lsst::sphgeom::Region.

◆ contains() [5/5]

bool lsst::sphgeom::Circle::contains ( UnitVector3d const &  ) const
inlineoverridevirtual

contains tests whether the given unit vector is inside this region.

Implements lsst::sphgeom::Region.

◆ decode()

static std::unique_ptr< Circle > lsst::sphgeom::Circle::decode ( std::vector< uint8_t > const &  s)
inlinestatic

decode deserializes a Circle from a byte string produced by encode.

◆ dilateBy()

Circle & lsst::sphgeom::Circle::dilateBy ( Angle  r)

If r is positive, dilateBy increases the opening angle of this circle to include all points within angle r of its boundary. If r is negative, it decreases the opening angle to exclude those points instead.

If this circle is empty or full, or r is zero or NaN, there is no effect.

◆ encode()

std::vector< uint8_t > lsst::sphgeom::Circle::encode ( ) const
overridevirtual

encode serializes this region into an opaque byte string. Byte strings emitted by encode can be deserialized with decode.

Implements lsst::sphgeom::Region.

◆ expandedTo()

Circle lsst::sphgeom::Circle::expandedTo ( UnitVector3d const &  x) const
inline

expandedTo returns the minimal bounding circle for the union of this circle and x.

◆ expandTo()

Circle & lsst::sphgeom::Circle::expandTo ( UnitVector3d const &  x)

expandTo minimally expands this circle to contain x.

◆ getBoundingBox()

Box lsst::sphgeom::Circle::getBoundingBox ( ) const
overridevirtual

getBoundingBox returns a bounding-box for this region.

Implements lsst::sphgeom::Region.

◆ getBoundingBox3d()

Box3d lsst::sphgeom::Circle::getBoundingBox3d ( ) const
overridevirtual

getBoundingBox3d returns a 3-dimensional bounding-box for this region.

Implements lsst::sphgeom::Region.

◆ getBoundingCircle()

Circle lsst::sphgeom::Circle::getBoundingCircle ( ) const
inlineoverridevirtual

getBoundingCircle returns a bounding-circle for this region.

Implements lsst::sphgeom::Region.

◆ getCenter()

UnitVector3d const & lsst::sphgeom::Circle::getCenter ( ) const
inline

getCenter returns the center of this circle as a unit vector. It is arbitrary for empty and full circles.

◆ getOpeningAngle()

Angle lsst::sphgeom::Circle::getOpeningAngle ( ) const
inline

getOpeningAngle returns the opening angle of this circle - that is, the angle between its center vector and points on its boundary. It is negative or NaN for empty circles, and at least PI for full circles.

◆ getSquaredChordLength()

double lsst::sphgeom::Circle::getSquaredChordLength ( ) const
inline

getSquaredChordLength returns the squared length of chords between the circle center and points on the circle boundary. It is negative or NaN for empty circles, and at least 4 for full circles.

◆ intersects()

bool lsst::sphgeom::Circle::intersects ( UnitVector3d const &  x) const
inline

intersects returns true if the intersection of this circle and x is non-empty.

◆ isDisjointFrom()

bool lsst::sphgeom::Circle::isDisjointFrom ( UnitVector3d const &  x) const
inline

isDisjointFrom returns true if the intersection of this circle and x is empty.

◆ isWithin()

bool lsst::sphgeom::Circle::isWithin ( UnitVector3d const &  ) const
inline

isWithin returns true if the intersection of this circle and x is this circle.

◆ openingAngleFor()

Angle lsst::sphgeom::Circle::openingAngleFor ( double  squaredChordLength)
static

openingAngleFor computes and returns the angular separation between points in S² that are separated by the given squared chord length. The squared chord length l² and angle θ are related by l² = 4 sin²(θ/2).

◆ relate() [1/5]

Relationship lsst::sphgeom::Circle::relate ( Box const &  b) const
overridevirtual

Implements lsst::sphgeom::Region.

◆ relate() [2/5]

Relationship lsst::sphgeom::Circle::relate ( Circle const &  c) const
overridevirtual

Implements lsst::sphgeom::Region.

◆ relate() [3/5]

Relationship lsst::sphgeom::Circle::relate ( ConvexPolygon const &  p) const
overridevirtual

Implements lsst::sphgeom::Region.

◆ relate() [4/5]

Relationship lsst::sphgeom::Circle::relate ( Ellipse const &  e) const
overridevirtual

Implements lsst::sphgeom::Region.

◆ relate() [5/5]

Relationship lsst::sphgeom::Circle::relate ( Region const &  ) const
inlineoverridevirtual

relate computes the spatial relationships between this region A and another region B. The return value S is a bitset with the following properties:

  • Bit S & DISJOINT is set only if A and B do not have any points in common.
  • Bit S & CONTAINS is set only if A contains all points in B.
  • Bit S & WITHIN is set only if B contains all points in A.

Said another way: if the CONTAINS, WITHIN or DISJOINT bit is set, then the corresponding spatial relationship between the two regions holds conclusively. If it is not set, the relationship may or may not hold.

These semantics allow for conservative relationship computations. In particular, a Region may choose to implement relate by replacing itself and/or the argument with a simplified bounding region.

Implements lsst::sphgeom::Region.

◆ squaredChordLengthFor()

double lsst::sphgeom::Circle::squaredChordLengthFor ( Angle  openingAngle)
static

squaredChordLengthFor computes and returns the squared chord length between points in S² that are separated by the given angle. The squared chord length l² and angle θ are related by l² = 4 sin²(θ/2).


The documentation for this class was generated from the following files: