9#include <boost/python/class.hpp>
10#include <boost/python/copy_const_reference.hpp>
11#include <boost/python/dict.hpp>
12#include <boost/python/errors.hpp>
13#include <boost/python/list.hpp>
14#include <boost/python/operators.hpp>
15#include <boost/python/return_arg.hpp>
16#include <boost/python/return_value_policy.hpp>
31Py_hash_t hashV3D(
V3D &self) {
32 boost::python::object tmpObj(self.
toString());
34 return PyObject_Hash(tmpObj.ptr());
37double getV3DItem(
V3D &self,
int index) {
49 PyErr_SetString(PyExc_IndexError,
"index out of range");
50 throw boost::python::error_already_set();
68 PyErr_SetString(PyExc_IndexError,
"index out of range");
69 throw boost::python::error_already_set();
73int getV3DLength(
V3D &self) {
83 data[
'x'] = vector.
X();
84 data[
'y'] = vector.
Y();
85 data[
'z'] = vector.
Z();
90 vector.
setX(extract<double>(state[
'x']));
91 vector.
setY(extract<double>(state[
'y']));
92 vector.
setZ(extract<double>(state[
'z']));
99 class_<V3D>(
"V3D", init<>(
"Construct a V3D at the origin"))
101 .def(init<double, double, double>(
"Construct a V3D with X,Y,Z coordinates"))
102 .def(
"X", &
V3D::X, arg(
"self"),
"Returns the X coordinate")
103 .def(
"Y", &
V3D::Y, arg(
"self"),
"Returns the Y coordinate")
104 .def(
"Z", &
V3D::Z, arg(
"self"),
"Returns the Z coordinate")
105 .def(
"getX", &
V3D::X, arg(
"self"),
106 "Returns the X coordinate")
107 .def(
"getY", &
V3D::Y, arg(
"self"),
108 "Returns the Y coordinate")
109 .def(
"getZ", &
V3D::Z, arg(
"self"),
110 "Returns the Z coordinate")
111 .def(
"distance", &
V3D::distance, (arg(
"self"), arg(
"other")),
112 "Returns the distance between this vector and another")
113 .def(
"angle", &
V3D::angle, (arg(
"self"), arg(
"other")),
"Returns the angle between this vector and another")
114 .def(
"cosAngle", &
V3D::cosAngle, (arg(
"self"), arg(
"other")),
115 "Returns cos(angle) between this vector and another")
116 .def(
"zenith", &
V3D::zenith, (arg(
"self"), arg(
"other")),
"Returns the zenith between this vector and another")
118 "Computes the scalar product between this and another vector")
120 "Computes the cross product between this and another vector")
121 .def(
"norm", &
V3D::norm, arg(
"self"),
"Calculates the length of the vector")
122 .def(
"norm2", &
V3D::norm2, arg(
"self"),
"Calculates the squared length of the vector")
123 .def(
"__add__", &V3D::operator+, (arg(
"left"), arg(
"right")))
124 .def(
"__iadd__", &V3D::operator+=, return_self<>(), (arg(
"self"), arg(
"other")))
125 .def(
"__sub__",
static_cast<V3D (
V3D::*)(
const V3D &) const
>(&V3D::operator-), (arg(
"left"), arg(
"right")))
126 .def(
"__isub__", &V3D::operator-=, return_self<>(), (arg(
"self"), arg(
"other")))
127 .def(
"__neg__",
static_cast<V3D (
V3D::*)() const
>(&V3D::operator-), (arg(
"self")))
128 .def(
"__len__", &getV3DLength, (arg(
"self")),
129 "Returns the length of the vector for list-like interface. Always "
131 .def(
"__getitem__", &getV3DItem, (arg(
"self"), arg(
"index")),
132 "Access the V3D-object like a list for getting elements.")
133 .def(
"__setitem__", &setV3DItem, (arg(
"self"), arg(
"index"), arg(
"value")),
134 "Access the V3D-object like a list for setting elements.")
142 .def(self *
double())
143 .def(self *=
double())
148 .def(self_ns::str(self))
149 .def(self_ns::repr(self))
150 .def(
"__hash__", &hashV3D)
152 "Calculate direction angles from direction cosines")
153 .def(
"directionAngles", &directionAnglesDefault, arg(
"self"),
154 "Calculate direction angles from direction cosines");
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
double distance(const V3D &v) const noexcept
Calculates the distance between two vectors.
double zenith(const V3D &) const noexcept
Zenith (theta) angle between this and another vector.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
constexpr V3D cross_prod(const V3D &v) const noexcept
Cross product (this * argument)
constexpr double Y() const noexcept
Get y.
std::string toString() const
void setZ(const double zz) noexcept
Set is z position.
V3D directionAngles(bool inDegrees=true) const
Direction angles.
double angle(const V3D &) const
Angle between this and another vector.
double norm() const noexcept
constexpr double norm2() const noexcept
Vector length squared.
void setX(const double xx) noexcept
Set is x position.
double cosAngle(const V3D &) const
cos(Angle) between this and another vector
void setY(const double yy) noexcept
Set is y position.
constexpr double Z() const noexcept
Get z.
static void setstate(V3D &vector, dict state)
static dict getstate(const V3D &vector)