LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
_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)
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.