22 #include "pybind11/pybind11.h"
28 using namespace pybind11::literals;
35 py::class_<Angle>
cls(mod,
"Angle");
37 cls.def_static(
"nan", &Angle::nan);
38 cls.def_static(
"fromDegrees", &Angle::fromDegrees);
39 cls.def_static(
"fromRadians", &Angle::fromRadians);
41 cls.def(py::init<>());
42 cls.def(py::init<double>(),
"radians"_a);
43 cls.def(py::init<Angle>(),
"angle"_a);
48 [](NormalizedAngle &
a) {
49 return new Angle(
a.asRadians());
53 cls.def(
"__eq__", &Angle::operator==, py::is_operator());
54 cls.def(
"__ne__", &Angle::operator!=, py::is_operator());
55 cls.def(
"__lt__", &Angle::operator<, py::is_operator());
56 cls.def(
"__gt__", &Angle::operator>, py::is_operator());
57 cls.def(
"__le__", &Angle::operator<=, py::is_operator());
58 cls.def(
"__ge__", &Angle::operator>=, py::is_operator());
60 cls.def(
"__neg__", (
Angle(
Angle::*)()
const) & Angle::operator-);
61 cls.def(
"__add__", &Angle::operator+, py::is_operator());
65 cls.def(
"__mul__", &Angle::operator*, py::is_operator());
66 cls.def(
"__rmul__", &Angle::operator*, py::is_operator());
67 cls.def(
"__truediv__", (
Angle(
Angle::*)(
double)
const) & Angle::operator/,
69 cls.def(
"__truediv__",
70 (
double (
Angle::*)(
Angle const &)
const) & Angle::operator/,
73 cls.def(
"__iadd__", &Angle::operator+=);
74 cls.def(
"__isub__", &Angle::operator-=);
75 cls.def(
"__imul__", &Angle::operator*=);
76 cls.def(
"__itruediv__", &Angle::operator/=);
78 cls.def(
"asDegrees", &Angle::asDegrees);
79 cls.def(
"asRadians", &Angle::asRadians);
80 cls.def(
"isNormalized", &Angle::isNormalized);
81 cls.def(
"isNan", &Angle::isNan);
83 cls.def(
"__str__", [](
Angle const &
self) {
84 return py::str(
"{!s}").format(
self.asRadians());
86 cls.def(
"__repr__", [](
Angle const &
self) {
87 return py::str(
"Angle({!r})").format(
self.asRadians());
91 return py::make_tuple(
cls, py::make_tuple(
self.asRadians()));