22 #include "pybind11/pybind11.h"
29 using namespace pybind11::literals;
36 py::module::import(
"lsst.sphgeom.angle");
38 py::class_<NormalizedAngle>
cls(mod,
"NormalizedAngle");
41 py::implicitly_convertible<NormalizedAngle, Angle>();
43 cls.def_static(
"nan", &NormalizedAngle::nan);
44 cls.def_static(
"fromDegrees", &NormalizedAngle::fromDegrees);
45 cls.def_static(
"fromRadians", &NormalizedAngle::fromRadians);
47 cls.def_static(
"center", &NormalizedAngle::center,
"a"_a,
"b"_a);
49 cls.def(py::init<>());
50 cls.def(py::init<NormalizedAngle const &>());
51 cls.def(py::init<Angle const &>());
52 cls.def(py::init<double>(),
"radians"_a);
53 cls.def(py::init<LonLat const &, LonLat const &>(),
"a"_a,
"b"_a);
54 cls.def(py::init<Vector3d const &, Vector3d const &>(),
"a"_a,
"b"_a);
56 cls.def(
"__eq__", &NormalizedAngle::operator==, py::is_operator());
57 cls.def(
"__ne__", &NormalizedAngle::operator!=, py::is_operator());
58 cls.def(
"__lt__", &NormalizedAngle::operator<, py::is_operator());
59 cls.def(
"__gt__", &NormalizedAngle::operator>, py::is_operator());
60 cls.def(
"__le__", &NormalizedAngle::operator<=, py::is_operator());
61 cls.def(
"__ge__", &NormalizedAngle::operator>=, py::is_operator());
64 (
Angle(NormalizedAngle::*)()
const) & NormalizedAngle::operator-);
65 cls.def(
"__add__", &NormalizedAngle::operator+, py::is_operator());
67 (
Angle(NormalizedAngle::*)(
Angle const &)
const) &
68 NormalizedAngle::operator-,
70 cls.def(
"__mul__", &NormalizedAngle::operator*, py::is_operator());
71 cls.def(
"__rmul__", &NormalizedAngle::operator*, py::is_operator());
72 cls.def(
"__truediv__",
73 (
Angle(NormalizedAngle::*)(
double)
const) &
74 NormalizedAngle::operator/,
76 cls.def(
"__truediv__",
77 (
double (NormalizedAngle::*)(
Angle const &)
const) &
78 NormalizedAngle::operator/,
81 cls.def(
"asDegrees", &NormalizedAngle::asDegrees);
82 cls.def(
"asRadians", &NormalizedAngle::asRadians);
83 cls.def(
"isNan", &NormalizedAngle::isNan);
84 cls.def(
"getAngleTo", &NormalizedAngle::getAngleTo);
86 cls.def(
"__str__", [](NormalizedAngle
const &
self) {
87 return py::str(
"{!s}").format(
self.asRadians());
89 cls.def(
"__repr__", [](NormalizedAngle
const &
self) {
90 return py::str(
"NormalizedAngle({!r})").format(
self.asRadians());
93 cls.def(
"__reduce__", [
cls](NormalizedAngle
const &
self) {
94 return py::make_tuple(
cls, py::make_tuple(
self.asRadians()));