Skip to content

Commit 9e0f6ad

Browse files
authored
Export arrow(seg_idx, t) (#17)
* add arrow * update * update headers
1 parent 6abc088 commit 9e0f6ad

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/polyline_ruler.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct PolylineRuler
249249
const RowVectors &polyline() const { return polyline_; }
250250
int N() const { return N_; }
251251
bool is_wgs84() const { return is_wgs84_; }
252+
Eigen::Vector3d k() const { return k_; }
252253

253254
static Eigen::VectorXd ranges(const Eigen::Ref<const RowVectors> &polyline,
254255
bool is_wgs84 = false)
@@ -407,6 +408,12 @@ struct PolylineRuler
407408
t, is_wgs84_);
408409
}
409410

411+
std::pair<Eigen::Vector3d, Eigen::Vector3d> arrow(int seg_idx,
412+
double t) const
413+
{
414+
return std::make_pair(at(seg_idx, t), dir(seg_idx));
415+
}
416+
410417
std::pair<Eigen::Vector3d, Eigen::Vector3d>
411418
arrow(double range, bool smooth_joint = true) const
412419
{

src/pybind11_polyline_ruler.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ CUBAO_INLINE void bind_polyline_ruler(py::module &m)
7979
.def("polyline", &PolylineRuler::polyline, rvp::reference_internal)
8080
.def("N", &PolylineRuler::N)
8181
.def("is_wgs84", &PolylineRuler::is_wgs84)
82+
.def("k", &PolylineRuler::k)
8283
//
8384
.def_static(
8485
"_ranges",
@@ -119,7 +120,12 @@ CUBAO_INLINE void bind_polyline_ruler(py::module &m)
119120
.def("at",
120121
py::overload_cast<int, double>(&PolylineRuler::at, py::const_),
121122
py::kw_only(), "segment_index"_a, "t"_a)
122-
.def("arrow", &PolylineRuler::arrow, "range"_a, //
123+
.def("arrow",
124+
py::overload_cast<int, double>(&PolylineRuler::arrow, py::const_),
125+
py::kw_only(), "index"_a, "t"_a)
126+
.def("arrow",
127+
py::overload_cast<double, bool>(&PolylineRuler::arrow, py::const_),
128+
"range"_a, //
123129
py::kw_only(), "smooth_joint"_a = true)
124130
.def("arrows",
125131
py::overload_cast<const Eigen::Ref<const Eigen::VectorXd> &, bool>(

tests/test_basic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ def test_polyline_ruler():
305305
assert np.all(xyz == [101, 10, 0])
306306
assert np.all(dir == [1, 0, 0])
307307

308+
xyz, dir = ruler.arrow(index=0, t=0.2)
309+
assert np.all(xyz == [2, 0, 0])
310+
assert np.all(dir == [1, 0, 0])
311+
308312
ranges, xyzs, dirs = ruler.arrows([-1, 10, 111])
309313
assert len(ranges) == len(xyzs) == len(dirs)
310314
ranges, xyzs, dirs = ruler.arrows(10.0)

0 commit comments

Comments
 (0)