SDF Solstice

Happy Solstice! My ornament this year is virtual.

Copy this link into your browser if the embed below looks weird. On mobile, use the native browser (Safari on iOS, Chrome on Android) to view in AR.

Three years ago, Signed Distance Functions (SDFs) were implicitly a part of my solstice celebration:

This year, I’m making the implicit explicit.

Here’s the code for the ornament, below. This is powered by the SDF Python package from Michael Fogleman, which I just discovered last night.

from sdf import *

# Create a sphere for the main body envelope of the ornament
s = sphere(25)

# this is the canonical SDF example box
f = sphere(10) & box(15)
c = cylinder(5)
f -= c.orient(X) | c.orient(Y) | c.orient(Z)

#round the edges
f = f.k(0.5)

# Create a 3D lattice by repeating the box in all three dimensions
lattice = f.repeat((15, 15, 15))

# Take the intersection of 's' and the lattice array
s = s & lattice

# Save the ornament as an STL file'ornament.stl', samples=2**28) #reduce to 2**27 or 2**26 for faster processing

import pyvista as pv

# Load the mesh from the STL file
mesh ='ornament.stl')

# Decimate the mesh
decimated_mesh = mesh.decimate(0.975)

# Save the decimated mesh'decimated_ornament.stl')