Boundaries#
Since the boundary of a point cloud is not uniquelly defined, the package offers the convex hull or a convex hull, for which the alpha shape package is used.
The data structure of the according class is similar to the others:
B = Bound(data_path=start_date.strftime("./bounds/%Y%m%d_%H/"), k=15,
convex=True, traj_data=T)
B.save()
The boolean “convex” attribute controls whether a convex or a concave hull should be used and, in case a concave hull should be used, the alpha attribute ($\alpha>0$) controls the concavity.$\alpha = 0$ recovers the convex hull and $\alpha \Rightarrow \infty$ returns only the points themselves.
B.convex = False
B.alpha = 0.001
is_bound, hulls = B.calc_or_load()
print(B)
The calc_bounds function returns two dictionaries. The keys are relevant datetimes and the first dict returns a boolean 1D numpy array that indicates whether a point is a boundary point. The second dict has the trimesh objects that represent the hulls (used for plotting later).
You can experiment with this by using the interactive matplotlib widget generated by the plot_bound function (default plot method).
B.plot()
Implemented is also an algorithm that, given a point cloud, find the largest alpha that leads to a hull that still contains all points.
B.alpha = None
is_bound, hulls = B.calc_or_load()