LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
_circle.cc
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 * See COPYRIGHT file at the top of the source tree.
4 *
5 * This product includes software developed by the
6 * LSST Project (http://www.lsst.org/).
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22#include "pybind11/pybind11.h"
23#include "pybind11/numpy.h"
24
25#include "lsst/sphgeom/python.h"
26
27#include "lsst/sphgeom/Box.h"
28#include "lsst/sphgeom/Circle.h"
31#include "lsst/sphgeom/Region.h"
33
36
37namespace py = pybind11;
38using namespace pybind11::literals;
39
40namespace lsst {
41namespace sphgeom {
42
43template <>
45 cls.attr("TYPE_CODE") = py::int_(Circle::TYPE_CODE);
46
47 cls.def_static("empty", &Circle::empty);
48 cls.def_static("full", &Circle::full);
49 cls.def_static("squaredChordLengthFor", &Circle::squaredChordLengthFor,
50 "openingAngle"_a);
51 cls.def_static("openingAngleFor", &Circle::openingAngleFor,
52 "squaredChordLength"_a);
53
54 cls.def(py::init<>());
55 cls.def(py::init<UnitVector3d const &>(), "center"_a);
56 cls.def(py::init<UnitVector3d const &, Angle>(), "center"_a, "angle"_a);
57 cls.def(py::init<UnitVector3d const &, double>(), "center"_a,
58 "squaredChordLength"_a);
59 cls.def(py::init<Circle const &>(), "circle"_a);
60
61 cls.def("__eq__", &Circle::operator==, py::is_operator());
62 cls.def("__ne__", &Circle::operator!=, py::is_operator());
63 cls.def("__contains__",
64 (bool (Circle::*)(Circle const &) const) & Circle::contains,
65 py::is_operator());
66 // Rewrap this base class method since there are overloads in this subclass
67 cls.def("__contains__",
68 (bool (Circle::*)(UnitVector3d const &) const) & Circle::contains,
69 py::is_operator());
70
71 cls.def("isEmpty", &Circle::isEmpty);
72 cls.def("isFull", &Circle::isFull);
73 cls.def("getCenter", &Circle::getCenter);
74 cls.def("getSquaredChordLength", &Circle::getSquaredChordLength);
75 cls.def("getOpeningAngle", &Circle::getOpeningAngle);
76 cls.def("contains",
77 (bool (Circle::*)(Circle const &) const) & Circle::contains);
78 // Rewrap these base class methods since there are overloads in this subclass
79 cls.def("contains",
80 (bool (Circle::*)(UnitVector3d const &) const) & Circle::contains);
81 cls.def("contains", py::vectorize((bool (Circle::*)(double, double, double) const)&Circle::contains),
82 "x"_a, "y"_a, "z"_a);
83 cls.def("contains", py::vectorize((bool (Circle::*)(double, double) const)&Circle::contains),
84 "lon"_a, "lat"_a);
85
86 cls.def("isDisjointFrom",
87 (bool (Circle::*)(UnitVector3d const &) const) &
89 cls.def("isDisjointFrom",
90 (bool (Circle::*)(Circle const &) const) & Circle::isDisjointFrom);
91 cls.def("intersects",
92 (bool (Circle::*)(UnitVector3d const &) const) &
94 cls.def("intersects",
95 (bool (Circle::*)(Circle const &) const) & Circle::intersects);
96 cls.def("isWithin",
97 (bool (Circle::*)(UnitVector3d const &) const) & Circle::isWithin);
98 cls.def("isWithin",
99 (bool (Circle::*)(Circle const &) const) & Circle::isWithin);
100 cls.def("clipTo",
101 (Circle & (Circle::*)(UnitVector3d const &)) & Circle::clipTo);
102 cls.def("clipTo", (Circle & (Circle::*)(Circle const &)) & Circle::clipTo);
103 cls.def("clippedTo",
104 (Circle(Circle::*)(UnitVector3d const &) const) &
106 cls.def("clippedTo",
107 (Circle(Circle::*)(Circle const &) const) & Circle::clippedTo);
108 cls.def("expandTo",
109 (Circle & (Circle::*)(UnitVector3d const &)) & Circle::expandTo);
110 cls.def("expandTo",
111 (Circle & (Circle::*)(Circle const &)) & Circle::expandTo);
112 cls.def("expandedTo",
113 (Circle(Circle::*)(UnitVector3d const &) const) &
115 cls.def("expandedTo",
116 (Circle(Circle::*)(Circle const &) const) & Circle::expandedTo);
117 cls.def("dilateBy", &Circle::dilateBy, "radius"_a);
118 cls.def("dilatedBy", &Circle::dilatedBy, "radius"_a);
119 cls.def("erodeBy", &Circle::erodeBy, "radius"_a);
120 cls.def("erodedBy", &Circle::erodedBy, "radius"_a);
121 cls.def("getArea", &Circle::getArea);
122 cls.def("complement", &Circle::complement);
123 cls.def("complemented", &Circle::complemented);
124
125 // Note that the Region interface has already been wrapped.
126
127 cls.def("__str__", [](Circle const &self) {
128 return py::str("Circle({!s}, {!s})")
129 .format(self.getCenter(), self.getOpeningAngle());
130 });
131 cls.def("__repr__", [](Circle const &self) {
132 return py::str("Circle({!r}, {!r})")
133 .format(self.getCenter(), self.getOpeningAngle());
134 });
135 cls.def(py::pickle(&python::encode, &python::decode<Circle>));
136}
137
138} // sphgeom
139} // lsst
This file declares a class for representing circular regions on the unit sphere.
This file declares a class for representing convex polygons with great circle edges on the unit spher...
This file defines an interface for spherical regions.
This file declares a class for representing unit vectors in ℝ³.
Circle is a circular region on the unit sphere that contains its boundary.
Definition: Circle.h:46
bool contains(Circle const &x) const
contains returns true if the intersection of this circle and x is equal to x.
Definition: Circle.cc:64
static Angle openingAngleFor(double squaredChordLength)
openingAngleFor computes and returns the angular separation between points in S² that are separated b...
Definition: Circle.cc:52
bool isEmpty() const
Definition: Circle.h:109
static Circle empty()
Definition: Circle.h:50
Circle clippedTo(UnitVector3d const &x) const
Definition: Circle.h:165
Circle & clipTo(UnitVector3d const &x)
Definition: Circle.cc:91
double getArea() const
getArea returns the area of this circle in steradians.
Definition: Circle.h:205
Circle & dilateBy(Angle r)
If r is positive, dilateBy increases the opening angle of this circle to include all points within an...
Definition: Circle.cc:187
static Circle full()
Definition: Circle.h:52
bool isWithin(UnitVector3d const &) const
Definition: Circle.h:151
Circle expandedTo(UnitVector3d const &x) const
Definition: Circle.h:183
bool isFull() const
Definition: Circle.h:114
Circle dilatedBy(Angle r) const
Definition: Circle.h:200
bool isDisjointFrom(UnitVector3d const &x) const
Definition: Circle.h:137
Circle & erodeBy(Angle r)
Definition: Circle.h:201
double getSquaredChordLength() const
getSquaredChordLength returns the squared length of chords between the circle center and points on th...
Definition: Circle.h:123
Angle getOpeningAngle() const
getOpeningAngle returns the opening angle of this circle - that is, the angle between its center vect...
Definition: Circle.h:128
UnitVector3d const & getCenter() const
getCenter returns the center of this circle as a unit vector.
Definition: Circle.h:118
bool intersects(UnitVector3d const &x) const
Definition: Circle.h:144
Circle & complement()
complement sets this circle to the closure of its complement.
Definition: Circle.cc:197
Circle & expandTo(UnitVector3d const &x)
Definition: Circle.cc:123
static double squaredChordLengthFor(Angle openingAngle)
squaredChordLengthFor computes and returns the squared chord length between points in S² that are sep...
Definition: Circle.cc:41
Circle complemented() const
complemented returns the closure of the complement of this circle.
Definition: Circle.h:217
static constexpr uint8_t TYPE_CODE
Definition: Circle.h:48
Circle erodedBy(Angle r) const
Definition: Circle.h:202
Region is a minimal interface for 2-dimensional regions on the unit sphere.
Definition: Region.h:79
UnitVector3d is a unit vector in ℝ³ with components stored in double precision.
Definition: UnitVector3d.h:55
pybind11::bytes encode(Region const &self)
Encode a Region as a pybind11 bytes object.
Definition: utils.h:53
void defineClass(Pybind11Class &cls)
A base class for image defects.
This file declares a class for representing longitude/latitude angle boxes on the unit sphere.
This file declares a class for representing elliptical regions on the unit sphere.