MCPcopy Create free account
hub / github.com/MITK/MITK / InitVector3D

Function InitVector3D

Wrapping/Python/mitk/Vectors.cpp:57–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void InitVector3D(py::module_& m)
58{
59 py::class_<Vector3D>(m, "Vector3D",
60 R"(3D vector in world coordinates.
61
62A triple of double-precision scalars representing a direction or offset.
63Distinct from :py:class:`Point3D`: a vector encodes a displacement and is
64unaffected by translations of the coordinate system.
65)")
66 .def(py::init<>(),
67 "Construct a zero vector (0, 0, 0).")
68 .def(py::init<ScalarType, ScalarType, ScalarType>(), py::arg("x"), py::arg("y"), py::arg("z"),
69 R"(Construct a vector with the given components.
70
71Args:
72 x: X component.
73 y: Y component.
74 z: Z component.
75)")
76 .def("__getitem__", [](const Vector3D& p, size_t i) { return p[i]; },
77 "Return the i-th component (0 = x, 1 = y, 2 = z).")
78 .def("__setitem__", [](Vector3D& p, size_t i, ScalarType v) { p[i] = v; },
79 "Set the i-th component.")
80 .def_property("x",
81 [](const Vector3D& p) { return p[0]; },
82 [](Vector3D& p, ScalarType v) { p[0] = v; },
83 "X component.")
84 .def_property("y",
85 [](const Vector3D& p) { return p[1]; },
86 [](Vector3D& p, ScalarType v) { p[1] = v; },
87 "Y component.")
88 .def_property("z",
89 [](const Vector3D& p) { return p[2]; },
90 [](Vector3D& p, ScalarType v) { p[2] = v; },
91 "Z component.")
92 .def("__repr__",
93 [](const Vector3D& p) {
94 return "<Vector3D ["
95 + std::to_string(p[0]) + ", "
96 + std::to_string(p[1]) + ", "
97 + std::to_string(p[2]) + "]>";
98 });
99}
100
101void InitVectors(py::module_& m)
102{

Callers 1

InitVectorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected