Skip to content

Instantly share code, notes, and snippets.

@jackd
Last active March 26, 2019 13:42
Show Gist options
  • Save jackd/22dfc19984443469e117a091e11d9e2b to your computer and use it in GitHub Desktop.
Save jackd/22dfc19984443469e117a091e11d9e2b to your computer and use it in GitHub Desktop.
trimesh issue with minimum sphere
import numpy as np
import trimesh
points = np.load('cloud_data.npy')
center, radius = trimesh.nsphere.minimum_nsphere(points)
print('data has already been centered/rescaled on minimum_nsphere')
print('center=%s, radius=%s' % (center, radius))
print('Largest point norm: %.3f' % np.max(np.linalg.norm(points, axis=-1)))
naive_center = (np.min(points, axis=0) + np.max(points, axis=0)) / 2
points = points - naive_center
r = np.max(np.linalg.norm(points, axis=-1))
print('Largest point norm after naive recentering: %.3f' % r)
# trimesh.points.PointCloud(points).show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment