LSST Applications 26.0.0,g0265f82a02+6660c170cc,g07994bdeae+30b05a742e,g0a0026dc87+17526d298f,g0a60f58ba1+17526d298f,g0e4bf8285c+96dd2c2ea9,g0ecae5effc+c266a536c8,g1e7d6db67d+6f7cb1f4bb,g26482f50c6+6346c0633c,g2bbee38e9b+6660c170cc,g2cc88a2952+0a4e78cd49,g3273194fdb+f6908454ef,g337abbeb29+6660c170cc,g337c41fc51+9a8f8f0815,g37c6e7c3d5+7bbafe9d37,g44018dc512+6660c170cc,g4a941329ef+4f7594a38e,g4c90b7bd52+5145c320d2,g58be5f913a+bea990ba40,g635b316a6c+8d6b3a3e56,g67924a670a+bfead8c487,g6ae5381d9b+81bc2a20b4,g93c4d6e787+26b17396bd,g98cecbdb62+ed2cb6d659,g98ffbb4407+81bc2a20b4,g9ddcbc5298+7f7571301f,ga1e77700b3+99e9273977,gae46bcf261+6660c170cc,gb2715bf1a1+17526d298f,gc86a011abf+17526d298f,gcf0d15dbbd+96dd2c2ea9,gdaeeff99f8+0d8dbea60f,gdb4ec4c597+6660c170cc,ge23793e450+96dd2c2ea9,gf041782ebf+171108ac67
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.
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.