sphere_sdf — 3D sdf_csg op

• 数据种类:coordgrid → sdf

• 调用: import fullseye as fs; fs.ledger.sphere_sdf(grid, center, R)(要直接调用实现,import sdf_ops; sdf_ops.sphere_sdf(grid, center, R);从台账取用则 ops3d.get("sphere_sdf"))

用法

球的符号距离场:|p - center| - R(内负外正)。

grid 是最后一轴为 3 的坐标数组 (..., 3)(grid_coords 的输出或 (N,3) 点云)。center 长度为 3,R>=0 为半径。返回值的 shape 为 grid.shape[:-1]。严格的 SDF (梯度范数 1)。sdf_offset(sphere_sdf(g,c,R), r) == sphere_sdf(g,c,R+r)。

R < 0 或形状不正确的 grid / center 会引发 ValueError。

计算:np.linalg.norm(grid - center, axis=-1) - R。坐标单位直接成为距离的单位(传入 grid_coords 的 world 坐标即为 world 单位)。坐标分量的顺序为 grid 最后一轴的顺序(grid_coords 时为 (x, y, z)),center 也用同样顺序。

参数与检查(ValueError):

• grid:最后一轴为 3 的 float 数组 (..., 3)(也可为 1-D 的 (3,)。0-D 或最后一轴不为 3 的会被拒绝)。

• center:元素数 3(无法 reshape(3) 时为 numpy 的 ValueError)。

• R:可被 float() 转换的标量。传入旋转矩阵等时也为 ValueError (此参数是半径而非位姿)。R < 0 被拒绝,R = 0 即为到中心的距离场本身。

返回值:grid.shape[:-1] 的 float64(grid_coords 的输出时为 (nx, ny, nz))。中心处为 -R,表面为 0,外侧为正。

用法:用 grid_coords 生成网格 → sphere_sdf / box_sdf → 用 sdf_union / sdf_subtract 做 CSG → 以 <= 0 为占用做 marching cubes(向 voxel_to_mesh 传入 -sdf,相当于 iso=0 取等值面)。

参考(示例数据、文献)

• 示例数据目录(下载 URL / 许可证) —— 2-D 用 skimage.data(BSD/公有领域)加合成图,3-D 给出真实数据源(Stanford/PDS 等)的下载 URL。

• 算子来历与参考文献 —— 该算子族所依据的研究/方法出处。

可运行的示例(实际调用该算子并已验证的样例)

• annotate3d_figure — py -3.11 examples_3d/annotate3d_figure.py

• gear_metrology — py -3.11 examples_3d/gear_metrology.py

• molecule_atom_count — py -3.11 examples_3d/molecule_atom_count.py

• procedural_hand — py -3.11 examples_3d/procedural_hand.py

• render_beauty — py -3.11 examples_3d/render_beauty.py

• sdf_csg — py -3.11 examples_3d/sdf_csg.py

• sfm_recon — py -3.11 examples_3d/sfm_recon.py

类型可衔接的下一个算子(可接受 sdf 作为输入)

sdf_to_occupancy · fuse_to_voxel · integrate · extract_surface_points · query_distance · sdf_union · sdf_intersect · sdf_subtract

同类别(sdf_csg)

grid_coords · box_sdf · plane_sdf · cylinder_sdf · torus_sdf · capsule_sdf · sdf_union · sdf_intersect


*Provenance: sdf_ops.py — 3D 算子登记表。本条目由 tools/opdocs.py md 自动生成(请勿手工编辑)。*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.