Skip to content

Instantly share code, notes, and snippets.

@OhkuboSGMS
Created December 10, 2021 15:20
Show Gist options
  • Save OhkuboSGMS/cd74b64b2fc9ce211bd9fd75c91390ea to your computer and use it in GitHub Desktop.
Save OhkuboSGMS/cd74b64b2fc9ce211bd9fd75c91390ea to your computer and use it in GitHub Desktop.
ground grid
import numpy as np
import open3d as o3d
def grid_line(size=2):
x = np.arange(-size, size + 1)
y = np.array((-size, size))
x_1 = np.repeat(x, 2)
y_1 = np.tile(y, size * 2 + 1)
z = np.zeros_like(x_1)
x_line = np.vstack((x_1, y_1, z)).T
y_line = np.vstack((y_1, x_1, z)).T
# xy,yz,zxの設定
points = np.concatenate((x_line, y_line))
idx = np.arange(0, points.size).reshape(-1, 2)
line_set = o3d.geometry.LineSet(
points=o3d.utility.Vector3dVector(points),
lines=o3d.utility.Vector2iVector(idx))
print(points)
o3d.visualization.draw(line_set, line_width=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment