Physical-Digital Sphere Packing Experiment

In an earlier post I had discussed a script for packing a single layer of spheres on a complex curved surface. A script of this type that I developed was used in the Cradle project by Ball-Nogues Studio. However, in the Cradle project the script had been used only to generate possible simulations of the design for structural analysis (done by Buro Happold) and for estimating material quantities prior to the start of fabrication. The script was not used to generate the exact placement of spheres in the final project. A 3D model produced by the script was only used as an approximate guide for the placement of spheres during construction. The reason for this was that any small deviations between the physical construction and the digital model could cause large differences in the packing of the spheres. I had discussed this in detail in a post titled ‘Santa Monica Cradle: Reflections on Craft and Computation’.

The following script and physical experiment using the script bridges the gap between the digital model and the physical construction process by digitally simulating the packing of the spheres in parallel with their physical packing. This script allows for a digital tolerance in order to absorb imperfections in the physical model. This process does not allow the digital model to dictate the physical construction but instead allows the digital model to mimic the physical packing of imperfect spheres on an imperfect surface.

The physical experiment involved packing spherical ball-bearings (with rust on their surface creating imperfections) on a simple conical paper surface. The paper cone was made from regular letter paper by cutting out a circle with a scissors and folding it into a cone and taping it with sticky tape. The result was thus an imperfect conical surface. The following montage of screen shots from the running script and the steps in the physical sphere packing show how the script and physical construction run in parallel. The tolerance required here was 0.001″

The way in which I hope to make use of this script is to use the resulting 3D model of the physical sphere packing as a basis to design components that can be custom made to interface with a given physical configuration of spheres.

Below is the script used in this experiment:

Option Explicit
‘Script written by <Ayodh Kamath>
‘Script copyrighted by <Ayodh Kamath>
‘Script version Friday, March 25, 2011 10:15:38 PM

Call Main()
Sub Main()
 
 Dim arrSurf, arrSphere1, arrSphere2
 Dim arrBoundingBox, realRadius1, realRadius2, arrLine, arrCentre1, arrCentre2, binCarryOn, arrJoin, arrIntCrv, arrIntPt1, arrIntPt2, realDist1, realDist2, arrCentre
 Dim arrSphere, arrSurf1
 Dim realRadius, arrSidePt
 Dim arrIntSphere1, arrIntSphere2, arrInt
 Dim arrSpheres, intUnselect
 Dim i, j

 arrSurf = Rhino.GetObject(“Select surface to populate”)
 arrSphere1 = Rhino.GetObject(“Select first sphere”)
 arrSphere2 = Rhino.GetObject(“Select second sphere”)
 
 arrBoundingBox = Rhino.BoundingBox(arrSphere1)
 realRadius1 = (Rhino.Distance(arrBoundingBox(0), arrBoundingBox(1)))/2
 arrLine = Rhino.AddLine(arrBoundingBox(0), arrBoundingBox(6))
 arrCentre1 = Rhino.CurveMidPoint(arrLine)
 Rhino.DeleteObject arrLine
 
 arrBoundingBox = Rhino.BoundingBox(arrSphere2)
 realRadius2 = (Rhino.Distance(arrBoundingBox(0), arrBoundingBox(1)))/2
 arrLine = Rhino.AddLine(arrBoundingBox(0), arrBoundingBox(6))
 arrCentre2 = Rhino.CurveMidPoint(arrLine)
 Rhino.DeleteObject arrLine
 
 binCarryOn = 1
 
 Do While binCarryOn = 1
 
  realRadius = Rhino.GetReal(“Enter radius of tangent sphere:”)
  arrSidePt = Rhino.GetObject(“Select point in desired direction”)
 
  arrSphere1 = Rhino.AddSphere(arrCentre1, (realRadius1+realRadius))
  arrSphere2 = Rhino.AddSphere(arrCentre2, (realRadius2+realRadius))
 
  arrInt = Rhino.SurfaceSurfaceIntersection(arrSphere1, arrSphere2,, vbTrue)
  Rhino.DeleteObject arrSphere1
  Rhino.DeleteObject arrSphere2
  
  If UBound(arrInt)>0 Then
    
   ReDim arrSegments(UBound(arrInt))
    
   For j = 0 To UBound(arrInt)
     
    arrSegments(j) = arrInt(j,1)
     
   Next
    
   arrJoin = Rhino.JoinCurves(arrSegments, vbTrue)
     
   arrIntCrv = arrJoin(0)
    
  Else
    
   arrIntCrv = arrInt(0,1)
    
  End If
  
  arrSurf1 = Rhino.OffsetSurface(arrSurf, realRadius)
  arrInt = Rhino.CurveSurfaceIntersection(arrIntCrv, arrSurf1)
  Rhino.DeleteObject arrIntCrv
  Rhino.DeleteObject arrSurf1
  
  If IsArray(arrInt) Then
   
   If UBound(arrInt)>0 Then
    
    arrIntPt1 = arrInt(0,1)
    
    arrIntPt2 = arrInt(1,1)
    
    realDist1 = Rhino.Distance(arrIntPt1, Rhino.PointCoordinates(arrSidePt))
    
    realDist2 = Rhino.Distance(arrIntPt2, Rhino.PointCoordinates(arrSidePt))
    
    If realDist1>realDist2 Then arrCentre = arrInt(1,1)
    
    If realDist2>realDist1 Then arrCentre = arrInt(0,1)
    
   Else
    
    ‘arrCentre = arrInt(0,1)
    
   End If
   
  End If
  
  arrSphere = Rhino.AddSphere(arrCentre, realRadius)
  
  Rhino.Command “SelClosedSrf”
  
  arrSpheres = Rhino.SelectedObjects
  
  For i = 0 To UBound(arrSpheres)
   
   arrInt = Rhino.SurfaceSurfaceIntersection(arrSphere, arrSpheres(i), 0.001, vbTrue)
   
   If IsArray(arrInt) Then
    
    If (arrInt(0,0) <> 4) And (arrInt(0,0) <> 5) Then
    
     Rhino.DeleteObject arrSphere
     intUnselect = Rhino.UnselectAllObjects
     Rhino.Command “SelCrv”
     Rhino.Command “Delete”
     
    End If
    
   End If
   
  Next
  
  Call Rhino.Command(“_ViewCaptureToFile”)
   
  arrSphere1 = Rhino.GetObject(“Select first sphere”)
  
  If Not IsNull(arrSphere1) Then
   
   arrSphere2 = Rhino.GetObject(“Select second sphere”)
   
   arrBoundingBox = Rhino.BoundingBox(arrSphere1)
   realRadius1 = (Rhino.Distance(arrBoundingBox(0), arrBoundingBox(1)))/2
   arrLine = Rhino.AddLine(arrBoundingBox(0), arrBoundingBox(6))
   arrCentre1 = Rhino.CurveMidPoint(arrLine)
   Rhino.DeleteObject arrLine
 
   arrBoundingBox = Rhino.BoundingBox(arrSphere2)
   realRadius2 = (Rhino.Distance(arrBoundingBox(0), arrBoundingBox(1)))/2
   arrLine = Rhino.AddLine(arrBoundingBox(0), arrBoundingBox(6))
   arrCentre2 = Rhino.CurveMidPoint(arrLine)
   Rhino.DeleteObject arrLine
   
  Else
   
   binCarryOn = 0
   
  End If
 
 Loop
 
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s