DeepSDFStruct.sdf_primitives#

Primitive SDF Shapes#

This module provides basic geometric primitive SDFs that can be used as building blocks for more complex geometries. All primitives inherit from SDFBase and can be combined using boolean operations.

Available Primitives#

  • SphereSDF: Sphere with specified center and radius

  • CylinderSDF: Infinite cylinder along a coordinate axis

  • TorusSDF: Torus with major and minor radii

  • PlaneSDF: Half-space defined by a point and normal vector

  • CornerSpheresSDF: Cube with spherical cutouts at corners

  • CrossMsSDF: Cross-shaped structure (intersection of three cylinders)

All primitives support PyTorch’s automatic differentiation and can be used in optimization workflows.

Classes

CornerSpheresSDF(radius[, limit])

CrossMsSDF(radius)

CylinderSDF(point, axis, radius)

PlaneSDF(point, normal)

SphereSDF(center, radius)

Signed distance function for a sphere.

TorusSDF(center, R, r)

Signed distance function for a torus.

class DeepSDFStruct.sdf_primitives.CornerSpheresSDF(radius, limit=1.0)#

Bases: DeepSDFStruct.SDF.SDFBase

class DeepSDFStruct.sdf_primitives.CrossMsSDF(radius)#

Bases: DeepSDFStruct.SDF.SDFBase

class DeepSDFStruct.sdf_primitives.CylinderSDF(point, axis, radius)#

Bases: DeepSDFStruct.SDF.SDFBase

class DeepSDFStruct.sdf_primitives.PlaneSDF(point, normal)#

Bases: DeepSDFStruct.SDF.SDFBase

class DeepSDFStruct.sdf_primitives.SphereSDF(center, radius)#

Bases: DeepSDFStruct.SDF.SDFBase

Signed distance function for a sphere.

Computes the signed distance from query points to a sphere surface. The distance is negative inside the sphere, zero on the surface, and positive outside.

Parameters:
  • center (array-like of shape (3,)) – Center point of the sphere in 3D space.

  • radius (float) – Radius of the sphere.

Examples

>>> import torch
>>> from DeepSDFStruct.sdf_primitives import SphereSDF
>>>
>>> sphere = SphereSDF(center=[0, 0, 0], radius=1.0)
>>> points = torch.tensor([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]])
>>> distances = sphere(points)
>>> print(distances)  # [-1.0, 0.0] (center, surface)
class DeepSDFStruct.sdf_primitives.TorusSDF(center, R, r)#

Bases: DeepSDFStruct.SDF.SDFBase

Signed distance function for a torus.

A torus is a surface of revolution generated by revolving a circle (minor radius) around an axis at a specified distance (major radius).

Parameters:
  • center (array-like of shape (3,)) – Center point of the torus in 3D space.

  • R (float) – Major radius (distance from torus center to tube center).

  • r (float) – Minor radius (radius of the tube).

Examples

>>> from DeepSDFStruct.sdf_primitives import TorusSDF
>>> import torch
>>>
>>> torus = TorusSDF(center=[0, 0, 0], R=1.0, r=0.3)
>>> points = torch.tensor([[1.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
>>> distances = torus(points)