Skip to content

Instantly share code, notes, and snippets.

@cohnt
Created December 29, 2020 19:13
Show Gist options
  • Save cohnt/d2041741c188930f19681adfbfef998b to your computer and use it in GitHub Desktop.
Save cohnt/d2041741c188930f19681adfbfef998b to your computer and use it in GitHub Desktop.
import numpy as np
# Single point cloud case
point_cloud = np.random.rand(6,3) # 6 3D points
flattened = point_cloud.reshape(point_cloud.shape[0],-1) # One point in R^18
unflattened = flattened.reshape(-1,3) # 6 3D points
# Check that they're identical
print point_cloud
print unflattened
# Multiple point clouds case
point_clouds = np.random.rand(12,6,3) # 12 3D point clouds, each with 6 points
flattened = point_clouds.reshape(point_clouds.shape[0],-1) # 12 points in R^18
unflattened = flattened.reshape(flattened.shape[0],-1,3) # 12 3D point clouds, each with 6 points
# Check that they're identical
print point_clouds
print unflattened
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment