Similarly, to keep the beams and joints outside of a spherical volume, we add a constraint on each beam that the distance between the center of this sphere and the beam (a line segment) must be be greater than or equal to some radius R. This distance formula may be found in geometry textbooks, such as Spinier [1987]. For optimization purposes, we approximated the gradients of this function with a finite-difference method