mirror of
https://github.com/PrimitiveAnything/PrimitiveAnything.git
synced 2026-05-08 00:58:55 +08:00
init
This commit is contained in:
21
primitive_anything/michelangelo/graphics/primitives/volume.py
Executable file
21
primitive_anything/michelangelo/graphics/primitives/volume.py
Executable file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def generate_dense_grid_points(bbox_min: np.ndarray,
|
||||
bbox_max: np.ndarray,
|
||||
octree_depth: int,
|
||||
indexing: str = "ij"):
|
||||
length = bbox_max - bbox_min
|
||||
num_cells = np.exp2(octree_depth)
|
||||
x = np.linspace(bbox_min[0], bbox_max[0], int(num_cells) + 1, dtype=np.float32)
|
||||
y = np.linspace(bbox_min[1], bbox_max[1], int(num_cells) + 1, dtype=np.float32)
|
||||
z = np.linspace(bbox_min[2], bbox_max[2], int(num_cells) + 1, dtype=np.float32)
|
||||
[xs, ys, zs] = np.meshgrid(x, y, z, indexing=indexing)
|
||||
xyz = np.stack((xs, ys, zs), axis=-1)
|
||||
xyz = xyz.reshape(-1, 3)
|
||||
grid_size = [int(num_cells) + 1, int(num_cells) + 1, int(num_cells) + 1]
|
||||
|
||||
return xyz, grid_size, length
|
||||
|
||||
Reference in New Issue
Block a user