LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
22 #include "pybind11/pybind11.h"
38 template <
typename OtherT>
39 void declareAngleComparisonOperators(
PyAngle&
cls) {
40 cls.def(
"__eq__", [](
Angle const&
self, OtherT
const&
other) {
return self ==
other; },
42 cls.def(
"__ne__", [](
Angle const&
self, OtherT
const&
other) {
return self !=
other; },
44 cls.def(
"__le__", [](
Angle const&
self, OtherT
const&
other) {
return self <=
other; },
46 cls.def(
"__ge__", [](
Angle const&
self, OtherT
const&
other) {
return self >=
other; },
48 cls.def(
"__lt__", [](
Angle const&
self, OtherT
const&
other) {
return self <
other; }, py::is_operator());
49 cls.def(
"__gt__", [](
Angle const&
self, OtherT
const&
other) {
return self >
other; }, py::is_operator());
57 [](
auto & mod,
auto &
cls)
mutable {
58 cls.def(
"__eq__", [](AngleUnit const& self, AngleUnit const& other) { return self == other; },
66 mod.attr(
"radians") = py::cast(
radians);
67 mod.attr(
"degrees") = py::cast(
degrees);
68 mod.attr(
"hours") = py::cast(
hours);
76 PyAngle(wrappers.module,
"Angle"),
77 [](
auto & mod,
auto &
cls)
mutable {
78 cls.def(py::init<double, AngleUnit>(), py::arg(
"val"), py::arg(
"units") =
radians);
79 cls.def(py::init<>());
80 declareAngleComparisonOperators<Angle>(
cls);
81 declareAngleComparisonOperators<double>(
cls);
82 declareAngleComparisonOperators<int>(
cls);
97 cls.def(
"__neg__", [](
Angle const&
self) {
return -
self; }, py::is_operator());
104 throw py::type_error(
"unsupported operand type(s) for /: 'Angle' and 'Angle'");
106 cls.def(
"__float__", &Angle::operator
double);
110 return py::make_tuple(
cls, py::make_tuple(py::cast(
self.asRadians())));
125 mod.def(
"isAngle", isAngle<Angle>);
126 mod.def(
"isAngle", isAngle<double>);
131 [](
auto & mod)
mutable {
132 mod.attr(
"PI") = py::float_(
PI);
133 mod.attr(
"TWOPI") = py::float_(
TWOPI);
134 mod.attr(
"HALFPI") = py::float_(
HALFPI);
136 mod.attr(
"SQRTPI") = py::float_(
SQRTPI);
137 mod.attr(
"INVSQRTPI") = py::float_(
INVSQRTPI);
138 mod.attr(
"ROOT2") = py::float_(
ROOT2);
constexpr AngleUnit degrees
constant with units of degrees
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Angle separation(Angle const &other) const noexcept
The signed difference between two Angles.
constexpr double radToDeg(double x) noexcept
constexpr double masToRad(double x) noexcept
constexpr double PI
The ratio of a circle's circumference to diameter.
Angle wrapCtr() const noexcept
Wrap this angle to the range [-π, π).
Angle wrap() const noexcept
Wrap this angle to the range [0, 2π).
constexpr AngleUnit arcseconds
constant with units of arcseconds
Angle abs(Angle const &a)
constexpr double asArcminutes() const noexcept
Return an Angle's value in arcminutes.
constexpr double ONE_OVER_PI
constexpr double radToArcsec(double x) noexcept
constexpr AngleUnit hours
constant with units of hours
constexpr double asRadians() const noexcept
Return an Angle's value in radians.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
ItemVariant const * other
constexpr AngleUnit milliarcseconds
constant with units of milliarcseconds
A helper class for subdividing pybind11 module across multiple translation units (i....
py::class_< Angle > PyAngle
constexpr double radToMas(double x) noexcept
A base class for image defects.
constexpr double degToRad(double x) noexcept
constexpr double asAngularUnits(AngleUnit const &units) const noexcept
Return an Angle's value in the specified units.
constexpr AngleUnit arcminutes
constant with units of arcminutes
py::class_< AngleUnit > PyAngleUnit
constexpr double asHours() const noexcept
Return an Angle's value in hours.
A class used to convert scalar POD types such as double to Angle.
A class representing an angle.
constexpr AngleUnit radians
constant with units of radians
constexpr double asDegrees() const noexcept
Return an Angle's value in degrees.
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Angle wrapNear(Angle const &refAng) const noexcept
Wrap this angle to a value x such that -π ≤ x - refAng ≤ π, approximately.
constexpr double asMilliarcseconds() const noexcept
Return an Angle's value in milliarcseconds.
constexpr double asArcseconds() const noexcept
Return an Angle's value in arcseconds.
constexpr double arcsecToRad(double x) noexcept
void wrapAngle(utils::python::WrapperCollection &wrappers)