Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixiong-tang committed Dec 14, 2024
1 parent ffc141d commit 57544a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/concave_hull/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import List, Tuple, Union

import numpy as np

from ._core import __version__ # noqa
Expand Down
5 changes: 5 additions & 0 deletions src/convex_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <vector>
#include <algorithm>

namespace cubao
{
namespace convex_hull
{

inline int orientation(const Eigen::Vector2d &a, const Eigen::Vector2d &b,
const Eigen::Vector2d &c)
{
Expand Down
12 changes: 6 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
plt.plot(points[simplex, 0], points[simplex, 1], "g-", alpha=0.5)

hull = convex_hull_indexes(points[:, :2])
for i, j in zip(hull[:-1], hull[1:]):
for i, j in zip(hull[:-1], hull[1:]): # noqa: B905
plt.plot(
[points[i, 0], points[j, 0]], [points[i, 1], points[j, 1]], "g-", alpha=0.5
)

idxes = concave_hull_indexes(
points[:, :2],
length_threshold=50,
# convex_hull_indexes=convex_hull.vertices.astype(np.int32),
convex_hull_indexes=convex_hull.vertices.astype(np.int32),
)
# you can get coordinates by `points[idxes]`
assert np.all(points[idxes] == concave_hull(points, length_threshold=50))
# assert np.all(points[idxes] == concave_hull(points, length_threshold=50))

# for f, t in zip(idxes[:-1], idxes[1:]): # noqa
# seg = points[[f, t]]
# plt.plot(seg[:, 0], seg[:, 1], "r-", alpha=0.5)
for f, t in zip(idxes[:-1], idxes[1:]): # noqa
seg = points[[f, t]]
plt.plot(seg[:, 0], seg[:, 1], "r-", alpha=0.5)

plt.gca().set_aspect("equal")
# plt.savefig("docs/hull.png")
Expand Down

0 comments on commit 57544a7

Please sign in to comment.