MCPcopy Create free account
hub / github.com/davisking/dlib / bind_line

Function bind_line

tools/python/src/line.cpp:31–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29// ----------------------------------------------------------------------------------------
30
31void bind_line(py::module& m)
32{
33
34 const char* class_docs =
35"This object represents a line in the 2D plane. The line is defined by two points \n\
36running through it, p1 and p2. This object also includes a unit normal vector that \n\
37is perpendicular to the line.";
38
39 py::class_<line>(m, "line", class_docs)
40 .def(py::init<>(), "p1, p2, and normal are all the 0 vector.")
41 .def(py::init<dpoint,dpoint>(), py::arg("a"), py::arg("b"),
42"ensures \n\
43 - #p1 == a \n\
44 - #p2 == b \n\
45 - #normal == A vector normal to the line passing through points a and b. \n\
46 Therefore, the normal vector is the vector (a-b) but unit normalized and rotated clockwise 90 degrees."
47 /*!
48 ensures
49 - #p1 == a
50 - #p2 == b
51 - #normal == A vector normal to the line passing through points a and b.
52 Therefore, the normal vector is the vector (a-b) but unit normalized and rotated clockwise 90 degrees.
53 !*/
54 )
55 .def(py::init<point,point>(), py::arg("a"), py::arg("b"),
56"ensures \n\
57 - #p1 == a \n\
58 - #p2 == b \n\
59 - #normal == A vector normal to the line passing through points a and b. \n\
60 Therefore, the normal vector is the vector (a-b) but unit normalized and rotated clockwise 90 degrees."
61 /*!
62 ensures
63 - #p1 == a
64 - #p2 == b
65 - #normal == A vector normal to the line passing through points a and b.
66 Therefore, the normal vector is the vector (a-b) but unit normalized and rotated clockwise 90 degrees.
67 !*/
68 )
69 .def_property_readonly("normal", &line::normal, "returns a unit vector that is normal to the line passing through p1 and p2.")
70 .def("__repr__", &line__repr__)
71 .def("__str__", &line__str__)
72 .def_property_readonly("p1", &line::p1, "returns the first endpoint of the line.")
73 .def_property_readonly("p2", &line::p2, "returns the second endpoint of the line.");
74
75
76 m.def("signed_distance_to_line", &signed_distance_to_line<long>, py::arg("l"), py::arg("p"));
77 m.def("signed_distance_to_line", &signed_distance_to_line<double>, py::arg("l"), py::arg("p"),
78"ensures \n\
79 - returns how far p is from the line l. This is a signed distance. The sign \n\
80 indicates which side of the line the point is on and the magnitude is the \n\
81 distance. Moreover, the direction of positive sign is pointed to by the \n\
82 vector l.normal. \n\
83 - To be specific, this routine returns dot(p-l.p1, l.normal)"
84 /*!
85 ensures
86 - returns how far p is from the line l. This is a signed distance. The sign
87 indicates which side of the line the point is on and the magnitude is the
88 distance. Moreover, the direction of positive sign is pointed to by the

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 4

reverseFunction · 0.85
angle_between_linesFunction · 0.85
intersectFunction · 0.70
argClass · 0.50

Tested by

no test coverage detected