MCPcopy Create free account
hub / github.com/JeremyBYU/polylidar / main

Function main

examples/python/basic2d.py:14–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def main():
15 kwargs = dict(num_groups=2, group_size=1000, dist=100.0, seed=1)
16 # generate 2 random normally distributed clusters of points, 200 X 2 numpy array.
17 points = generate_test_points(**kwargs)
18 lmax = get_estimated_lmax(**kwargs)
19 polylidar_kwargs = dict(alpha=0.0, lmax=lmax, min_triangles=5)
20
21 # Convert points to matrix format (no copy) and make Polylidar3D Object
22 points_mat = MatrixDouble(points, copy=False)
23 polylidar = Polylidar3D(**polylidar_kwargs)
24
25 # Extract the mesh, planes, polygons, and time
26 t1 = time.perf_counter()
27 mesh, planes, polygons = polylidar.extract_planes_and_polygons(points_mat)
28 t2 = time.perf_counter()
29
30 print("Took {:.2f} milliseconds".format((t2 - t1) * 1000))
31
32 # Convert to numpy format, no copy with np.asarray()
33 triangles = np.asarray(mesh.triangles)
34
35 fig, ax = plt.subplots(figsize=(10, 10), nrows=1, ncols=1)
36 # plot points
37 ax.scatter(points[:, 0], points[:, 1], c='k')
38 # plot all triangles
39 # plt.triplot(points[:,0], points[:,1], triangles) # better alternative
40 plot_triangles(get_triangles_from_list(triangles, points), ax)
41 # plot seperated planar triangular segments
42 triangle_meshes = get_colored_planar_segments(planes, triangles, points)
43 plot_triangle_meshes(triangle_meshes, ax)
44 # plot polygons
45 plot_polygons(polygons, points, ax)
46 plt.axis('equal')
47 plt.show()
48
49
50if __name__ == "__main__":

Callers 1

basic2d.pyFile · 0.70

Calls 8

generate_test_pointsFunction · 0.90
get_estimated_lmaxFunction · 0.90
plot_trianglesFunction · 0.90
get_triangles_from_listFunction · 0.90
plot_triangle_meshesFunction · 0.90
plot_polygonsFunction · 0.90
Polylidar3DClass · 0.85

Tested by

no test coverage detected